Exemple #1
0
void mount_spiffs(){

	int slot = rboot_get_current_rom();

#ifndef DISABLE_SPIFFS
	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40300000, SPIFF_SIZE);
		spiffs_mount_manual(0x40300000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40500000, SPIFF_SIZE);
		spiffs_mount_manual(0x40500000, SPIFF_SIZE);
#endif
	}
#else
	debugf("spiffs disabled");
#endif

}
void otaUpdate_CallBack(bool result) {
	
    Debug.println("In OTA callback...");
    if(result == true)
    {
        // success
        uint8 slot;
        slot = rboot_get_current_rom();
        if (slot == 0) slot = 1; else slot = 0;
#ifndef DISABLE_SPIFFS
        Debug.printf("Firmware updated, storing AppSettings to new spiffs...\r\n");
        AppSettings.load();
        spiffs_unmount();
        if (slot == 0)
        {
#ifdef RBOOT_SPIFFS_0
            Debug.printf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
            spiffs_mount_manual(RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
#else
            Debug.printf("trying to mount spiffs at %x, length %d", 0x40300000, SPIFF_SIZE);
            spiffs_mount_manual(0x40300000, SPIFF_SIZE);
#endif
        }
        else
        {
#ifdef RBOOT_SPIFFS_1
            Debug.printf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
            spiffs_mount_manual(RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
#else
            Debug.printf("trying to mount spiffs at %x, length %d", 0x40500000, SPIFF_SIZE);
            spiffs_mount_manual(0x40500000, SPIFF_SIZE);
#endif
        }
        AppSettings.save();
#else
        Debug.printf("spiffs disabled");
#endif
        // set to boot new rom and then reboot
        Debug.printf("Firmware updated, rebooting to rom %d...\r\n", slot);
        rboot_set_current_rom(slot);
        System.restart();
    }
    else
    {
        // fail
        Debug.println("Firmware update failed!");
        if (numOtaTrials < 6)
            StartOtaUpdate();
        else
            numOtaTrials = 0;
    }
}
Exemple #3
0
void init() {
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(false); // Debug output to serial
	
	// mount spiffs
	int slot = rboot_get_current_rom();

	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40300000, SPIFF_SIZE);
		spiffs_mount_manual(0x40300000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40500000, SPIFF_SIZE);
		spiffs_mount_manual(0x40500000, SPIFF_SIZE);
#endif
	}

	WifiAccessPoint.enable(false);
	WifiStation.config(WIFI_SSID, WIFI_PWD);
    WifiStation.enable(true);
	
    Serial.printf("\r\nCurrently running rom %d.\r\n", slot);
	Serial.println("Type 'help' and press enter for instructions.");
	Serial.println();
	Serial.commandProcessing(true);
    
    commandHandler.registerCommand(CommandDelegate("ip","show current ip address","user", cmdIP));
    commandHandler.registerCommand(CommandDelegate("ota","perform ota update, switch rom and reboot","user", cmdOTA));
    commandHandler.registerCommand(CommandDelegate("heap","display free heap","user", cmdAppHeap));
    commandHandler.registerCommand(CommandDelegate("ls","list files in spiffs","user", cmdLs));
    commandHandler.registerCommand(CommandDelegate("connect","connect to wifi","user", cmdConnect));
    commandHandler.registerCommand(CommandDelegate("disconnect","disconnect from wifi","user", cmdConnect));
    commandHandler.registerCommand(CommandDelegate("ap","create access point","user", cmdAP));
    
	//Serial.setCallback(serialCallBack);
    init_servos(); 
    WifiStation.waitConnection(startWebServer, 30, startAP);    
    
}
void init() {
	
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Debug output to serial
	
	// mount spiffs
	int slot = rboot_get_current_rom();
#ifndef DISABLE_SPIFFS
	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40300000, SPIFF_SIZE);
		spiffs_mount_manual(0x40300000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1 + 0x40200000, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x40500000, SPIFF_SIZE);
		spiffs_mount_manual(0x40500000, SPIFF_SIZE);
#endif
	}
#else
	debugf("spiffs disabled");
