diff --git a/include/NetworkHandler.h b/include/NetworkHandler.h index ab7d0cf..0e86c0d 100644 --- a/include/NetworkHandler.h +++ b/include/NetworkHandler.h @@ -11,5 +11,6 @@ void network_connect(void); void network_disconnect(void); void network_init(void); +bool network_is_connected(void); #endif diff --git a/src/NetworkHandler.cpp b/src/NetworkHandler.cpp index 96e68ac..5ce289e 100644 --- a/src/NetworkHandler.cpp +++ b/src/NetworkHandler.cpp @@ -3,9 +3,10 @@ Copyright (c) 2023 Casey Reeves and the LuminaSensum contributors */ -#include "EthernetInterface.h" +#include "NetworkHandler.h" #include "mbed-trace/mbed_trace.h" #include "mbed.h" +#include #define TRACE_GROUP "NET" // instantiate the network interface @@ -23,7 +24,7 @@ // set up a status callback function to monitor for changes -bool is_connected = false; +std::atomic is_connected = false; void status_callback(nsapi_event_t status, intptr_t param) { tr_debug("Detected a connection status change."); switch (param) { @@ -61,3 +62,7 @@ eth.attach(&status_callback); tr_debug("Status callback now attached to monitor changes."); } + +// function to check weather the network is connected + +bool network_is_connected(void) { return is_connected; }