blob: 0aaeb556577c7f01c596e4c6722f0691e08425ec [file] [log] [blame]
Paul Sokolovskyee3fec32015-06-12 17:16:52 +03001/*
2 * This file is part of the Micro Python project, http://micropython.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2015 Paul Sokolovsky
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26
27#include <stdio.h>
28#include <stdint.h>
29#include <string.h>
30#include <errno.h>
31
32#include "py/nlr.h"
33#include "py/objlist.h"
34#include "py/runtime.h"
Damien George9475cc52016-03-30 11:35:03 +030035#include "py/mphal.h"
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +030036#include "netutils.h"
37#include "queue.h"
38#include "user_interface.h"
39#include "espconn.h"
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +030040#include "spi_flash.h"
Damien George9475cc52016-03-30 11:35:03 +030041#include "ets_alt_task.h"
Paul Sokolovskyee3fec32015-06-12 17:16:52 +030042
Paul Sokolovskyd5a12a62016-02-19 18:53:43 +020043#define MODNETWORK_INCLUDE_CONSTANTS (1)
44
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +020045typedef struct _wlan_if_obj_t {
46 mp_obj_base_t base;
47 int if_id;
48} wlan_if_obj_t;
Paul Sokolovskyee3fec32015-06-12 17:16:52 +030049
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +020050void error_check(bool status, const char *msg);
51const mp_obj_type_t wlan_if_type;
52
53STATIC const wlan_if_obj_t wlan_objs[] = {
54 {{&wlan_if_type}, STATION_IF},
55 {{&wlan_if_type}, SOFTAP_IF},
56};
57
58STATIC void require_if(mp_obj_t wlan_if, int if_no) {
59 wlan_if_obj_t *self = MP_OBJ_TO_PTR(wlan_if);
60 if (self->if_id != if_no) {
Paul Sokolovsky2c8356c2016-04-05 16:08:25 +030061 error_check(false, if_no == STATION_IF ? "STA required" : "AP required");
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +020062 }
Paul Sokolovskyee3fec32015-06-12 17:16:52 +030063}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +020064
65STATIC mp_obj_t get_wlan(mp_uint_t n_args, const mp_obj_t *args) {
66 int idx = 0;
67 if (n_args > 0) {
68 idx = mp_obj_get_int(args[0]);
69 }
70 return MP_OBJ_FROM_PTR(&wlan_objs[idx]);
71}
72STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(get_wlan_obj, 0, 1, get_wlan);
Paul Sokolovskyee3fec32015-06-12 17:16:52 +030073
Paul Sokolovsky1c43a0f2016-02-19 18:44:13 +020074STATIC mp_obj_t esp_active(mp_uint_t n_args, const mp_obj_t *args) {
75 wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
76 uint32_t mode = wifi_get_opmode();
77 if (n_args > 1) {
78 int mask = self->if_id == STATION_IF ? STATION_MODE : SOFTAP_MODE;
79 if (mp_obj_get_int(args[1]) != 0) {
80 mode |= mask;
81 } else {
82 mode &= ~mask;
83 }
84 error_check(wifi_set_opmode(mode), "Cannot update i/f status");
85 return mp_const_none;
86 }
87
88 // Get active status
89 if (self->if_id == STATION_IF) {
90 return mp_obj_new_bool(mode & STATION_MODE);
91 } else {
92 return mp_obj_new_bool(mode & SOFTAP_MODE);
93 }
94}
95STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_active_obj, 1, 2, esp_active);
96
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +030097STATIC mp_obj_t esp_connect(mp_uint_t n_args, const mp_obj_t *args) {
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +020098 require_if(args[0], STATION_IF);
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +030099 struct station_config config = {{0}};
100 mp_uint_t len;
101 const char *p;
102
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300103 p = mp_obj_str_get_data(args[1], &len);
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200104 memcpy(config.ssid, p, len);
105 p = mp_obj_str_get_data(args[2], &len);
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300106 memcpy(config.password, p, len);
107
108 error_check(wifi_station_set_config(&config), "Cannot set STA config");
109 error_check(wifi_station_connect(), "Cannot connect to AP");
110
111 return mp_const_none;
112}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200113STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_connect_obj, 3, 7, esp_connect);
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300114
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200115STATIC mp_obj_t esp_disconnect(mp_obj_t self_in) {
116 require_if(self_in, STATION_IF);
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300117 error_check(wifi_station_disconnect(), "Cannot disconnect from AP");
118 return mp_const_none;
119}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200120STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_disconnect_obj, esp_disconnect);
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300121
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200122STATIC mp_obj_t esp_status(mp_obj_t self_in) {
123 wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
124 if (self->if_id == STATION_IF) {
125 return MP_OBJ_NEW_SMALL_INT(wifi_station_get_connect_status());
126 }
127 return MP_OBJ_NEW_SMALL_INT(-1);
Bill Owens60ccb412015-06-18 05:54:29 -0700128}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200129STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_status_obj, esp_status);
Bill Owens60ccb412015-06-18 05:54:29 -0700130
Damien George9475cc52016-03-30 11:35:03 +0300131STATIC mp_obj_t *esp_scan_list = NULL;
132
Bill Owens686516f2015-06-16 10:27:12 -0700133STATIC void esp_scan_cb(scaninfo *si, STATUS status) {
Damien George9475cc52016-03-30 11:35:03 +0300134 if (esp_scan_list == NULL) {
135 // called unexpectedly
136 return;
137 }
138 if (si->pbss && status == 0) {
139 struct bss_info *bs;
Bill Owens686516f2015-06-16 10:27:12 -0700140 STAILQ_FOREACH(bs, si->pbss, next) {
141 mp_obj_tuple_t *t = mp_obj_new_tuple(6, NULL);
142 t->items[0] = mp_obj_new_bytes(bs->ssid, strlen((char*)bs->ssid));
143 t->items[1] = mp_obj_new_bytes(bs->bssid, sizeof(bs->bssid));
144 t->items[2] = MP_OBJ_NEW_SMALL_INT(bs->channel);
145 t->items[3] = MP_OBJ_NEW_SMALL_INT(bs->rssi);
146 t->items[4] = MP_OBJ_NEW_SMALL_INT(bs->authmode);
147 t->items[5] = MP_OBJ_NEW_SMALL_INT(bs->is_hidden);
Damien George9475cc52016-03-30 11:35:03 +0300148 mp_obj_list_append(*esp_scan_list, MP_OBJ_FROM_PTR(t));
Bill Owens686516f2015-06-16 10:27:12 -0700149 }
Damien George9475cc52016-03-30 11:35:03 +0300150 } else {
151 // indicate error
152 *esp_scan_list = MP_OBJ_NULL;
Bill Owens686516f2015-06-16 10:27:12 -0700153 }
Damien George9475cc52016-03-30 11:35:03 +0300154 esp_scan_list = NULL;
Bill Owens686516f2015-06-16 10:27:12 -0700155}
156
Damien George9475cc52016-03-30 11:35:03 +0300157STATIC mp_obj_t esp_scan(mp_obj_t self_in) {
Bill Owens686516f2015-06-16 10:27:12 -0700158 if (wifi_get_opmode() == SOFTAP_MODE) {
Damien George9475cc52016-03-30 11:35:03 +0300159 nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError,
160 "scan unsupported in AP mode"));
Bill Owens686516f2015-06-16 10:27:12 -0700161 }
Damien George9475cc52016-03-30 11:35:03 +0300162 mp_obj_t list = mp_obj_new_list(0, NULL);
163 esp_scan_list = &list;
Bill Owens686516f2015-06-16 10:27:12 -0700164 wifi_station_scan(NULL, (scan_done_cb_t)esp_scan_cb);
Damien George9475cc52016-03-30 11:35:03 +0300165 ETS_POLL_WHILE(esp_scan_list != NULL);
166 if (list == MP_OBJ_NULL) {
167 nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, "scan failed"));
168 }
169 return list;
Bill Owens686516f2015-06-16 10:27:12 -0700170}
Damien George9475cc52016-03-30 11:35:03 +0300171STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_scan_obj, esp_scan);
Bill Owens686516f2015-06-16 10:27:12 -0700172
Bill Owense2bfa472015-06-22 13:22:17 -0700173/// \method isconnected()
174/// Return True if connected to an AP and an IP address has been assigned,
175/// false otherwise.
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200176STATIC mp_obj_t esp_isconnected(mp_obj_t self_in) {
177 wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
178 if (self->if_id == STATION_IF) {
179 if (wifi_station_get_connect_status() == STATION_GOT_IP) {
180 return mp_const_true;
181 }
182 } else {
183 if (wifi_softap_get_station_num() > 0) {
184 return mp_const_true;
185 }
Bill Owense2bfa472015-06-22 13:22:17 -0700186 }
187 return mp_const_false;
188}
189
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200190STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_isconnected_obj, esp_isconnected);
Bill Owense2bfa472015-06-22 13:22:17 -0700191
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200192STATIC mp_obj_t esp_mac(mp_uint_t n_args, const mp_obj_t *args) {
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200193 wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200194 uint8_t mac[6];
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200195 if (n_args == 1) {
196 wifi_get_macaddr(self->if_id, mac);
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200197 return mp_obj_new_bytes(mac, sizeof(mac));
198 } else {
199 mp_buffer_info_t bufinfo;
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200200 mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200201
202 if (bufinfo.len != 6) {
203 nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
204 "invalid buffer length"));
205 }
206
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200207 wifi_set_macaddr(self->if_id, bufinfo.buf);
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200208 return mp_const_none;
209 }
210}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200211STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_mac_obj, 1, 2, esp_mac);
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200212
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200213STATIC mp_obj_t esp_ifconfig(mp_obj_t self_in) {
214 wlan_if_obj_t *self = MP_OBJ_TO_PTR(self_in);
Damien George02ea74d2015-12-22 14:28:53 +0000215 struct ip_info info;
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200216 wifi_get_ip_info(self->if_id, &info);
Damien George02ea74d2015-12-22 14:28:53 +0000217 mp_obj_t ifconfig[4] = {
218 netutils_format_ipv4_addr((uint8_t*)&info.ip, NETUTILS_BIG),
219 netutils_format_ipv4_addr((uint8_t*)&info.netmask, NETUTILS_BIG),
220 netutils_format_ipv4_addr((uint8_t*)&info.gw, NETUTILS_BIG),
221 MP_OBJ_NEW_QSTR(MP_QSTR_), // no DNS server
222 };
223 return mp_obj_new_tuple(4, ifconfig);
224}
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200225STATIC MP_DEFINE_CONST_FUN_OBJ_1(esp_ifconfig_obj, esp_ifconfig);
Damien George02ea74d2015-12-22 14:28:53 +0000226
Paul Sokolovskya49c1602016-02-19 19:50:36 +0200227STATIC mp_obj_t esp_config(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
228 if (n_args != 1 && kwargs->used != 0) {
229 nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
230 "either pos or kw args are allowed"));
231 }
232
233 wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
234 union {
235 struct station_config sta;
236 struct softap_config ap;
237 } cfg;
238
239 if (self->if_id == STATION_IF) {
240 error_check(wifi_station_get_config(&cfg.sta), "can't get STA config");
241 } else {
242 error_check(wifi_softap_get_config(&cfg.ap), "can't get AP config");
243 }
244
245 if (kwargs->used != 0) {
246
247 for (mp_uint_t i = 0; i < kwargs->alloc; i++) {
248 if (MP_MAP_SLOT_IS_FILLED(kwargs, i)) {
249 #define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
250 switch ((uintptr_t)kwargs->table[i].key) {
251 case QS(MP_QSTR_essid): {
252 mp_uint_t len;
253 const char *s = mp_obj_str_get_data(kwargs->table[i].value, &len);
254 len = MIN(len, sizeof(cfg.ap.ssid));
255 memcpy(cfg.ap.ssid, s, len);
256 cfg.ap.ssid_len = len;
257 break;
258 }
259 default:
260 goto unknown;
261 }
262 #undef QS
263 }
264 }
265
266 if (self->if_id == STATION_IF) {
267 error_check(wifi_station_set_config(&cfg.sta), "can't set STA config");
268 } else {
269 error_check(wifi_softap_set_config(&cfg.ap), "can't set AP config");
270 }
271
272 return mp_const_none;
273 }
274
275 // Get config
276
277 if (n_args != 2) {
278 nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
279 "can query only one param"));
280 }
281
282 #define QS(x) (uintptr_t)MP_OBJ_NEW_QSTR(x)
283 switch ((uintptr_t)args[1]) {
284 case QS(MP_QSTR_essid):
285 return mp_obj_new_str((char*)cfg.ap.ssid, cfg.ap.ssid_len, false);
286 }
287 #undef QS
288
289unknown:
290 nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError,
291 "unknown config param"));
292}
293STATIC MP_DEFINE_CONST_FUN_OBJ_KW(esp_config_obj, 1, esp_config);
294
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200295STATIC const mp_map_elem_t wlan_if_locals_dict_table[] = {
Paul Sokolovsky1c43a0f2016-02-19 18:44:13 +0200296 { MP_OBJ_NEW_QSTR(MP_QSTR_active), (mp_obj_t)&esp_active_obj },
Paul Sokolovsky32eb4b92015-06-12 17:26:10 +0300297 { MP_OBJ_NEW_QSTR(MP_QSTR_connect), (mp_obj_t)&esp_connect_obj },
298 { MP_OBJ_NEW_QSTR(MP_QSTR_disconnect), (mp_obj_t)&esp_disconnect_obj },
Bill Owens60ccb412015-06-18 05:54:29 -0700299 { MP_OBJ_NEW_QSTR(MP_QSTR_status), (mp_obj_t)&esp_status_obj },
Bill Owens686516f2015-06-16 10:27:12 -0700300 { MP_OBJ_NEW_QSTR(MP_QSTR_scan), (mp_obj_t)&esp_scan_obj },
Bill Owense2bfa472015-06-22 13:22:17 -0700301 { MP_OBJ_NEW_QSTR(MP_QSTR_isconnected), (mp_obj_t)&esp_isconnected_obj },
Paul Sokolovskyfce00362015-12-27 10:03:32 +0200302 { MP_OBJ_NEW_QSTR(MP_QSTR_mac), (mp_obj_t)&esp_mac_obj },
Paul Sokolovskya49c1602016-02-19 19:50:36 +0200303 { MP_OBJ_NEW_QSTR(MP_QSTR_config), (mp_obj_t)&esp_config_obj },
Damien George02ea74d2015-12-22 14:28:53 +0000304 { MP_OBJ_NEW_QSTR(MP_QSTR_ifconfig), (mp_obj_t)&esp_ifconfig_obj },
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200305};
306
307STATIC MP_DEFINE_CONST_DICT(wlan_if_locals_dict, wlan_if_locals_dict_table);
308
309const mp_obj_type_t wlan_if_type = {
310 { &mp_type_type },
311 .name = MP_QSTR_WLAN,
312 .locals_dict = (mp_obj_t)&wlan_if_locals_dict,
313};
314
Paul Sokolovsky7378c502016-02-19 12:53:45 +0200315STATIC mp_obj_t esp_wifi_mode(mp_uint_t n_args, const mp_obj_t *args) {
316 if (n_args == 0) {
317 return mp_obj_new_int(wifi_get_opmode());
318 } else {
319 wifi_set_opmode(mp_obj_get_int(args[0]));
320 return mp_const_none;
321 }
322}
323STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_wifi_mode_obj, 0, 1, esp_wifi_mode);
324
325STATIC mp_obj_t esp_phy_mode(mp_uint_t n_args, const mp_obj_t *args) {
326 if (n_args == 0) {
327 return mp_obj_new_int(wifi_get_phy_mode());
328 } else {
329 wifi_set_phy_mode(mp_obj_get_int(args[0]));
330 return mp_const_none;
331 }
332}
333STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(esp_phy_mode_obj, 0, 1, esp_phy_mode);
334
Paul Sokolovsky9e8396a2016-02-13 19:26:17 +0200335STATIC const mp_map_elem_t mp_module_network_globals_table[] = {
336 { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_network) },
337 { MP_OBJ_NEW_QSTR(MP_QSTR_WLAN), (mp_obj_t)&get_wlan_obj },
Paul Sokolovsky7378c502016-02-19 12:53:45 +0200338 { MP_OBJ_NEW_QSTR(MP_QSTR_wifi_mode), (mp_obj_t)&esp_wifi_mode_obj },
339 { MP_OBJ_NEW_QSTR(MP_QSTR_phy_mode), (mp_obj_t)&esp_phy_mode_obj },
Bill Owens60ccb412015-06-18 05:54:29 -0700340
341#if MODNETWORK_INCLUDE_CONSTANTS
Paul Sokolovsky5239a8a2016-02-20 01:38:17 +0200342 { MP_OBJ_NEW_QSTR(MP_QSTR_STA_IF),
343 MP_OBJ_NEW_SMALL_INT(STATION_IF)},
344 { MP_OBJ_NEW_QSTR(MP_QSTR_AP_IF),
345 MP_OBJ_NEW_SMALL_INT(SOFTAP_IF)},
346
Bill Owens60ccb412015-06-18 05:54:29 -0700347 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_IDLE),
348 MP_OBJ_NEW_SMALL_INT(STATION_IDLE)},
349 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECTING),
350 MP_OBJ_NEW_SMALL_INT(STATION_CONNECTING)},
351 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_WRONG_PASSWORD),
352 MP_OBJ_NEW_SMALL_INT(STATION_WRONG_PASSWORD)},
353 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_NO_AP_FOUND),
354 MP_OBJ_NEW_SMALL_INT(STATION_NO_AP_FOUND)},
355 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_CONNECT_FAIL),
356 MP_OBJ_NEW_SMALL_INT(STATION_CONNECT_FAIL)},
357 { MP_OBJ_NEW_QSTR(MP_QSTR_STAT_GOT_IP),
358 MP_OBJ_NEW_SMALL_INT(STATION_GOT_IP)},
Paul Sokolovsky55314372016-04-01 12:10:11 +0300359
360 { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11B),
361 MP_OBJ_NEW_SMALL_INT(PHY_MODE_11B) },
362 { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11G),
363 MP_OBJ_NEW_SMALL_INT(PHY_MODE_11G) },
364 { MP_OBJ_NEW_QSTR(MP_QSTR_MODE_11N),
365 MP_OBJ_NEW_SMALL_INT(PHY_MODE_11N) },
Bill Owens60ccb412015-06-18 05:54:29 -0700366#endif
Paul Sokolovskyee3fec32015-06-12 17:16:52 +0300367};
368
369STATIC MP_DEFINE_CONST_DICT(mp_module_network_globals, mp_module_network_globals_table);
370
371const mp_obj_module_t network_module = {
372 .base = { &mp_type_module },
373 .name = MP_QSTR_network,
374 .globals = (mp_obj_dict_t*)&mp_module_network_globals,
375};