Skip to content

Commit 9d840aa

Browse files
committed
Cleaned up and now testing
1 parent b336039 commit 9d840aa

File tree

4 files changed

+7
-118
lines changed

4 files changed

+7
-118
lines changed

ports/esp32s2/common-hal/wifi/Radio.c

Lines changed: 5 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -160,76 +160,20 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) {
160160
return mp_const_none;
161161
}
162162

163-
wifi_network_obj_t *apnet = m_new_obj(wifi_network_obj_t);
164-
apnet->base.type = &wifi_network_type;
163+
wifi_network_obj_t *ap_info = m_new_obj(wifi_network_obj_t);
164+
ap_info->base.type = &wifi_network_type;
165165
// From esp_wifi.h, the possible return values (typos theirs):
166166
// ESP_OK: succeed
167167
// ESP_ERR_WIFI_CONN: The station interface don't initialized
168168
// ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
169-
if (esp_wifi_sta_get_ap_info(&self->apnet.record) != ESP_OK){
169+
if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){
170170
return mp_const_none;
171171
} else {
172-
memcpy(&apnet->record, &self->apnet.record, sizeof(wifi_ap_record_t));
173-
return MP_OBJ_FROM_PTR(apnet);
172+
memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t));
173+
return MP_OBJ_FROM_PTR(ap_info);
174174
}
175175
}
176176

177-
mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self) {
178-
if (!esp_netif_is_netif_up(self->netif)) {
179-
return mp_const_none;
180-
}
181-
182-
// Make sure the interface is in STA mode
183-
if (self->sta_mode){
184-
return mp_const_none;
185-
}
186-
187-
// From esp_wifi.h, the possible return values (typos theirs):
188-
// ESP_OK: succeed
189-
// ESP_ERR_WIFI_CONN: The station interface don't initialized
190-
// ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
191-
if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
192-
return mp_const_none;
193-
} else {
194-
return mp_obj_new_int(self->ap_info.rssi);
195-
}
196-
}
197-
198-
// mp_obj_t common_hal_wifi_radio_get_ap_ssid(wifi_radio_obj_t *self) {
199-
// if (!esp_netif_is_netif_up(self->netif)) {
200-
// return mp_const_none;
201-
// }
202-
203-
// // Make sure the interface is in STA mode
204-
// if (self->sta_mode){
205-
// return mp_const_none;
206-
// }
207-
208-
// if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
209-
// return mp_const_none;
210-
// } else {
211-
// const char* cstr = (const char*) self->ap_info.ssid;
212-
// return mp_obj_new_str(cstr, strlen(cstr));
213-
// }
214-
// }
215-
216-
// mp_obj_t common_hal_wifi_radio_get_ap_bssid(wifi_radio_obj_t *self) {
217-
// if (!esp_netif_is_netif_up(self->netif)) {
218-
// return mp_const_none;
219-
// }
220-
221-
// // Make sure the interface is in STA mode
222-
// if (self->sta_mode){
223-
// return mp_const_none;
224-
// }
225-
226-
// if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
227-
// return mp_const_none;
228-
// } else {
229-
// return mp_obj_new_bytes(self->ap_info.bssid, MAC_ADDRESS_LENGTH);
230-
// }
231-
// }
232-
233177
mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self) {
234178
if (!esp_netif_is_netif_up(self->netif)) {
235179
return mp_const_none;

ports/esp32s2/common-hal/wifi/Radio.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,7 @@ typedef struct {
4747
StaticEventGroup_t event_group;
4848
EventGroupHandle_t event_group_handle;
4949
wifi_config_t sta_config;
50-
wifi_ap_record_t ap_info;
51-
wifi_network_obj_t apnet;
50+
wifi_network_obj_t ap_info;
5251
esp_netif_ip_info_t ip_info;
5352
esp_netif_dns_info_t dns_info;
5453
esp_netif_t *netif;

shared-bindings/wifi/Radio.c

Lines changed: 1 addition & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -163,54 +163,6 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m
163163
}
164164
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_connect_obj, 1, wifi_radio_connect);
165165

166-
//| ap_rssi: int
167-
//| """RSSI of the currently connected AP. Returns none if not connected"""
168-
//|
169-
STATIC mp_obj_t wifi_radio_get_ap_rssi(mp_obj_t self) {
170-
return common_hal_wifi_radio_get_ap_rssi(self);
171-
172-
}
173-
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_rssi_obj, wifi_radio_get_ap_rssi);
174-
175-
const mp_obj_property_t wifi_radio_ap_rssi_obj = {
176-
.base.type = &mp_type_property,
177-
.proxy = { (mp_obj_t)&wifi_radio_get_ap_rssi_obj,
178-
(mp_obj_t)&mp_const_none_obj,
179-
(mp_obj_t)&mp_const_none_obj },
180-
};
181-
182-
// //| ap_ssid: int
183-
// //| """SSID of the currently connected AP. Returns none if not connected"""
184-
// //|
185-
// STATIC mp_obj_t wifi_radio_get_ap_ssid(mp_obj_t self) {
186-
// return common_hal_wifi_radio_get_ap_ssid(self);
187-
188-
// }
189-
// MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_ssid_obj, wifi_radio_get_ap_ssid);
190-
191-
// const mp_obj_property_t wifi_radio_ap_ssid_obj = {
192-
// .base.type = &mp_type_property,
193-
// .proxy = { (mp_obj_t)&wifi_radio_get_ap_ssid_obj,
194-
// (mp_obj_t)&mp_const_none_obj,
195-
// (mp_obj_t)&mp_const_none_obj },
196-
// };
197-
198-
// //| ap_bssid: int
199-
// //| """BSSID (usually MAC) of the currently connected AP. Returns none if not connected"""
200-
// //|
201-
// STATIC mp_obj_t wifi_radio_get_ap_bssid(mp_obj_t self) {
202-
// return common_hal_wifi_radio_get_ap_bssid(self);
203-
204-
// }
205-
// MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_bssid_obj, wifi_radio_get_ap_bssid);
206-
207-
// const mp_obj_property_t wifi_radio_ap_bssid_obj = {
208-
// .base.type = &mp_type_property,
209-
// .proxy = { (mp_obj_t)&wifi_radio_get_ap_bssid_obj,
210-
// (mp_obj_t)&mp_const_none_obj,
211-
// (mp_obj_t)&mp_const_none_obj },
212-
// };
213-
214166
//| ipv4_gateway: Optional[ipaddress.IPv4Address]
215167
//| """IP v4 Address of the gateway when connected to an access point. None otherwise."""
216168
//|
@@ -276,7 +228,7 @@ const mp_obj_property_t wifi_radio_ipv4_dns_obj = {
276228
};
277229

278230
//| ap_info: Optional[Network]
279-
//| """None otherwise."""
231+
//| """Network object containing BSSID, SSID, channel, and RSSI when connected to an access point. None otherwise."""
280232
//|
281233
STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
282234
return common_hal_wifi_radio_get_ap_info(self);
@@ -332,9 +284,6 @@ STATIC const mp_rom_map_elem_t wifi_radio_locals_dict_table[] = {
332284
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
333285

334286
{ MP_ROM_QSTR(MP_QSTR_ap_info), MP_ROM_PTR(&wifi_radio_ap_info_obj) },
335-
{ MP_ROM_QSTR(MP_QSTR_ap_rssi), MP_ROM_PTR(&wifi_radio_ap_rssi_obj) },
336-
// { MP_ROM_QSTR(MP_QSTR_ap_ssid), MP_ROM_PTR(&wifi_radio_ap_ssid_obj) },
337-
// { MP_ROM_QSTR(MP_QSTR_ap_bssid), MP_ROM_PTR(&wifi_radio_ap_bssid_obj) },
338287
{ MP_ROM_QSTR(MP_QSTR_ipv4_dns), MP_ROM_PTR(&wifi_radio_ipv4_dns_obj) },
339288
{ MP_ROM_QSTR(MP_QSTR_ipv4_gateway), MP_ROM_PTR(&wifi_radio_ipv4_gateway_obj) },
340289
{ MP_ROM_QSTR(MP_QSTR_ipv4_subnet), MP_ROM_PTR(&wifi_radio_ipv4_subnet_obj) },

shared-bindings/wifi/Radio.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self)
5454
extern wifi_radio_error_t common_hal_wifi_radio_connect(wifi_radio_obj_t *self, uint8_t* ssid, size_t ssid_len, uint8_t* password, size_t password_len, uint8_t channel, mp_float_t timeout, uint8_t* bssid, size_t bssid_len);
5555

5656
extern mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self);
57-
extern mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self);
58-
// extern mp_obj_t common_hal_wifi_radio_get_ap_ssid(wifi_radio_obj_t *self);
59-
// extern mp_obj_t common_hal_wifi_radio_get_ap_bssid(wifi_radio_obj_t *self);
6057
extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self);
6158
extern mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self);
6259
extern mp_obj_t common_hal_wifi_radio_get_ipv4_subnet(wifi_radio_obj_t *self);

0 commit comments

Comments
 (0)