wifi control & reporting sbmp backend; added small libs to fit in the flash size

Former-commit-id: ae5cdcd16db7d06f1afde24b4c1da78904053781
master
Ondřej Hruška 9 years ago
parent 8bf9045031
commit 78e0569f87
  1. 7
      Makefile
  2. BIN
      esp_iot_sdk_v1.5.2/lib/libmgcc.a
  3. BIN
      esp_iot_sdk_v1.5.2/lib/libmlwip.a
  4. BIN
      esp_iot_sdk_v1.5.2/lib/libmmain.a
  5. BIN
      esp_iot_sdk_v1.5.2/lib/libmphy.a
  6. BIN
      esp_iot_sdk_v1.5.2/lib/libmwpa.a
  7. 6
      esp_meas.pro
  8. 1388
      html_src/css/app.css
  9. 9619
      html_src/js/all.js
  10. 14
      user/datalink.c
  11. 11
      user/datalink.h
  12. 18
      user/user_main.c
  13. 107
      user/wificontrol.c
  14. 13
      user/wificontrol.h

@ -59,7 +59,12 @@ MODULES = user sbmp/library esphttpclient
EXTRA_INCDIR = include libesphttpd/include sbmp/library user esphttpclient EXTRA_INCDIR = include libesphttpd/include sbmp/library user esphttpclient
# libraries used in this project, mainly provided by the SDK # libraries used in this project, mainly provided by the SDK
LIBS = c gcc hal phy pp net80211 wpa main lwip crypto LIBS = c mgcc mphy pp net80211 wpa main lwip wps
# mwpa causes compile errors with wps
# mmain causes undefined symbol call_user_start (not worth the trouble - uses some kind of custom app_main.c)
#LIBS = c gcc hal phy pp net80211 wpa main lwip wps
#ssl #ssl
#Add in esphttpd lib #Add in esphttpd lib

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

@ -68,7 +68,8 @@ SOURCES += \
esphttpclient/test/httpclient_test.c \ esphttpclient/test/httpclient_test.c \
esphttpclient/httpclient.c \ esphttpclient/httpclient.c \
user/page_monitoring.c \ user/page_monitoring.c \
user/reporting.c user/reporting.c \
user/wificontrol.c
HEADERS += \ HEADERS += \
include/uart_hw.h \ include/uart_hw.h \
@ -158,7 +159,8 @@ HEADERS += \
esphttpclient/espmissingincludes.h \ esphttpclient/espmissingincludes.h \
esphttpclient/httpclient.h \ esphttpclient/httpclient.h \
user/page_monitoring.h \ user/page_monitoring.h \
user/reporting.h user/reporting.h \
user/wificontrol.h
DISTFILES += \ DISTFILES += \
style.astylerc \ style.astylerc \

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1,5 +1,6 @@
#include "uart_driver.h" #include "uart_driver.h"
#include "datalink.h" #include "datalink.h"
#include "wificontrol.h"
// payload rx buffer // payload rx buffer
#define PAYLOAD_BUFFER_LEN (256+3) #define PAYLOAD_BUFFER_LEN (256+3)
@ -15,13 +16,22 @@ static void FLASH_FN u0_putc(uint8_t c)
} }
/** Handle incoming datagram (new session) */
static void FLASH_FN dg_handler(SBMP_Datagram *dg) static void FLASH_FN dg_handler(SBMP_Datagram *dg)
{ {
dbg("[SBMP] Datagram received, type %d, session %d", dg->type, dg->session); switch (dg->type) {
case DG_SETMODE_AP:
wificontrol_setmode_ap();
break;
case DG_WPS_START:
wificontrol_start_wps();
break;
}
} }
/** This is called by the UART rx handler */ /** This is called by the UART rx handler */
void datalink_receive(uint8_t byte) void FLASH_FN datalink_receive(uint8_t byte)
{ {
sbmp_ep_receive(dlnk_ep, byte); sbmp_ep_receive(dlnk_ep, byte);
} }

@ -7,10 +7,13 @@
// request to capture data... // request to capture data...
#define DG_REQUEST_RAW 40 #define DG_REQUEST_RAW 40
#define DG_REQUEST_FFT 41 #define DG_REQUEST_FFT 41
// reporting helpers // reporting
#define DG_REQUEST_STORE_REF 42 #define DG_REQUEST_STORE_REF 42 // request to capture & store reference FFT
#define DG_REQUEST_COMPARE_REF 43 #define DG_REQUEST_COMPARE_REF 43 // request to capture FFT & compare with reference
// wifi status & control
#define DG_SETMODE_AP 44 // request AP mode (AP button pressed)
#define DG_WPS_START 45 // start WPS
#define DG_WIFI_STATUS 46 // WiFi status report
extern SBMP_Endpoint *dlnk_ep; extern SBMP_Endpoint *dlnk_ep;

