@@ -62,29 +62,7 @@ int arduino::WiFiClass::beginAP(const char* ssid, const char *passphrase, uint8_
62
62
63
63
nsapi_error_t registrationResult;
64
64
softAPInterface->unregister_event_handler ();
65
- registrationResult = softAPInterface->register_event_handler ([](whd_interface_t ifp, const whd_event_header_t *event_header, const uint8_t *event_data, void *handler_user_data) -> void *{
66
-
67
- if (event_header->event_type == WLC_E_ASSOC_IND){
68
- WiFi._currentNetworkStatus = WL_AP_CONNECTED;
69
- } else if (event_header->event_type == WLC_E_DISASSOC_IND){
70
- WiFi._currentNetworkStatus = WL_AP_LISTENING;
71
- }
72
-
73
- // Default Event Handler
74
- whd_driver_t whd_driver = ifp->whd_driver ;
75
- WHD_IOCTL_LOG_ADD_EVENT (whd_driver, event_header->event_type , event_header->flags , event_header->reason );
76
-
77
- if ((event_header->event_type == (whd_event_num_t )WLC_E_LINK) || (event_header->event_type == WLC_E_IF)) {
78
- if (osSemaphoreGetCount (whd_driver->ap_info .whd_wifi_sleep_flag ) < 1 ) {
79
- osStatus_t result = osSemaphoreRelease (whd_driver->ap_info .whd_wifi_sleep_flag );
80
- if (result != osOK) {
81
- printf (" Release whd_wifi_sleep_flag ERROR: %d" , result);
82
- }
83
- }
84
- }
85
-
86
- return handler_user_data;
87
- });
65
+ registrationResult = softAPInterface->register_event_handler (arduino::WiFiClass::handleAPEvents);
88
66
89
67
if (registrationResult != NSAPI_ERROR_OK) {
90
68
return (_currentNetworkStatus = WL_AP_FAILED);
@@ -94,6 +72,29 @@ int arduino::WiFiClass::beginAP(const char* ssid, const char *passphrase, uint8_
94
72
return _currentNetworkStatus;
95
73
}
96
74
75
+ void * arduino::WiFiClass::handleAPEvents (whd_interface_t ifp, const whd_event_header_t *event_header, const uint8_t *event_data, void *handler_user_data){
76
+ if (event_header->event_type == WLC_E_ASSOC_IND){
77
+ WiFi._currentNetworkStatus = WL_AP_CONNECTED;
78
+ } else if (event_header->event_type == WLC_E_DISASSOC_IND){
79
+ WiFi._currentNetworkStatus = WL_AP_LISTENING;
80
+ }
81
+
82
+ // Default Event Handler
83
+ whd_driver_t whd_driver = ifp->whd_driver ;
84
+ WHD_IOCTL_LOG_ADD_EVENT (whd_driver, event_header->event_type , event_header->flags , event_header->reason );
85
+
86
+ if ((event_header->event_type == (whd_event_num_t )WLC_E_LINK) || (event_header->event_type == WLC_E_IF)) {
87
+ if (osSemaphoreGetCount (whd_driver->ap_info .whd_wifi_sleep_flag ) < 1 ) {
88
+ osStatus_t result = osSemaphoreRelease (whd_driver->ap_info .whd_wifi_sleep_flag );
89
+ if (result != osOK) {
90
+ printf (" Release whd_wifi_sleep_flag ERROR: %d" , result);
91
+ }
92
+ }
93
+ }
94
+
95
+ return handler_user_data;
96
+ }
97
+
97
98
void arduino::WiFiClass::ensureDefaultAPNetworkConfiguration () {
98
99
if (_ip == nullptr ){
99
100
_ip = SocketAddress (DEFAULT_IP_ADDRESS);
0 commit comments