@@ -153,49 +153,43 @@ mp_obj_t common_hal_wifi_radio_get_ap_rssi(wifi_radio_obj_t *self) {
153
153
}
154
154
155
155
// Make sure the interface is in STA mode
156
- wifi_mode_t if_mode ;
157
- esp_wifi_get_mode (& if_mode );
158
- if (if_mode != WIFI_MODE_STA ){
156
+ if (self -> sta_mode ){
159
157
return mp_const_none ;
160
158
}
161
159
162
- wifi_ap_record_t ap_info ;
163
160
// From esp_wifi.h, the possible return values (typos theirs):
164
161
// ESP_OK: succeed
165
162
// ESP_ERR_WIFI_CONN: The station interface don't initialized
166
163
// ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
167
- if (esp_wifi_sta_get_ap_info (& ap_info ) != ESP_OK ){
164
+ if (esp_wifi_sta_get_ap_info (& self -> ap_info ) != ESP_OK ){
168
165
return mp_const_none ;
169
166
} else {
170
- return mp_obj_new_int (ap_info .rssi );
167
+ return mp_obj_new_int (self -> ap_info .rssi );
171
168
}
172
169
}
173
170
174
171
mp_obj_t common_hal_wifi_radio_get_ipv4_gateway (wifi_radio_obj_t * self ) {
175
172
if (!esp_netif_is_netif_up (self -> netif )) {
176
173
return mp_const_none ;
177
174
}
178
- esp_netif_ip_info_t ip_info ;
179
- esp_netif_get_ip_info (self -> netif , & ip_info );
180
- return common_hal_ipaddress_new_ipv4address (ip_info .gw .addr );
175
+ esp_netif_get_ip_info (self -> netif , & self -> ip_info );
176
+ return common_hal_ipaddress_new_ipv4address (self -> ip_info .gw .addr );
181
177
}
182
178
183
179
mp_obj_t common_hal_wifi_radio_get_ipv4_subnet (wifi_radio_obj_t * self ) {
184
180
if (!esp_netif_is_netif_up (self -> netif )) {
185
181
return mp_const_none ;
186
182
}
187
- esp_netif_ip_info_t ip_info ;
188
- esp_netif_get_ip_info (self -> netif , & ip_info );
189
- return common_hal_ipaddress_new_ipv4address (ip_info .netmask .addr );
183
+ esp_netif_get_ip_info (self -> netif , & self -> ip_info );
184
+ return common_hal_ipaddress_new_ipv4address (self -> ip_info .netmask .addr );
190
185
}
191
186
192
187
mp_obj_t common_hal_wifi_radio_get_ipv4_address (wifi_radio_obj_t * self ) {
193
188
if (!esp_netif_is_netif_up (self -> netif )) {
194
189
return mp_const_none ;
195
190
}
196
- esp_netif_ip_info_t ip_info ;
197
- esp_netif_get_ip_info (self -> netif , & ip_info );
198
- return common_hal_ipaddress_new_ipv4address (ip_info .ip .addr );
191
+ esp_netif_get_ip_info (self -> netif , & self -> ip_info );
192
+ return common_hal_ipaddress_new_ipv4address (self -> ip_info .ip .addr );
199
193
}
200
194
201
195
mp_int_t common_hal_wifi_radio_ping (wifi_radio_obj_t * self , mp_obj_t ip_address , mp_float_t timeout ) {
0 commit comments