// Lua: dsleep( us, option ) static int node_deepsleep( lua_State* L ) { s32 us, option; //us = luaL_checkinteger( L, 1 ); // Set deleep option, skip if nil if ( lua_isnumber(L, 2) ) { option = lua_tointeger(L, 2); if ( option < 0 || option > 4) return luaL_error( L, "wrong arg range" ); else deep_sleep_set_option( option ); } // Set deleep time, skip if nil if ( lua_isnumber(L, 1) ) { us = lua_tointeger(L, 1); // if ( us <= 0 ) if ( us < 0 ) return luaL_error( L, "wrong arg range" ); else system_deep_sleep( us ); } return 0; }
void wifi_callback( System_Event_t *evt ) { os_printf( "%s: %d\n", __FUNCTION__, evt->event ); char toto[7] = "hello\n\0"; //uart0_tx_buffer(toto, 7); switch ( evt->event ) { case EVENT_STAMODE_CONNECTED: { char toto[7] = "hello\n\0"; //uart0_tx_buffer(toto, 7); os_printf("connect to ssid %s, channel %d\n", evt->event_info.connected.ssid, evt->event_info.connected.channel); break; } case EVENT_STAMODE_DISCONNECTED: { os_printf("disconnect from ssid %s, reason %d\n", evt->event_info.disconnected.ssid, evt->event_info.disconnected.reason); deep_sleep_set_option( 0 ); system_deep_sleep( 60 * 1000 * 1000 ); // 60 seconds break; } case EVENT_STAMODE_GOT_IP: { os_printf("ip:" IPSTR ",mask:" IPSTR ",gw:" IPSTR, IP2STR(&evt->event_info.got_ip.ip), IP2STR(&evt->event_info.got_ip.mask), IP2STR(&evt->event_info.got_ip.gw)); os_printf("\n"); break; } default: { break; } } }