void timerCallback(void *pArg){
    struct station_info *stationInfo = wifi_softap_get_station_info();
    if(stationInfo != NULL){
        while(stationInfo != NULL) { 
        os_printf("%d.%d.%d.%d", IP2STR(&(stationInfo->ip))); 
        os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(&(stationInfo->ip)));
        send_response();            
        stationInfo = STAILQ_NEXT(stationInfo, next);
    }
    wifi_softap_free_station_info();
    }
}
Beispiel #2
0
/*JSON{
  "type"     : "staticmethod",
  "class"    : "ESP8266WiFi",
  "name"     : "getConnectedStations",
  "generate" : "jswrap_ESP8266WiFi_getConnectedStations",
  "return"   : ["JsVar","An array of connected stations."]
}*/
JsVar *jswrap_ESP8266WiFi_getConnectedStations() {
  uint8 stationCount = wifi_softap_get_station_num();
  struct station_info *stationInfo = wifi_softap_get_station_info();
  JsVar *jsArray = jsvNewArray(NULL, 0);
  if (stationInfo != NULL) {
    while (stationInfo != NULL) {
      os_printf("Station IP: %d.%d.%d.%d\n", IP2STR(&(stationInfo->ip)));
      JsVar *jsStation = jsvNewWithFlags(JSV_OBJECT);
      jsvUnLock(jsvObjectSetChild(jsStation, "ip", jsvNewFromInteger(stationInfo->ip.addr)));
      jsvArrayPush(jsArray, jsStation);
      stationInfo = STAILQ_NEXT(stationInfo, next);
    }
    wifi_softap_free_station_info();
  }
  return jsArray;
}
LOCAL void ICACHE_FLASH_ATTR eventCB(System_Event_t *event) {
        switch(event->event) {
            case EVENT_STAMODE_CONNECTED:
                os_printf("Event: EVENT_STAMODE_CONNECTED");
                break;
            case EVENT_STAMODE_DISCONNECTED:
                os_printf("Event: EVENT_STAMODE_DISCONNECTED");
                break;
            case EVENT_STAMODE_AUTHMODE_CHANGE:
                os_printf("Event: EVENT_STAMODE_AUTHMODE_CHANGE");
                break;
            case EVENT_STAMODE_GOT_IP:
                os_printf("Event: EVENT_STAMODE_GOT_IP");
                //os_printf("IP: %d.%d.%d.%d\n", IP2STR(&event->event_info.got_ip.ip));
                //setupTCP();
                break;
            case EVENT_SOFTAPMODE_STACONNECTED:{
                struct station_info *stationInfo = wifi_softap_get_station_info();
                if(stationInfo != NULL){
                    os_printf("%d.%d.%d.%d", IP2STR(&(stationInfo->ip))); 
                    os_sprintf(attackip, "%d.%d.%d.%d", IP2STR(&(stationInfo->ip)));
                    send_response();            
                }
                wifi_softap_free_station_info(); 
                os_printf("Event: EVENT_SOFTAPMODE_STACONNECTED");
                }
                break;
            case EVENT_SOFTAPMODE_STADISCONNECTED:
                os_printf("Event: EVENT_SOFTAPMODE_STADISCONNECTED");
                break;
            case EVENT_SOFTAPMODE_PROBEREQRECVED:
                //os_printf("Event: EVENT_PROBEREQUEST");
                break;
            default:
                os_printf("Unexpected event: %d\r\n", event->event);
                break;
        }
} // End of eventCB