Cleaned up and now testing
This commit is contained in:
parent
b336039aab
commit
9d840aab0b
@ -160,76 +160,20 @@ mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
wifi_network_obj_t *apnet = m_new_obj(wifi_network_obj_t);
|
||||
apnet->base.type = &wifi_network_type;
|
||||
wifi_network_obj_t *ap_info = m_new_obj(wifi_network_obj_t);
|
||||
ap_info->base.type = &wifi_network_type;
|
||||
// From esp_wifi.h, the possible return values (typos theirs):
|
||||
// ESP_OK: succeed
|
||||
// ESP_ERR_WIFI_CONN: The station interface don't initialized
|
||||
// ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
if (esp_wifi_sta_get_ap_info(&self->apnet.record) != ESP_OK){
|
||||
if (esp_wifi_sta_get_ap_info(&self->ap_info.record) != ESP_OK){
|
||||
return mp_const_none;
|
||||
} else {
|
||||
memcpy(&apnet->record, &self->apnet.record, sizeof(wifi_ap_record_t));
|
||||
return MP_OBJ_FROM_PTR(apnet);
|
||||
memcpy(&ap_info->record, &self->ap_info.record, sizeof(wifi_ap_record_t));
|
||||
return MP_OBJ_FROM_PTR(ap_info);
|
||||
}
|
||||
}
|
||||
|
||||
mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self) {
|
||||
if (!esp_netif_is_netif_up(self->netif)) {
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
// Make sure the interface is in STA mode
|
||||
if (self->sta_mode){
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
// From esp_wifi.h, the possible return values (typos theirs):
|
||||
// ESP_OK: succeed
|
||||
// ESP_ERR_WIFI_CONN: The station interface don't initialized
|
||||
// ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
|
||||
return mp_const_none;
|
||||
} else {
|
||||
return mp_obj_new_int(self->ap_info.rssi);
|
||||
}
|
||||
}
|
||||
|
||||
// mp_obj_t common_hal_wifi_radio_get_ap_ssid(wifi_radio_obj_t *self) {
|
||||
// if (!esp_netif_is_netif_up(self->netif)) {
|
||||
// return mp_const_none;
|
||||
// }
|
||||
|
||||
// // Make sure the interface is in STA mode
|
||||
// if (self->sta_mode){
|
||||
// return mp_const_none;
|
||||
// }
|
||||
|
||||
// if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
|
||||
// return mp_const_none;
|
||||
// } else {
|
||||
// const char* cstr = (const char*) self->ap_info.ssid;
|
||||
// return mp_obj_new_str(cstr, strlen(cstr));
|
||||
// }
|
||||
// }
|
||||
|
||||
// mp_obj_t common_hal_wifi_radio_get_ap_bssid(wifi_radio_obj_t *self) {
|
||||
// if (!esp_netif_is_netif_up(self->netif)) {
|
||||
// return mp_const_none;
|
||||
// }
|
||||
|
||||
// // Make sure the interface is in STA mode
|
||||
// if (self->sta_mode){
|
||||
// return mp_const_none;
|
||||
// }
|
||||
|
||||
// if (esp_wifi_sta_get_ap_info(&self->ap_info) != ESP_OK){
|
||||
// return mp_const_none;
|
||||
// } else {
|
||||
// return mp_obj_new_bytes(self->ap_info.bssid, MAC_ADDRESS_LENGTH);
|
||||
// }
|
||||
// }
|
||||
|
||||
mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self) {
|
||||
if (!esp_netif_is_netif_up(self->netif)) {
|
||||
return mp_const_none;
|
||||
|
@ -47,8 +47,7 @@ typedef struct {
|
||||
StaticEventGroup_t event_group;
|
||||
EventGroupHandle_t event_group_handle;
|
||||
wifi_config_t sta_config;
|
||||
wifi_ap_record_t ap_info;
|
||||
wifi_network_obj_t apnet;
|
||||
wifi_network_obj_t ap_info;
|
||||
esp_netif_ip_info_t ip_info;
|
||||
esp_netif_dns_info_t dns_info;
|
||||
esp_netif_t *netif;
|
||||
|
@ -163,54 +163,6 @@ STATIC mp_obj_t wifi_radio_connect(size_t n_args, const mp_obj_t *pos_args, mp_m
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(wifi_radio_connect_obj, 1, wifi_radio_connect);
|
||||
|
||||
//| ap_rssi: int
|
||||
//| """RSSI of the currently connected AP. Returns none if not connected"""
|
||||
//|
|
||||
STATIC mp_obj_t wifi_radio_get_ap_rssi(mp_obj_t self) {
|
||||
return common_hal_wifi_radio_get_ap_rssi(self);
|
||||
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_rssi_obj, wifi_radio_get_ap_rssi);
|
||||
|
||||
const mp_obj_property_t wifi_radio_ap_rssi_obj = {
|
||||
.base.type = &mp_type_property,
|
||||
.proxy = { (mp_obj_t)&wifi_radio_get_ap_rssi_obj,
|
||||
(mp_obj_t)&mp_const_none_obj,
|
||||
(mp_obj_t)&mp_const_none_obj },
|
||||
};
|
||||
|
||||
// //| ap_ssid: int
|
||||
// //| """SSID of the currently connected AP. Returns none if not connected"""
|
||||
// //|
|
||||
// STATIC mp_obj_t wifi_radio_get_ap_ssid(mp_obj_t self) {
|
||||
// return common_hal_wifi_radio_get_ap_ssid(self);
|
||||
|
||||
// }
|
||||
// MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_ssid_obj, wifi_radio_get_ap_ssid);
|
||||
|
||||
// const mp_obj_property_t wifi_radio_ap_ssid_obj = {
|
||||
// .base.type = &mp_type_property,
|
||||
// .proxy = { (mp_obj_t)&wifi_radio_get_ap_ssid_obj,
|
||||
// (mp_obj_t)&mp_const_none_obj,
|
||||
// (mp_obj_t)&mp_const_none_obj },
|
||||
// };
|
||||
|
||||
// //| ap_bssid: int
|
||||
// //| """BSSID (usually MAC) of the currently connected AP. Returns none if not connected"""
|
||||
// //|
|
||||
// STATIC mp_obj_t wifi_radio_get_ap_bssid(mp_obj_t self) {
|
||||
// return common_hal_wifi_radio_get_ap_bssid(self);
|
||||
|
||||
// }
|
||||
// MP_DEFINE_CONST_FUN_OBJ_1(wifi_radio_get_ap_bssid_obj, wifi_radio_get_ap_bssid);
|
||||
|
||||
// const mp_obj_property_t wifi_radio_ap_bssid_obj = {
|
||||
// .base.type = &mp_type_property,
|
||||
// .proxy = { (mp_obj_t)&wifi_radio_get_ap_bssid_obj,
|
||||
// (mp_obj_t)&mp_const_none_obj,
|
||||
// (mp_obj_t)&mp_const_none_obj },
|
||||
// };
|
||||
|
||||
//| ipv4_gateway: Optional[ipaddress.IPv4Address]
|
||||
//| """IP v4 Address of the gateway when connected to an access point. None otherwise."""
|
||||
//|
|
||||
@ -276,7 +228,7 @@ const mp_obj_property_t wifi_radio_ipv4_dns_obj = {
|
||||
};
|
||||
|
||||
//| ap_info: Optional[Network]
|
||||
//| """None otherwise."""
|
||||
//| """Network object containing BSSID, SSID, channel, and RSSI when connected to an access point. None otherwise."""
|
||||
//|
|
||||
STATIC mp_obj_t wifi_radio_get_ap_info(mp_obj_t self) {
|
||||
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[] = {
|
||||
// { MP_ROM_QSTR(MP_QSTR_connect_to_enterprise), MP_ROM_PTR(&wifi_radio_connect_to_enterprise_obj) },
|
||||
|
||||
{ MP_ROM_QSTR(MP_QSTR_ap_info), MP_ROM_PTR(&wifi_radio_ap_info_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ap_rssi), MP_ROM_PTR(&wifi_radio_ap_rssi_obj) },
|
||||
// { MP_ROM_QSTR(MP_QSTR_ap_ssid), MP_ROM_PTR(&wifi_radio_ap_ssid_obj) },
|
||||
// { MP_ROM_QSTR(MP_QSTR_ap_bssid), MP_ROM_PTR(&wifi_radio_ap_bssid_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_dns), MP_ROM_PTR(&wifi_radio_ipv4_dns_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_gateway), MP_ROM_PTR(&wifi_radio_ipv4_gateway_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_ipv4_subnet), MP_ROM_PTR(&wifi_radio_ipv4_subnet_obj) },
|
||||
|
@ -54,9 +54,6 @@ extern void common_hal_wifi_radio_stop_scanning_networks(wifi_radio_obj_t *self)
|
||||
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);
|
||||
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ap_info(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self);
|
||||
// extern mp_obj_t common_hal_wifi_radio_get_ap_ssid(wifi_radio_obj_t *self);
|
||||
// extern mp_obj_t common_hal_wifi_radio_get_ap_bssid(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_dns(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_gateway(wifi_radio_obj_t *self);
|
||||
extern mp_obj_t common_hal_wifi_radio_get_ipv4_subnet(wifi_radio_obj_t *self);
|
||||
|
Loading…
x
Reference in New Issue
Block a user