Try not to broadcast everywhere.
What function, what background ? You either call a C function from C/C++ code or you need to FFI from mJS. There is no point in calling an RPC from a web page to get WiFi status since your device needs to be connected to have WiFi to be able to answer… do you need other status ? Specifically ?
There is no notion of “Internet” connection, whoever tells you that “is connected to the Internet” is pinging some host or polling some service that he assumes must be accesible and knows how to access that. AFAIK mOS does not do that; but if you connect to a cloud you can check its status.
From the WiFi API docs:
mgos_wifi_get_status
enum mgos_wifi_status mgos_wifi_get_status(void);
Get wifi status, see enum mgos_wifi_status.
and they belong in the header
enum mgos_wifi_status {
MGOS_WIFI_DISCONNECTED = 0,
MGOS_WIFI_CONNECTING = 1,
MGOS_WIFI_CONNECTED = 2,
MGOS_WIFI_IP_ACQUIRED = 3,
};
Or you may subscribe to an event
Everything is documented, RTM.