Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ca42334

Browse files
committed
Merge remote-tracking branch 'arduino/master'
2 parents 8952379 + 727c018 commit ca42334

File tree

3 files changed

+49
-10
lines changed

3 files changed

+49
-10
lines changed

‎libraries/USBHOST/src/class/host/tusbh.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747

4848
#define TUSHH_ROOT_CHILD_COUNT 1
49-
#define TUSBH_MAX_CHILD 4
49+
#define TUSBH_MAX_CHILD 10
5050
#define TUSBH_MAX_CONFIG_LENGTH 256
5151
#define TUSBH_MAX_INTERFACE 8
5252
#define TUSBH_MAX_EP 4

‎libraries/WiFi/src/WiFi.cpp‎

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,24 +44,57 @@ int arduino::WiFiClass::begin(const char* ssid, const char *passphrase) {
4444

4545
int arduino::WiFiClass::beginAP(const char* ssid, const char *passphrase, uint8_t channel) {
4646

47-
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
48-
_softAP = WhdSoftAPInterface::get_default_instance();
49-
#endif
47+
#if defined(ARDUINO_PORTENTA_H7_M7) || defined(ARDUINO_PORTENTA_H7_M4)
48+
_softAP = WhdSoftAPInterface::get_default_instance();
49+
#endif
5050

5151
if (_softAP == NULL) {
52-
return WL_AP_FAILED;
52+
return (_currentNetworkStatus = WL_AP_FAILED);
5353
}
5454

5555
ensureDefaultAPNetworkConfiguration();
5656

57+
WhdSoftAPInterface* softAPInterface = static_cast<WhdSoftAPInterface*>(_softAP);
58+
5759
//Set ap ssid, password and channel
58-
static_cast<WhdSoftAPInterface*>(_softAP)->set_network(_ip, _netmask, _gateway);
59-
nsapi_error_t result = static_cast<WhdSoftAPInterface*>(_softAP)->start(ssid, passphrase, NSAPI_SECURITY_WPA2, channel, true /* dhcp server */, NULL, true /* cohexistance */);
60+
softAPInterface->set_network(_ip, _netmask, _gateway);
61+
nsapi_error_t result = softAPInterface->start(ssid, passphrase, NSAPI_SECURITY_WPA2, channel, true /* dhcp server */, NULL, true /* cohexistance */);
6062

63+
nsapi_error_t registrationResult;
64+
softAPInterface->unregister_event_handler();
65+
registrationResult = softAPInterface->register_event_handler(arduino::WiFiClass::handleAPEvents);
66+
67+
if (registrationResult != NSAPI_ERROR_OK) {
68+
return (_currentNetworkStatus = WL_AP_FAILED);
69+
}
70+
6171
_currentNetworkStatus = (result == NSAPI_ERROR_OK && setSSID(ssid)) ? WL_AP_LISTENING : WL_AP_FAILED;
6272
return _currentNetworkStatus;
6373
}
6474

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+
6598
void arduino::WiFiClass::ensureDefaultAPNetworkConfiguration() {
6699
if(_ip == nullptr){
67100
_ip = SocketAddress(DEFAULT_IP_ADDRESS);
@@ -80,10 +113,15 @@ void arduino::WiFiClass::end() {
80113

81114
int arduino::WiFiClass::disconnect() {
82115
if (_softAP != nullptr) {
83-
return static_cast<WhdSoftAPInterface*>(_softAP)->stop();
116+
WhdSoftAPInterface* softAPInterface = static_cast<WhdSoftAPInterface*>(_softAP);
117+
softAPInterface->unregister_event_handler();
118+
_currentNetworkStatus = (softAPInterface->stop() == NSAPI_ERROR_OK ? WL_DISCONNECTED : WL_AP_FAILED);
84119
} else {
85-
return wifi_if->disconnect();
120+
wifi_if->disconnect();
121+
_currentNetworkStatus = WL_DISCONNECTED;
86122
}
123+
124+
return _currentNetworkStatus;
87125
}
88126

89127
void arduino::WiFiClass::config(arduino::IPAddress local_ip){

‎libraries/WiFi/src/WiFi.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,14 @@ class WiFiClass
303303
SocketAddress _dnsServer1 = nullptr;
304304
SocketAddress _dnsServer2 = nullptr;
305305
char* _ssid = nullptr;
306-
wl_status_t _currentNetworkStatus = WL_IDLE_STATUS;
306+
volatilewl_status_t _currentNetworkStatus = WL_IDLE_STATUS;
307307
WiFiInterface* wifi_if = nullptr;
308308
voidPrtFuncPtr _initializerCallback;
309309
WiFiAccessPoint* ap_list = nullptr;
310310
uint8_t connected_ap;
311311
int setSSID(const char* ssid);
312312
void ensureDefaultAPNetworkConfiguration();
313+
static void * handleAPEvents(whd_interface_t ifp, const whd_event_header_t *event_header, const uint8_t *event_data, void *handler_user_data);
313314
bool isVisible(const char* ssid);
314315
arduino::IPAddress ipAddressFromSocketAddress(SocketAddress socketAddress);
315316
SocketAddress socketAddressFromIpAddress(arduino::IPAddress ip, uint16_t port);

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /