Skip to content

Commit 343cdfa

Browse files
authored
Merge pull request #40 from ALLTERCO/add_get_connected_sta_cfg
Add mgos_wifi_get_connected_sta_cfg()
2 parents 25cdec8 + 47669bf commit 343cdfa

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

include/mgos_wifi.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,12 @@ char *mgos_wifi_get_status_str(void);
176176
*/
177177
char *mgos_wifi_get_connected_ssid(void);
178178

179+
/*
180+
* Get a `struct mgos_config_wifi_sta` to which we are currently connected
181+
* or `NULL` if not connected.
182+
*/
183+
const struct mgos_config_wifi_sta *mgos_wifi_get_connected_sta_cfg(void);
184+
179185
/*
180186
* Return default DNS server IP address. The caller should free it.
181187
*/

src/mgos_wifi_sta.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,12 @@ char *mgos_wifi_get_connected_ssid(void) {
678678
return strdup(s_cur_entry->cfg->ssid);
679679
}
680680

681+
const struct mgos_config_wifi_sta *mgos_wifi_get_connected_sta_cfg(void) {
682+
if (s_cur_entry == NULL) return NULL;
683+
return s_cur_entry->cfg;
684+
}
685+
686+
681687
void mgos_wifi_sta_init(void) {
682688
mgos_event_add_group_handler(MGOS_WIFI_EV_BASE, mgos_wifi_ev_handler, NULL);
683689
mgos_event_add_handler(MGOS_EVENT_REBOOT_AFTER,

0 commit comments

Comments
 (0)