@@ -20196,7 +20196,8 @@ void mg_free(void *ptr) {
20196
20196
20197
20197
#if (!defined(MG_ENABLE_DRIVER_PICO_W) || !MG_ENABLE_DRIVER_PICO_W) && \
20198
20198
(!defined(MG_ENABLE_DRIVER_CYW) || !MG_ENABLE_DRIVER_CYW) && \
20199
- (!defined(MG_ENABLE_DRIVER_CYW_SDIO) || !MG_ENABLE_DRIVER_CYW_SDIO)
20199
+ (!defined(MG_ENABLE_DRIVER_CYW_SDIO) || !MG_ENABLE_DRIVER_CYW_SDIO) && \
20200
+ (!defined(MG_ENABLE_DRIVER_NXP_WIFI) || !MG_ENABLE_DRIVER_NXP_WIFI)
20200
20201
20201
20202
20202
20203
bool mg_wifi_scan(void) {
@@ -22297,6 +22298,101 @@ struct mg_tcpip_driver mg_tcpip_driver_imxrt = {mg_tcpip_driver_imxrt_init,
22297
22298
22298
22299
#endif
22299
22300
22301
+ #ifdef MG_ENABLE_LINES
22302
+ #line 1 "src/drivers/nxp_wifi.c"
22303
+ #endif
22304
+ #if MG_ENABLE_TCPIP && defined(MG_ENABLE_DRIVER_NXP_WIFI) && \
22305
+ MG_ENABLE_DRIVER_NXP_WIFI
22306
+
22307
+
22308
+
22309
+ bool __attribute__((weak)) netif_init(struct mg_tcpip_if *ifp) {
22310
+ (void) ifp;
22311
+ MG_ERROR(("Please link wifi/net/port/ contents"));
22312
+ return false;
22313
+ }
22314
+ size_t __attribute__((weak))
22315
+ netif_tx(const void *bfr, size_t len, struct mg_tcpip_if *ifp) {
22316
+ (void) bfr;
22317
+ (void) len;
22318
+ netif_init(ifp);
22319
+ return 0;
22320
+ }
22321
+ bool __attribute__((weak)) netif_connect(struct mg_wifi_data *wifi) {
22322
+ (void) wifi;
22323
+ return netif_init(NULL);
22324
+ }
22325
+ bool __attribute__((weak))
22326
+ netif_poll(struct mg_tcpip_if *ifp, bool s1, mg_tcpip_event_handler_t evcb) {
22327
+ (void) ifp;
22328
+ (void) s1;
22329
+ (void) evcb;
22330
+ return false;
22331
+ }
22332
+
22333
+ static struct mg_tcpip_if *s_ifp;
22334
+ static uint32_t s_ip, s_mask;
22335
+
22336
+ static void wifi_cb(struct mg_tcpip_if *ifp, int ev, void *ev_data) {
22337
+ struct mg_wifi_data *wifi =
22338
+ &((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
22339
+ if (wifi->apmode && ev == MG_TCPIP_EV_ST_CHG &&
22340
+ *(uint8_t *) ev_data == MG_TCPIP_STATE_UP) {
22341
+ MG_DEBUG(("Access Point started"));
22342
+ s_ip = ifp->ip, ifp->ip = wifi->apip;
22343
+ s_mask = ifp->mask, ifp->mask = wifi->apmask;
22344
+ ifp->enable_dhcp_client = false;
22345
+ ifp->enable_dhcp_server = true;
22346
+ }
22347
+ }
22348
+
22349
+ static bool nxp_wifi_init(struct mg_tcpip_if *ifp) {
22350
+ struct mg_wifi_data *wifi =
22351
+ &((struct mg_tcpip_driver_nxp_wifi_data *) ifp->driver_data)->wifi;
22352
+ s_ifp = ifp;
22353
+ s_ip = ifp->ip;
22354
+ s_mask = ifp->mask;
22355
+ ifp->pfn = wifi_cb;
22356
+ if (!netif_init(ifp)) return false;
22357
+ if (wifi->apmode) {
22358
+ return mg_wifi_ap_start(wifi);
22359
+ } else if (wifi->ssid != NULL && wifi->pass != NULL) {
22360
+ return mg_wifi_connect(wifi);
22361
+ }
22362
+ return true;
22363
+ }
22364
+
22365
+ bool nxp_wifi_poll(struct mg_tcpip_if *ifp, bool s1) {
22366
+ return netif_poll(ifp, s1, mg_tcpip_call);
22367
+ }
22368
+
22369
+ struct mg_tcpip_driver mg_tcpip_driver_nxp_wifi = {nxp_wifi_init, netif_tx,
22370
+ NULL, nxp_wifi_poll};
22371
+
22372
+ bool mg_wifi_connect(struct mg_wifi_data *wifi) {
22373
+ s_ifp->ip = s_ip;
22374
+ s_ifp->mask = s_mask;
22375
+ if (s_ifp->ip == 0) s_ifp->enable_dhcp_client = true;
22376
+ s_ifp->enable_dhcp_server = false;
22377
+ return netif_connect(wifi);
22378
+ }
22379
+
22380
+ bool __attribute__((weak)) mg_wifi_scan(void) {
22381
+ return netif_init(NULL);
22382
+ }
22383
+ bool __attribute__((weak)) mg_wifi_disconnect(void) {
22384
+ return netif_init(NULL);
22385
+ }
22386
+ bool __attribute__((weak)) mg_wifi_ap_start(struct mg_wifi_data *wifi) {
22387
+ (void) wifi;
22388
+ return netif_init(NULL);
22389
+ }
22390
+ bool __attribute__((weak)) mg_wifi_ap_stop(void) {
22391
+ return netif_init(NULL);
22392
+ }
22393
+
22394
+ #endif
22395
+
22300
22396
#ifdef MG_ENABLE_LINES
22301
22397
#line 1 "src/drivers/phy.c"
22302
22398
#endif
0 commit comments