@ -24,6 +24,7 @@
#include "fw_version.h" #include "fw_version.h"
#include "reporting.h" #include "reporting.h"
#include "wificontrol.h"
extern HttpdBuiltInUrl builtInUrls[]; extern HttpdBuiltInUrl builtInUrls[];
@ -119,7 +120,24 @@ void user_init(void)
info("Ready"); info("Ready");
printf(LOG_EOL); printf(LOG_EOL);
wificontrol_init();
os_timer_disarm(&prSecondTimer); os_timer_disarm(&prSecondTimer);
os_timer_setfn(&prSecondTimer, prSecondTimerCb, NULL); os_timer_setfn(&prSecondTimer, prSecondTimerCb, NULL);
os_timer_arm(&prSecondTimer, 1000, 1); os_timer_arm(&prSecondTimer, 1000, 1);
} }
// ---- unused funcs removed from sdk to save space ---
// вызывается из phy_chip_v6.o
void ICACHE_FLASH_ATTR chip_v6_set_sense(void)
{
// ret.n
}
// вызывается из phy_chip_v6.o
int ICACHE_FLASH_ATTR chip_v6_unset_chanfreq(void)
{
return 0;
}

@ -0,0 +1,107 @@
#include <esp8266.h>
#include <httpd.h>
#include "wificontrol.h"
#include <sbmp.h>
#include "datalink.h"
#include "reporting.h"
// --- AP ---
void FLASH_FN wificontrol_setmode_ap(void)
{
wifi_station_disconnect(); // disconnect
wifi_set_opmode(SOFTAP_MODE); // enter AP mode
warn("SBMP request to switch to SoftAP mode. Restarting...\n");
system_restart(); // TODO check if restart is needed
}
// --- WPS ---
static bool wps_in_progress = false;
static ETSTimer wps_abort_timer;
/** Timer CB - abort WPS */
static void FLASH_FN abort_wps_cb(void *arg)
{
(void)arg;
error("WPS timeout, stopped.");
wifi_wps_disable();
wps_in_progress = false;
}
static void FLASH_FN my_wps_cb(int status)
{
dbg("WPS callback!");
wps_in_progress = false;
switch (status) {
case WPS_CB_ST_SUCCESS:
info("WPS success!");
wifi_wps_disable();
wifi_station_connect();
break;
default:
error("WPS failed.");
break;
}
// TODO send status update to STM32
}
void FLASH_FN wificontrol_start_wps(void)
{
info("Starting WPS...");
// Make sure station is enabled
if (wifi_get_opmode() == SOFTAP_MODE) {
wifi_set_opmode(STATIONAP_MODE);
}
// Disconnect if connected to any station
wifi_station_disconnect();
// enable WPS
wifi_set_wps_cb(my_wps_cb);
wifi_wps_enable(WPS_TYPE_PBC);
os_timer_disarm(&wps_abort_timer);
os_timer_setfn(&wps_abort_timer, abort_wps_cb, NULL);
os_timer_arm(&wps_abort_timer, 15000, false); // 15 seconds
wps_in_progress = true;
}
// --- Status update ---
static ETSTimer wifistatus_timer;
/** Send wifi status update */
static void FLASH_FN wifistatus_cb(void *arg)
{
(void)arg;
WIFI_MODE opmode = wifi_get_opmode();
STATION_STATUS status = STATION_IDLE;
if (opmode != SOFTAP_MODE) {
status = wifi_station_get_connect_status();
}
if (sbmp_ep_start_message(dlnk_ep, DG_WIFI_STATUS, 4, NULL)) {
sbmp_ep_send_u8(dlnk_ep, opmode); // 1-Client, 2-SoftAP, 3-STA+AP
sbmp_ep_send_u8(dlnk_ep, status == STATION_GOT_IP); // Station connected
sbmp_ep_send_u8(dlnk_ep, wps_in_progress); // 1 = WPS is in progress
sbmp_ep_send_u8(dlnk_ep, rpt_conf.enabled); // Reporting is enabled
}
}
void FLASH_FN wificontrol_init(void)
{
os_timer_disarm(&wifistatus_timer);
os_timer_setfn(&wifistatus_timer, wifistatus_cb, NULL);
os_timer_arm(&wifistatus_timer, 1000, true);
}

@ -0,0 +1,13 @@
#ifndef WIFICONTROL_H
#define WIFICONTROL_H
#include <esp8266.h>
#include <httpd.h>
void wificontrol_setmode_ap(void);
void wificontrol_start_wps(void);
void wificontrol_init(void);
#endif // WIFICONTROL_H
Loading…
Cancel
Save