mirror of https://github.com/ARMmbed/mbed-os.git
wifi - Moved wifi_ap_t into its own class WiFiAccessPoint
Using a class for this structure is more idiomatic C++, allows future deprecations, and more flexibility of the internal structure. Additionally, this matches to design of the SocketAddress class specific to the network-socket api.pull/3975/head
parent
5b12539074
commit
0f40c121d5
|
@ -0,0 +1,37 @@
|
||||||
|
#include "network-socket/WiFiAccessPoint.h"
|
||||||
|
|
||||||
|
WiFiAccessPoint::WiFiAccessPoint()
|
||||||
|
{
|
||||||
|
memset(&_ap, 0, sizeof(_ap));
|
||||||
|
}
|
||||||
|
|
||||||
|
WiFiAccessPoint::WiFiAccessPoint(nsapi_wifi_ap_t ap)
|
||||||
|
{
|
||||||
|
_ap = ap;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *WiFiAccessPoint::get_ssid() const
|
||||||
|
{
|
||||||
|
return _ap.ssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t *WiFiAccessPoint::get_bssid() const
|
||||||
|
{
|
||||||
|
return _ap.bssid;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsapi_security_t WiFiAccessPoint::get_security() const
|
||||||
|
{
|
||||||
|
return _ap.security;
|
||||||
|
}
|
||||||
|
|
||||||
|
int8_t WiFiAccessPoint::get_rssi() const
|
||||||
|
{
|
||||||
|
return _ap.rssi;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t WiFiAccessPoint::get_channel() const
|
||||||
|
{
|
||||||
|
return _ap.channel;
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,70 @@
|
||||||
|
/* WiFiInterface
|
||||||
|
* Copyright (c) 2015 - 2016 ARM Limited
|
||||||
|
*
|
||||||
|
* 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 WIFI_ACCESS_POINT_H
|
||||||
|
#define WIFI_ACCESS_POINT_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "network-socket/nsapi_types.h"
|
||||||
|
|
||||||
|
/** WiFiAccessPoint class
|
||||||
|
*
|
||||||
|
* Class that represents a WiFi Access Point
|
||||||
|
* Common interface that is shared between WiFi devices
|
||||||
|
*/
|
||||||
|
class WiFiAccessPoint
|
||||||
|
{
|
||||||
|
/** WiFiAccessPoint lifetime
|
||||||
|
*/
|
||||||
|
WiFiAccessPoint();
|
||||||
|
WiFiAccessPoint(nsapi_wifi_ap_t ap);
|
||||||
|
|
||||||
|
/** Get an access point's ssid
|
||||||
|
*
|
||||||
|
* @return The ssid of the access point
|
||||||
|
*/
|
||||||
|
const char *get_ssid() const;
|
||||||
|
|
||||||
|
/** Get an access point's bssid
|
||||||
|
*
|
||||||
|
* @return The bssid of the access point
|
||||||
|
*/
|
||||||
|
const uint8_t *get_bssid() const;
|
||||||
|
|
||||||
|
/** Get an access point's security
|
||||||
|
*
|
||||||
|
* @return The security type of the access point
|
||||||
|
*/
|
||||||
|
nsapi_security_t get_security() const;
|
||||||
|
|
||||||
|
/** Gets the radio signal strength for the access point
|
||||||
|
*
|
||||||
|
* @return Connection strength in dBm (negative value),
|
||||||
|
* or 0 if measurement impossible
|
||||||
|
*/
|
||||||
|
int8_t get_rssi() const;
|
||||||
|
|
||||||
|
/** Get the access point's channel
|
||||||
|
*
|
||||||
|
* @return The channel of the access point
|
||||||
|
*/
|
||||||
|
uint8_t get_channel() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
nsapi_wifi_ap_t _ap;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -20,7 +20,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "Callback.h"
|
#include "Callback.h"
|
||||||
#include "network-socket/NetworkInterface.h"
|
#include "network-socket/NetworkInterface.h"
|
||||||
#include "nsapi.h"
|
#include "network-socket/WiFiAccessPoint.h"
|
||||||
|
|
||||||
/** WiFiInterface class
|
/** WiFiInterface class
|
||||||
*
|
*
|
||||||
|
@ -29,14 +29,6 @@
|
||||||
class WiFiInterface: public NetworkInterface
|
class WiFiInterface: public NetworkInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef struct wifi_ap {
|
|
||||||
char ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
|
|
||||||
uint8_t bssid[6];
|
|
||||||
nsapi_security_t security;
|
|
||||||
int8_t rssi;
|
|
||||||
uint8_t channel;
|
|
||||||
} wifi_ap_t;
|
|
||||||
|
|
||||||
/** WiFiInterface lifetime
|
/** WiFiInterface lifetime
|
||||||
*/
|
*/
|
||||||
virtual ~WiFiInterface() {};
|
virtual ~WiFiInterface() {};
|
||||||
|
@ -107,7 +99,7 @@ public:
|
||||||
* @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
|
* @return Number of entries in @a, or if @a count was 0 number of available networks, negative on error
|
||||||
* see @a nsapi_error
|
* see @a nsapi_error
|
||||||
*/
|
*/
|
||||||
virtual int scan(wifi_ap_t *res, unsigned count) = 0;
|
virtual int scan(WiFiAccessPoint *res, unsigned count) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
|
|
||||||
// entry point for C++ api
|
// entry point for C++ api
|
||||||
#include "network-socket/SocketAddress.h"
|
#include "network-socket/SocketAddress.h"
|
||||||
|
#include "network-socket/WiFiAccessPoint.h"
|
||||||
#include "network-socket/NetworkStack.h"
|
#include "network-socket/NetworkStack.h"
|
||||||
|
|
||||||
#include "network-socket/NetworkInterface.h"
|
#include "network-socket/NetworkInterface.h"
|
||||||
|
|
|
@ -163,6 +163,18 @@ typedef enum nsapi_option {
|
||||||
NSAPI_RCVBUF, /*!< Sets recv buffer size */
|
NSAPI_RCVBUF, /*!< Sets recv buffer size */
|
||||||
} nsapi_option_t;
|
} nsapi_option_t;
|
||||||
|
|
||||||
|
/** nsapi_wifi_ap structure
|
||||||
|
*
|
||||||
|
* Structure representing a WiFi Access Point
|
||||||
|
*/
|
||||||
|
typedef struct nsapi_wifi_ap {
|
||||||
|
char ssid[33]; /* 32 is what 802.11 defines as longest possible name; +1 for the \0 */
|
||||||
|
uint8_t bssid[6];
|
||||||
|
nsapi_security_t security;
|
||||||
|
int8_t rssi;
|
||||||
|
uint8_t channel;
|
||||||
|
} nsapi_wifi_ap_t;
|
||||||
|
|
||||||
|
|
||||||
/** nsapi_stack structure
|
/** nsapi_stack structure
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue