send initial wifi state to MCU

pull/37/head
Thorsten von Eicken 9 years ago
parent ddd2af1a65
commit a2b5f94e14
  1. 2
      cmd/cmd.c
  2. 4
      cmd/handlers.c
  3. 1
      user/cgiwifi.h

@ -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 {

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

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

Loading…
Cancel
Save