#endif
	WifiAccessPoint.enable(false);
	
	Serial.printf("\r\nCurrently running rom %d.\r\n", slot);
	Serial.println("Type 'help' and press enter for instructions.");
	Serial.println();
	
	Serial.setCallback(serialCallBack);
}
s32_t spiffs_mount()
{
  spiffs_mount_manual (spiffs_get_startaddress(), 0);
}
void init() {
	pinMode(PIN_BUTTON, INPUT);
	pinMode(PIN_GREEN, OUTPUT);
	pinMode(PIN_BLUE, OUTPUT);
	pinMode(PIN_RED, OUTPUT);
	digitalWrite(PIN_GREEN,0); //Green
	digitalWrite(PIN_BLUE,0); //Blue
	digitalWrite(PIN_RED,0); //Red

	indicationTimer.initializeMs(50, indicationFunction).start(); // every 20 seconds
	Serial.begin(SERIAL_BAUD_RATE); // 115200 by default
	Serial.systemDebugOutput(true); // Debug output to serial

	
	// mount spiffs
	int slot = rboot_get_current_rom();
#ifndef DISABLE_SPIFFS
	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 , SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x100000, SPIFF_SIZE);
		spiffs_mount_manual(0x100000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 , SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", SPIFF_SIZE);
		spiffs_mount_manual(0x300000, SPIFF_SIZE);
#endif
	}
#else
	debugf("spiffs disabled");
#endif
	AppSettings.load();

	WifiAccessPoint.enable(false);
	// connect to wifi
	WifiStation.config(WIFI_SSID, WIFI_PWD);
	WifiStation.enable(true);
	
	if (AppSettings.exist())
	{
		WifiStation.config(AppSettings.ssid, AppSettings.password);
		if (!AppSettings.dhcp && !AppSettings.ip.isNull())
			WifiStation.setIP(AppSettings.ip, AppSettings.netmask, AppSettings.gateway);
	}
	mqtt = new MqttClient(AppSettings.mqtt_server,AppSettings.mqtt_port, onMessageReceived);

	WifiStation.startScan(networkScanCompleted);

	// Start AP for configuration
	WifiAccessPoint.enable(true);
	WifiAccessPoint.config("Sming Configuration "+ WifiStation.getMAC(), "", AUTH_OPEN);

	// Run WEB server
	startWebServer();
	
	Serial.printf("\r\nCurrently running rom %d.\r\n", slot);
	Serial.println("Type 'help' and press enter for instructions.");
	Serial.println();
	
	Serial.setCallback(serialCallBack);
	// Run our method when station was connected to AP (or not connected)
	WifiStation.waitConnection(connectOk, 20, connectFail); // We recommend 20+ seconds for connection timeout at start
}
Exemple #7
0
void init() {
//ets_wdt_disable();
	Serial.begin(115200);
	WifiStation.enable(false);
	System.setCpuFrequency(eCF_160MHz);
	//Serial.systemDebugOutput(true);
	Serial.println("************************");
	Serial.println("***** Init running *****");
	Serial.println("************************");

// mount spiffs

	int slot = rboot_get_current_rom();
#ifndef DISABLE_SPIFFS
	if (slot == 0) {
#ifdef RBOOT_SPIFFS_0
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_0 , SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_0, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", 0x100000, SPIFF_SIZE);
		spiffs_mount_manual(0x100000, SPIFF_SIZE);
#endif
	} else {
#ifdef RBOOT_SPIFFS_1
		debugf("trying to mount spiffs at %x, length %d", RBOOT_SPIFFS_1 , SPIFF_SIZE);
		spiffs_mount_manual(RBOOT_SPIFFS_1, SPIFF_SIZE);
#else
		debugf("trying to mount spiffs at %x, length %d", SPIFF_SIZE);
		spiffs_mount_manual(0x300000, SPIFF_SIZE);
#endif
	}
#else
	debugf("spiffs disabled");
#endif


	//wifi_sid.add("linksys");
	//wifi_pass.add("Doitman1");
	wifi_sid.add("Sintex");
	wifi_pass.add("sintex92");
	wifi_sid.add("AsusKZ");
	wifi_pass.add("Doitman1");
	//wifi_sid.add("AndroidAp");
	//wifi_pass.add("Doitman1");

	WifiStation.config(wifi_sid.get(currWifiIndex), wifi_pass.get(currWifiIndex));
	WifiAccessPoint.enable(false);
	WifiStation.enable(true);


	procTimer.initializeMs(20000, checkConnection).start();

	WifiEvents.onStationGotIP(connectOk);

	//WifiStation.waitConnection(connectOk, 10, connectNotOk);

	/*


	 //wifi_set_opmode (STATION_MODE);
	 WifiAccessPoint.enable(false);

	 wifi_sid.add("AndroidAp");
	 wifi_pass.add("Doitman1");

	 //WifiStation.config(wifi_sid.get(currWifiIndex) , wifi_pass.get(currWifiIndex));
	 WifiStation.config(wifi_sid.get(currWifiIndex), wifi_pass.get(currWifiIndex));

	 WifiEvents.onStationDisconnect(STADisconnect);

	 checkConnection();
	 //WifiStation.connect();
	 //WifiStation.waitConnection(connectOk, 20, connectNotOk);

	 //pinMode(LED_PIN, OUTPUT);
	 procTimer.initializeMs(1000, blink).start();
	 */
}