Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow WhdAccessPoint scan result with extended parameters
- Add WhdAccessPoint to include additional WHD scan info - To save memory, only move assignment is supported for WhdAccessPoint - Add scan_whd to scan for WhdAccessPoint - Set set_blocking(false) to unsupported by return NSAPI_ERROR_UNSUPPORTED
- Loading branch information
1 parent
1798c24
commit f0084d8
Showing
5 changed files
with
193 additions
and
9 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
features/netsocket/emac-drivers/TARGET_WHD/interface/WhdAccessPoint.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include <cstdlib> | ||
#include <utility> | ||
#include "WhdAccessPoint.h" | ||
|
||
WhdAccessPoint::WhdAccessPoint(nsapi_wifi_ap_t ap, whd_bss_type_t bss_type, uint8_t *ie_ptr, uint32_t ie_len) : | ||
WiFiAccessPoint(ap), _bss_type(bss_type) | ||
{ | ||
_ie_ptr = (uint8_t *)malloc(ie_len * sizeof(uint8_t)); | ||
if (_ie_ptr != NULL) { | ||
_ie_len = ie_len; | ||
memcpy(_ie_ptr, ie_ptr, ie_len * sizeof(uint8_t)); | ||
} | ||
} | ||
|
||
WhdAccessPoint &WhdAccessPoint::operator=(WhdAccessPoint &&rhs) | ||
{ | ||
if (this != &rhs) { | ||
WiFiAccessPoint::operator=(rhs); | ||
_bss_type = rhs._bss_type; | ||
_ie_ptr = rhs._ie_ptr; | ||
_ie_len = rhs._ie_len; | ||
rhs._ie_ptr = NULL; | ||
rhs._ie_len = 0; | ||
} | ||
return *this; | ||
} | ||
|
||
whd_bss_type_t WhdAccessPoint::get_bss_type() const | ||
{ | ||
return _bss_type; | ||
} | ||
|
||
uint8_t *WhdAccessPoint::get_ie_data() const | ||
{ | ||
return _ie_ptr; | ||
} | ||
|
||
uint32_t WhdAccessPoint::get_ie_len() const | ||
{ | ||
return _ie_len; | ||
} | ||
|
||
WhdAccessPoint::~WhdAccessPoint() | ||
{ | ||
if (_ie_ptr != NULL) { | ||
free(_ie_ptr); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
features/netsocket/emac-drivers/TARGET_WHD/interface/WhdAccessPoint.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/* WHD Access Point Interface | ||
* Copyright (c) 2017-2019 ARM Limited | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef WHD_ACCESS_POINT_H | ||
#define WHD_ACCESS_POINT_H | ||
|
||
#include "netsocket/WiFiAccessPoint.h" | ||
#include "whd_types.h" | ||
|
||
/* Enum for scan result type */ | ||
enum scan_result_type { | ||
SRES_TYPE_WIFI_ACCESS_POINT, | ||
SRES_TYPE_WHD_ACCESS_POINT | ||
}; | ||
|
||
/** WhdAccessPoint class | ||
* | ||
* Class that represents a Whd Access Point | ||
* which contains additional Whd specific information | ||
*/ | ||
class WhdAccessPoint : public WiFiAccessPoint { | ||
public: | ||
WhdAccessPoint() : WiFiAccessPoint() {}; | ||
WhdAccessPoint(nsapi_wifi_ap_t ap, whd_bss_type_t bss_type, uint8_t *ie_ptr, uint32_t ie_len); | ||
|
||
/** Define move assignment and prevent copy-assignment | ||
* | ||
* Due to IE element data could have large memory footprint, | ||
* only move assignment is allowed. | ||
*/ | ||
WhdAccessPoint &operator=(WhdAccessPoint &&rhs); | ||
WhdAccessPoint &operator=(const WhdAccessPoint &rhs) = delete; | ||
|
||
/** Get WHD access point's bss type | ||
* | ||
* @return The whd_bss_type_t of the access point | ||
*/ | ||
whd_bss_type_t get_bss_type() const; | ||
|
||
/** Get WHD access point's IE data | ||
* | ||
* @return The pointer to ie data buffer | ||
*/ | ||
uint8_t *get_ie_data() const; | ||
|
||
/** Get WHD access point's IE length | ||
* | ||
* @return The ie data length | ||
*/ | ||
uint32_t get_ie_len() const; | ||
|
||
virtual ~WhdAccessPoint(); | ||
|
||
private: | ||
whd_bss_type_t _bss_type; | ||
uint8_t *_ie_ptr; /**< Pointer to received Beacon/Probe Response IE(Information Element) */ | ||
uint32_t _ie_len; /**< Length of IE(Information Element) */ | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters