Beispiel #1
0
void ICACHE_FLASH_ATTR AlarmTimer(void *arg) {
	AlarmCount++;
	ioLed(state);
	state = !state;
	if(AlarmCount > 10)
	{
		AlarmCount = 0;
		state = 1;
		ioLed(0);
		os_timer_disarm(&Alarmtimer);
	}
}
Beispiel #2
0
//Cgi that turns the LED on or off according to the 'led' param in the POST data
int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) {
	int len;
	char buff[1024];
	
	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	len=httpdFindArg(connData->post->buff, "switch", buff, sizeof(buff));
	if (len!=0) {
		int 	bValue = 0;

		bValue = atoi(buff);
		if (1 == bValue){
#ifdef CGI_DEBUG
	os_printf("cgiLed: completed request\n");
#endif

			currLedState ^= 1;
#ifdef CGI_DEBUG
	os_printf("cgiLed: currLedState = %d\n",currLedState);
#endif
			ioLed(currLedState);
		}
	}

	httpdRedirect(connData, "index.tpl");
	return HTTPD_CGI_DONE;
}
Beispiel #3
0
// ----------------------------------------------------------------------------
// Commander functions:
// ----------------------------------------------------------------------------
static void command(char cmd)
{
    switch(cmd) {
        case 'l': ioLed(2);                     break;  // Turn test LED off
        case 'm': scanLED(0);                   break;  // Turn Motor off
        case 'M': scanLED(1);                   break;  // Turn Motor on
        case 'h': menu();                       break;  // show menu
        case 'd': disconnect();                 break;  // disconnect station
        case 'c': connect_st_mode();            break;  // connect
        case 'i': wifi_check_ip(NULL);          break;  // Test for IP and send
        case 'u': create_udp();                 break;  // send test message
        case 's': send_msg();                   break;  // send test message
        case 'w': wifiStartScan();              break;  // Scan for AP's
        case 'a': logwifiaps();                 break;  // Scan for AP's and log via UDP
        default:                                break;
    }
}
//Cgi that turns the LED on or off according to the 'led' param in the POST data
int ICACHE_FLASH_ATTR cgiLed(HttpdConnData *connData) {
	int len;
	char buff[1024];
	
	if (connData->conn==NULL) {
		//Connection aborted. Clean up.
		return HTTPD_CGI_DONE;
	}

	len=httpdFindArg(connData->post->buff, "led", buff, sizeof(buff));
	if (len!=0) {
		currLedState = strcmp("Off", buff);
		ioLed(currLedState);
	}

	httpdRedirect(connData, "led.tpl");
	return HTTPD_CGI_DONE;
}