add better control for disabling flags on the screen for esp8266 wifi configuration

This commit is contained in:
cnlohr 2015-08-07 01:34:28 -04:00
parent 577a0e2d36
commit f844317327
7 changed files with 66 additions and 40 deletions

View file

@ -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));

View file

@ -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 );

Binary file not shown.

View file

@ -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" ); }

View file

@ -39,7 +39,7 @@ td { vertical-align: top; }
<table width=100% border=1><tr><td>
Current Configuration: (May deviate from default configuration, reset here if in doubt)<form name="wifisection" action="javascript:ChangeWifiConfig();">
<table border=1 width=1%>
<tr><td width=1>Type:</td><td><input type="radio" name="wifitype" value=1>Station (Connect to infrastructure)<br><input type="radio" name="wifitype" value=2 onclick="document.wifisection.wificurname.value = 'ESP'">AP (Broadcast a new AP)</td></tr>
<tr><td width=1>Type:</td><td><input type="radio" name="wifitype" value=1 onclick="ClickOpmode(1);">Station (Connect to infrastructure)<br><input type="radio" name="wifitype" value=2 onclick="ClickOpmode(2);">AP (Broadcast a new AP)</td></tr>
<tr><td>SSID:</td><td><input type="text" id="wificurname"></td></tr>
<tr><td>PASS:</td><td><input type="text" id="wificurpassword"></td></tr>
<tr><td>MAC:</td><td><input type="text" id="wifimac"> (Ignored in softAP mode)</td></tr>

View file

@ -605,9 +605,29 @@ function BSSIDClick( i )
document.wifisection.wifimac.value = tlines[1];
document.wifisection.wificurchannel.value = 0;
ClickOpmode( 1 );
return false;
}
function ClickOpmode( i )
{
if( i == 1 )
{
document.wifisection.wificurname.disabled = false;
document.wifisection.wificurpassword.disabled = false;
document.wifisection.wifimac.disabled = false;
document.wifisection.wificurchannel.disabled = true;
}
else
{
document.wifisection.wificurname.disabled = false;
document.wifisection.wificurpassword.disabled = true;
document.wifisection.wificurpassword.value = "";
document.wifisection.wifimac.disabled = true;
document.wifisection.wificurchannel.disabled = false;
}
}
function WifiDataTicker()
{
if( IsTabOpen('WifiSettings') )

View file

@ -2,8 +2,8 @@
#define _CCCONFIG_H
#define CCEMBEDDED
#define NUM_LIN_LEDS 217
#define USE_NUM_LIN_LEDS 217
#define NUM_LIN_LEDS 24
#define USE_NUM_LIN_LEDS 24
#define DFREQ 12000
#endif