diff --git a/cmd/cmd.c b/cmd/cmd.c index 06430ca..64aeef7 100644 --- a/cmd/cmd.c +++ b/cmd/cmd.c @@ -88,7 +88,7 @@ CMD_Exec(const CmdList *scp, CmdPacket *packet) { uint32_t ret = scp->sc_function(packet); // if requestor asked for a response, send it if (packet->_return){ - os_printf("CMD: Response: %lu, cmd: %d\r\n", ret, packet->cmd); + os_printf("CMD: Response: 0x%lx, cmd: %d\r\n", ret, packet->cmd); crc = CMD_ResponseStart(packet->cmd, 0, ret, 0); CMD_ResponseEnd(crc); } else { diff --git a/cmd/handlers.c b/cmd/handlers.c index 73370dd..396a43e 100644 --- a/cmd/handlers.c +++ b/cmd/handlers.c @@ -70,10 +70,14 @@ CMD_WifiCb(uint8_t wifiStatus) { // Command handler for Wifi connect command static uint32_t ICACHE_FLASH_ATTR CMD_WifiConnect(CmdPacket *cmd) { + os_printf("CMD: Wifi connect\n"); if(cmd->argc != 2 || cmd->callback == 0) return 0xFFFFFFFF; wifiStatusCb = CMD_WifiCb; // register our callback with wifi subsystem wifiCallback = cmd->callback; // save the MCU's callback + // trigger an immediate callback with the current status + lastWifiStatus = 0xff; + CMD_WifiCb(wifiState); return 1; } diff --git a/user/cgiwifi.h b/user/cgiwifi.h index c78a793..d73628e 100644 --- a/user/cgiwifi.h +++ b/user/cgiwifi.h @@ -14,6 +14,7 @@ int cgiWiFiConnStatus(HttpdConnData *connData); int cgiWiFiSpecial(HttpdConnData *connData); void wifiInit(void); +extern uint8_t wifiState; extern void (*wifiStatusCb)(uint8_t); // callback when wifi status changes #endif