diff --git a/embedded8266/common/commonservices.c b/embedded8266/common/commonservices.c index de80267..3e8aa62 100644 --- a/embedded8266/common/commonservices.c +++ b/embedded8266/common/commonservices.c @@ -316,6 +316,7 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata, else { struct station_config sc; + ets_memset( &sc, 0, sizeof( sc ) ); wifi_station_get_config( &sc ); if( sc.bssid_set ) ets_sprintf( macmap, MACSTR, MAC2STR( sc.bssid ) ); @@ -326,8 +327,18 @@ int ICACHE_FLASH_ATTR issue_command(char * buffer, int retsize, char *pusrdata, } break; case 'X': case 'x': - buffend += ets_sprintf( buffend, "WX%d", wifi_station_get_rssi() ); + { + int rssi = wifi_station_get_rssi(); + if( rssi >= 0 ) + { + buffend += ets_sprintf( buffend, "WX-" ); + } + else + { + buffend += ets_sprintf( buffend, "WX%d", wifi_station_get_rssi() ); + } break; + } case 'S': case 's': { int i, r; @@ -449,6 +460,33 @@ void ICACHE_FLASH_ATTR issue_command_udp(void *arg, char *pusrdata, unsigned sho } } +void ICACHE_FLASH_ATTR CSPreInit() +{ + int opmode = wifi_get_opmode(); + printf( "Opmode: %d\n", opmode ); + if( opmode == 1 ) + { + struct station_config sc; + wifi_station_get_config(&sc); + printf( "Station mode: \"%s\":\"%s\" (bssid_set:%d)\n", sc.ssid, sc.password, sc.bssid_set ); + if( sc.ssid[0] == 0 && !sc.bssid_set ) + { + wifi_set_opmode( 2 ); + opmode = 2; + } + else + { + wifi_station_connect(); + } + } + if( opmode == 2 ) + { + struct softap_config sc; + wifi_softap_get_config(&sc); + printf( "SoftAP mode: \"%s\":\"%s\"\n", sc.ssid, sc.password ); + } +} + void ICACHE_FLASH_ATTR CSInit() { pUdpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); diff --git a/embedded8266/common/commonservices.h b/embedded8266/common/commonservices.h index 3a31a7e..298aa06 100644 --- a/embedded8266/common/commonservices.h +++ b/embedded8266/common/commonservices.h @@ -12,6 +12,7 @@ int ICACHE_FLASH_ATTR issue_command(char * retdata, int retsize, char *pusrdata, unsigned short len); //Includes UDP Control + HTTP Interfaces +void ICACHE_FLASH_ATTR CSPreInit(); void ICACHE_FLASH_ATTR CSInit(); void ICACHE_FLASH_ATTR CSTick( int slowtick ); diff --git a/embedded8266/image.elf b/embedded8266/image.elf index 4bf4060..9d72368 100755 Binary files a/embedded8266/image.elf and b/embedded8266/image.elf differ diff --git a/embedded8266/user/user_main.c b/embedded8266/user/user_main.c index 80e3f04..b04fa21 100644 --- a/embedded8266/user/user_main.c +++ b/embedded8266/user/user_main.c @@ -178,47 +178,16 @@ void ICACHE_FLASH_ATTR user_init(void) uart0_sendStr("\r\nCustom Server\r\n"); +//Uncomment this to force a system restore. // system_restore(); + CustomStart(); #ifdef PROFILE GPIO_OUTPUT_SET(GPIO_ID_PIN(0), 0); #endif - int opmode = wifi_get_opmode(); - printf( "Opmode: %d\n", opmode ); - if( opmode == 1 ) - { - struct station_config sc; - wifi_station_get_config(&sc); - printf( "Station mode: \"%s\":\"%s\" (bssid_set:%d)\n", sc.ssid, sc.password, sc.bssid_set ); - if( sc.ssid[0] == 0 && !sc.bssid_set ) - { - wifi_set_opmode( 2 ); - opmode = 2; - } - else - { - wifi_station_connect(); - } - } - if( opmode == 2 ) - { - struct softap_config sc; - wifi_softap_get_config(&sc); - printf( "SoftAP mode: \"%s\":\"%s\"\n", sc.ssid, sc.password ); - } -// wifi_set_opmode( 2 ); //We broadcast our ESSID, wait for peopel to join. - -/* - struct station_config stationConf; - wifi_set_opmode( 1 ); //We broadcast our ESSID, wait for peopel to join. - os_memcpy(&stationConf.ssid, "xxx", ets_strlen( "xxx" ) + 1); - os_memcpy(&stationConf.password, "yyy", ets_strlen( "yyy" ) + 1); - - wifi_set_opmode( 1 ); - wifi_station_set_config(&stationConf); - wifi_station_connect();**/ + CSPreInit(); pUdpServer = (struct espconn *)os_zalloc(sizeof(struct espconn)); ets_memset( pUdpServer, 0, sizeof( struct espconn ) ); @@ -228,8 +197,6 @@ void ICACHE_FLASH_ATTR user_init(void) pUdpServer->proto.udp->local_port = 7777; espconn_regist_recvcb(pUdpServer, udpserver_recv); -/* wifi_station_dhcpc_start(); -*/ if( espconn_create( pUdpServer ) ) { while(1) { uart0_sendStr( "\r\nFAULT\r\n" ); } diff --git a/embedded8266/web/page/index.html b/embedded8266/web/page/index.html index 0f79da4..567515c 100644 --- a/embedded8266/web/page/index.html +++ b/embedded8266/web/page/index.html @@ -39,7 +39,7 @@ td { vertical-align: top; }
Current Configuration: (May deviate from default configuration, reset here if in doubt) |