mirror of
https://github.com/cesanta/mongoose.git
synced 2026-10-14 10:20:01 +00:00
rename ifp state change event
This commit is contained in:
1 parent
0ecbb62630
commit
c62f8b4e93
17 files changed
+73
-75
No files matched your search
@@ -27,12 +27,12 @@ static unsigned int state;
|
||||
|
||||
static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
// TODO(): should we include this inside ifp ? add an fn_data ?
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
}
|
||||
switch(state) {
|
||||
case AP: // we are in AP mode, wait for a user connection to trigger a scan or a connection to a network
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("Access Point READY !"));
|
||||
|
||||
// simulate user request to scan for networks
|
||||
@@ -57,7 +57,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case STOPPING_AP:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
|
||||
wifi->apmode = false;
|
||||
|
||||
@@ -70,7 +70,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("READY!"));
|
||||
state = READY;
|
||||
|
||||
@@ -84,7 +84,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
break;
|
||||
case READY:
|
||||
// go back to AP mode after a disconnection (simulation 2/2), you could retry
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
|
||||
bool res = mg_wifi_ap_start(wifi);
|
||||
MG_INFO(("Disconnected"));
|
||||
|
||||
@@ -183,13 +183,13 @@ static unsigned int state;
|
||||
|
||||
static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
// TODO(): should we include this inside ifp ? add an fn_data ?
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
}
|
||||
switch (state) {
|
||||
case AP: // we are in AP mode, wait for a user connection to trigger a scan
|
||||
// or a connection to a network
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("Access Point READY !"));
|
||||
|
||||
@@ -219,7 +219,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case STOPPING_AP:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
@@ -234,7 +234,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("READY!"));
|
||||
state = READY;
|
||||
@@ -251,7 +251,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
case READY:
|
||||
// go back to AP mode after a disconnection (simulation 2/2), you could
|
||||
// retry
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
|
||||
@@ -17,13 +17,13 @@ static unsigned int state;
|
||||
|
||||
static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
// TODO(): should we include this inside ifp ? add an fn_data ?
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
}
|
||||
switch (state) {
|
||||
case AP: // we are in AP mode, wait for a user connection to trigger a scan
|
||||
// or a connection to a network
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("Access Point READY !"));
|
||||
|
||||
@@ -53,7 +53,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case STOPPING_AP:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_pico_w_data *) ifp->driver_data)->wifi;
|
||||
@@ -68,7 +68,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("READY!"));
|
||||
state = READY;
|
||||
@@ -85,7 +85,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
case READY:
|
||||
// go back to AP mode after a disconnection (simulation 2/2), you could
|
||||
// retry
|
||||
if (ev == MG_TCPIP_EV_ST_CHG &&
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE &&
|
||||
*(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi =
|
||||
&((struct mg_tcpip_driver_pico_w_data *) ifp->driver_data)->wifi;
|
||||
|
||||
@@ -89,12 +89,12 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
if (ev == MG_TCPIP_EV_DRIVER) {
|
||||
spi_setup(CYWSPI, 3); // /16: 2.8MHz SPI3, 5.6MHz SPI1 (< 50MHz)
|
||||
}
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
}
|
||||
switch(state) {
|
||||
case AP: // we are in AP mode, wait for a user connection to trigger a scan or a connection to a network
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("Access Point READY !"));
|
||||
|
||||
// simulate user request to scan for networks
|
||||
@@ -119,7 +119,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case STOPPING_AP:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
wifi->apmode = false;
|
||||
|
||||
@@ -132,7 +132,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("READY!"));
|
||||
state = READY;
|
||||
|
||||
@@ -146,7 +146,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
break;
|
||||
case READY:
|
||||
// go back to AP mode after a disconnection (simulation 2/2), you could retry
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
bool res = mg_wifi_ap_start(wifi);
|
||||
MG_INFO(("Disconnected"));
|
||||
|
||||
@@ -89,12 +89,12 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
if (ev == MG_TCPIP_EV_DRIVER) {
|
||||
spi_setup(CYWSPI, 3); // /16: 3.4MHz SPI3, 6.75MHz SPI1 (< 50MHz)
|
||||
}
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
}
|
||||
switch(state) {
|
||||
case AP: // we are in AP mode, wait for a user connection to trigger a scan or a connection to a network
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("Access Point READY !"));
|
||||
|
||||
// simulate user request to scan for networks
|
||||
@@ -119,7 +119,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case STOPPING_AP:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
wifi->apmode = false;
|
||||
|
||||
@@ -132,7 +132,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
}
|
||||
break;
|
||||
case CONNECTING:
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_READY) {
|
||||
MG_INFO(("READY!"));
|
||||
state = READY;
|
||||
|
||||
@@ -146,7 +146,7 @@ static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
break;
|
||||
case READY:
|
||||
// go back to AP mode after a disconnection (simulation 2/2), you could retry
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && *(uint8_t *) ev_data == MG_TCPIP_STATE_DOWN) {
|
||||
struct mg_wifi_data *wifi = &((struct mg_tcpip_driver_cyw_data *) ifp->driver_data)->wifi;
|
||||
bool res = mg_wifi_ap_start(wifi);
|
||||
MG_INFO(("Disconnected"));
|
||||
|
||||
@@ -171,7 +171,7 @@ static void mqtt_ev_handler(struct mg_connection *c, int ev, void *ev_data) {
|
||||
|
||||
static void if_ev_handler(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
// Trigger MQTT connection when we have an IP address
|
||||
if (ifp->state == MG_TCPIP_STATE_READY && ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ifp->state == MG_TCPIP_STATE_READY && ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
struct mg_mqtt_opts opts = {.clean = true};
|
||||
// mg_mqtt_connect(ifp->mgr, MQTT_URL, &opts, mqtt_ev_handler, NULL);
|
||||
mg_mqtt_connect(ifp->mgr, MQTTS_URL, &opts, mqtt_ev_handler, "tls enabled");
|
||||
@@ -185,7 +185,7 @@ static void if_ev_handler(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
if (ip == 0) ip = MG_IPV4(169, 254, 2, 100);
|
||||
|
||||
// restart process on link change
|
||||
if (ev == MG_TCPIP_EV_ST_CHG && ifp->state == MG_TCPIP_STATE_DOWN) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE && ifp->state == MG_TCPIP_STATE_DOWN) {
|
||||
ifp->ip = 0;
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ static size_t tap_rx(void *buf, size_t len, struct mg_tcpip_if *ifp) {
|
||||
char *s_sntp = NULL;
|
||||
|
||||
static void mif_fn(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
|
||||
if (ev == MG_TCPIP_EV_ST_CHG) {
|
||||
if (ev == MG_TCPIP_EV_STATE_CHANGE) {
|
||||
MG_INFO(("State change: %u", *(uint8_t *) ev_data));
|
||||
} else if (ev == MG_TCPIP_EV_DHCP_DNS) {
|
||||
MG_INFO(("Got DNS from DHCP: %M", mg_print_ip4, (uint32_t *) ev_data));
|
||||
|
||||
Reference in new issue
Block a user