mirror of https://github.com/ARMmbed/mbed-os.git
Access Point API
parent
56117a86c8
commit
b934632653
|
|
@ -101,6 +101,9 @@
|
||||||
"REALTEK_RTL8195AM": {
|
"REALTEK_RTL8195AM": {
|
||||||
"tcpip-thread-stacksize": 1600
|
"tcpip-thread-stacksize": 1600
|
||||||
},
|
},
|
||||||
|
"UBLOX_EVK_ODIN_W2": {
|
||||||
|
"pbuf-pool-size" : 10
|
||||||
|
},
|
||||||
"STM": {
|
"STM": {
|
||||||
"mem-size": 25600
|
"mem-size": 25600
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -45,13 +45,14 @@ void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status,
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case cbWLAN_STATUS_CONNECTED:
|
case cbWLAN_STATUS_CONNECTED:
|
||||||
case cbWLAN_STATUS_AP_STA_ADDED:
|
case cbWLAN_STATUS_AP_UP:
|
||||||
linkUp = true;
|
linkUp = true;
|
||||||
break;
|
break;
|
||||||
case cbWLAN_STATUS_STOPPED:
|
case cbWLAN_STATUS_STOPPED:
|
||||||
case cbWLAN_STATUS_ERROR:
|
case cbWLAN_STATUS_ERROR:
|
||||||
case cbWLAN_STATUS_DISCONNECTED:
|
case cbWLAN_STATUS_DISCONNECTED:
|
||||||
case cbWLAN_STATUS_CONNECTION_FAILURE:
|
case cbWLAN_STATUS_CONNECTION_FAILURE:
|
||||||
|
case cbWLAN_STATUS_AP_DOWN:
|
||||||
break;
|
break;
|
||||||
case cbWLAN_STATUS_CONNECTING:
|
case cbWLAN_STATUS_CONNECTING:
|
||||||
default:
|
default:
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
|
@ -19,7 +19,7 @@
|
||||||
|
|
||||||
#include "WiFiInterface.h"
|
#include "WiFiInterface.h"
|
||||||
#ifdef DEVICE_WIFI_AP
|
#ifdef DEVICE_WIFI_AP
|
||||||
#include "WiFiSoftAPInterface.h"
|
#include "UbloxWiFiSoftAPInterface.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbed.h"
|
#include "mbed.h"
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include "rtos.h"
|
#include "rtos.h"
|
||||||
#include "cb_wlan.h"
|
#include "cb_wlan.h"
|
||||||
|
#include "wifi_emac.h"
|
||||||
|
|
||||||
#define ODIN_WIFI_MAX_MAC_ADDR_STR (18)
|
#define ODIN_WIFI_MAX_MAC_ADDR_STR (18)
|
||||||
#define ODIN_WIFI_SCAN_CACHE_SIZE (5)
|
#define ODIN_WIFI_SCAN_CACHE_SIZE (5)
|
||||||
|
|
@ -45,16 +46,18 @@ struct wlan_scan_indication_s;
|
||||||
/** OdinWiFiInterface class
|
/** OdinWiFiInterface class
|
||||||
* Implementation of the WiFiInterface for the ODIN-W2 module
|
* Implementation of the WiFiInterface for the ODIN-W2 module
|
||||||
*/
|
*/
|
||||||
|
#ifdef DEVICE_WIFI_AP
|
||||||
|
class OdinWiFiInterface : public WiFiInterface, public UbloxWiFiSoftAPInterface, public EMACInterface
|
||||||
|
#else
|
||||||
class OdinWiFiInterface : public WiFiInterface, public EMACInterface
|
class OdinWiFiInterface : public WiFiInterface, public EMACInterface
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** OdinWiFiInterface lifetime
|
/** OdinWiFiInterface lifetime
|
||||||
*/
|
*/
|
||||||
OdinWiFiInterface();
|
OdinWiFiInterface(OdinWiFiEMAC &emac = OdinWiFiEMAC::get_instance(), OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
||||||
|
|
||||||
OdinWiFiInterface(bool debug);
|
OdinWiFiInterface(bool debug, OdinWiFiEMAC &emac = OdinWiFiEMAC::get_instance(), OnboardNetworkStack &stack = OnboardNetworkStack::get_default_instance());
|
||||||
|
|
||||||
~OdinWiFiInterface();
|
~OdinWiFiInterface();
|
||||||
|
|
||||||
|
|
@ -138,6 +141,100 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual nsapi_error_t set_timeout(int ms);
|
virtual nsapi_error_t set_timeout(int ms);
|
||||||
|
|
||||||
|
#ifdef DEVICE_WIFI_AP
|
||||||
|
|
||||||
|
/** Set IP config for access point
|
||||||
|
*
|
||||||
|
* This function has to be called before the access point is started.
|
||||||
|
*
|
||||||
|
* @param gateway Null-terminated representation of the local gateway
|
||||||
|
* @param netmask Null-terminated representation of the network mask
|
||||||
|
* @return 0 on success, negative error code on failure
|
||||||
|
*/
|
||||||
|
//TODO: In previous WiFiInterface.h but not in new UbloxWiFiSoftAPInterface
|
||||||
|
virtual nsapi_error_t set_ap_network(const char *ip_address, const char *netmask, const char *gateway);
|
||||||
|
|
||||||
|
/** Set the WiFi network credentials
|
||||||
|
*
|
||||||
|
* @param ssid Name of the network to connect to
|
||||||
|
* @param pass Security passphrase to connect to the network
|
||||||
|
* @param security Type of encryption for connection
|
||||||
|
* (defaults to NSAPI_SECURITY_NONE)
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_credentials(const char *ssid, const char *pass = 0,
|
||||||
|
nsapi_security_t security = NSAPI_SECURITY_NONE);
|
||||||
|
|
||||||
|
/** Set the WiFi network channel
|
||||||
|
*
|
||||||
|
* @param channel Channel on which the connection is to be made.
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_channel(uint8_t channel);
|
||||||
|
|
||||||
|
/** Gets the current number of active connections
|
||||||
|
*
|
||||||
|
* @return number of active connections
|
||||||
|
*/
|
||||||
|
virtual int get_ap_connection_count();
|
||||||
|
|
||||||
|
/** Gets the max supported number of active connections
|
||||||
|
*
|
||||||
|
* @return maximum number of active connections
|
||||||
|
*/
|
||||||
|
virtual int get_ap_max_connection_count();
|
||||||
|
|
||||||
|
/** Enable or disable DHCP on the network access point
|
||||||
|
*
|
||||||
|
* Enables DHCP in SoftAP mode. Defaults to enabled unless
|
||||||
|
* a static IP address has been assigned. Requires that the network is
|
||||||
|
* service stopped.
|
||||||
|
*
|
||||||
|
* @param dhcp True to enable DHCP
|
||||||
|
* @return 0 on success, negative error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_dhcp(bool dhcp);
|
||||||
|
|
||||||
|
/** Set the beacon interval.
|
||||||
|
*
|
||||||
|
* Note that the value needs to be set before ap_start in order to take effect.
|
||||||
|
*
|
||||||
|
* @param interval Beason interval in time units (Default: 100 time units = 102.4 ms)
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_beacon_interval(uint16_t interval);
|
||||||
|
|
||||||
|
/** Start the interface
|
||||||
|
*
|
||||||
|
* Attempts to serve a WiFi network.
|
||||||
|
*
|
||||||
|
* @param ssid Name of the network to connect to
|
||||||
|
* @param pass Security passphrase to connect to the network
|
||||||
|
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
|
||||||
|
* @param channel Channel on which the connection is to be made.
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_start(const char *ssid, const char *pass = 0,
|
||||||
|
nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0);
|
||||||
|
|
||||||
|
/** Start the interface
|
||||||
|
*
|
||||||
|
* Attempts to serve a WiFi network. Requires ssid to be set.
|
||||||
|
* passphrase is optional.
|
||||||
|
* If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_start();
|
||||||
|
|
||||||
|
/** Stop the interface
|
||||||
|
*
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_stop();
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
enum OdinWifiState {
|
enum OdinWifiState {
|
||||||
|
|
@ -151,7 +248,6 @@ private:
|
||||||
S_STA_CONNECTED,
|
S_STA_CONNECTED,
|
||||||
S_STA_DISCONNECTED_WAIT_CONNECT,
|
S_STA_DISCONNECTED_WAIT_CONNECT,
|
||||||
S_STA_CONNECTION_FAIL_WAIT_DISCONNECT,
|
S_STA_CONNECTION_FAIL_WAIT_DISCONNECT,
|
||||||
//S_STA_LINK_LOSS_WAIT_DISCONNECT,
|
|
||||||
S_STA_WAIT_DISCONNECT,
|
S_STA_WAIT_DISCONNECT,
|
||||||
|
|
||||||
S_AP_IDLE,
|
S_AP_IDLE,
|
||||||
|
|
@ -199,7 +295,6 @@ private:
|
||||||
OdinWifiState entry_connect_fail_wait_disconnect();
|
OdinWifiState entry_connect_fail_wait_disconnect();
|
||||||
OdinWifiState entry_wait_connect();
|
OdinWifiState entry_wait_connect();
|
||||||
OdinWifiState entry_wait_disconnect();
|
OdinWifiState entry_wait_disconnect();
|
||||||
//OdinWifiState entry_link_loss_wait_disconnect(void);
|
|
||||||
OdinWifiState entry_ap_wait_start();
|
OdinWifiState entry_ap_wait_start();
|
||||||
OdinWifiState entry_ap_started();
|
OdinWifiState entry_ap_started();
|
||||||
OdinWifiState entry_ap_wait_stop();
|
OdinWifiState entry_ap_wait_stop();
|
||||||
|
|
@ -278,7 +373,6 @@ private:
|
||||||
Queue<odin_wifi_msg_s, 1> _cache_queue;
|
Queue<odin_wifi_msg_s, 1> _cache_queue;
|
||||||
MemoryPool<odin_wifi_msg_s, 7> *_msg_pool;
|
MemoryPool<odin_wifi_msg_s, 7> *_msg_pool;
|
||||||
Thread _thread;
|
Thread _thread;
|
||||||
//Timeout _timeout; //Randomly lost interrupts/callbacks; replaced by Timer
|
|
||||||
Timer _timer;
|
Timer _timer;
|
||||||
|
|
||||||
bool _debug;
|
bool _debug;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,108 @@
|
||||||
|
|
||||||
|
/* UbloxWiFiSoftAPInterface
|
||||||
|
* 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 UBLOX_WIFI_SOFTAPINTERFACE_H
|
||||||
|
#define UBLOX_WIFI_SOFTAPINTERFACE_H
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
#include "netsocket/WiFiAccessPoint.h"
|
||||||
|
|
||||||
|
/** UbloxWiFiSoftAPInterface class
|
||||||
|
*
|
||||||
|
* Common interface that is shared between WiFi devices supporting SoftAP mode
|
||||||
|
*/
|
||||||
|
class UbloxWiFiSoftAPInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/** UbloxWiFiSoftAPInterface lifetime
|
||||||
|
*/
|
||||||
|
virtual ~UbloxWiFiSoftAPInterface() {};
|
||||||
|
|
||||||
|
/** Set the WiFi network credentials
|
||||||
|
*
|
||||||
|
* @param ssid Name of the network to connect to
|
||||||
|
* @param pass Security passphrase to connect to the network
|
||||||
|
* @param security Type of encryption for connection
|
||||||
|
* (defaults to NSAPI_SECURITY_NONE)
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_credentials(const char *ssid, const char *pass = 0,
|
||||||
|
nsapi_security_t security = NSAPI_SECURITY_NONE) = 0;
|
||||||
|
|
||||||
|
/** Set the WiFi network channel
|
||||||
|
*
|
||||||
|
* @param channel Channel on which the connection is to be made, or 0 for any (Default: 0)
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_channel(uint8_t channel) = 0;
|
||||||
|
|
||||||
|
/** Gets the current number of active connections
|
||||||
|
*
|
||||||
|
* @return number of active connections
|
||||||
|
*/
|
||||||
|
virtual int get_ap_connection_count() = 0;
|
||||||
|
|
||||||
|
/** Gets the max supported number of active connections
|
||||||
|
*
|
||||||
|
* @return maximum number of active connections
|
||||||
|
*/
|
||||||
|
virtual int get_ap_max_connection_count() = 0;
|
||||||
|
|
||||||
|
/** Enable or disable DHCP on the network access point
|
||||||
|
*
|
||||||
|
* Enables DHCP in SoftAP mode. Defaults to enabled unless
|
||||||
|
* a static IP address has been assigned. Requires that the network is
|
||||||
|
* service stopped.
|
||||||
|
*
|
||||||
|
* @param dhcp True to enable DHCP
|
||||||
|
* @return 0 on success, negative error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t set_ap_dhcp(bool dhcp) = 0;
|
||||||
|
|
||||||
|
/** Start the interface
|
||||||
|
*
|
||||||
|
* Attempts to serve a WiFi network.
|
||||||
|
*
|
||||||
|
* @param ssid Name of the network to connect to
|
||||||
|
* @param pass Security passphrase to connect to the network
|
||||||
|
* @param security Type of encryption for connection (Default: NSAPI_SECURITY_NONE)
|
||||||
|
* @param channel Channel on which the connection is to be made.
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_start(const char *ssid, const char *pass = 0,
|
||||||
|
nsapi_security_t security = NSAPI_SECURITY_NONE, uint8_t channel = 0) = 0;
|
||||||
|
|
||||||
|
/** Start the interface
|
||||||
|
*
|
||||||
|
* Attempts to serve a WiFi network. Requires ssid to be set.
|
||||||
|
* passphrase is optional.
|
||||||
|
* If passphrase is invalid, NSAPI_ERROR_AUTH_ERROR is returned.
|
||||||
|
*
|
||||||
|
* @return 0 on success, negative error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_start() = 0;
|
||||||
|
|
||||||
|
/** Stop the interface
|
||||||
|
*
|
||||||
|
* @return 0 on success, or error code on failure
|
||||||
|
*/
|
||||||
|
virtual nsapi_error_t ap_stop() = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
@ -295,7 +295,9 @@ typedef enum {
|
||||||
* @ingroup wlan
|
* @ingroup wlan
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
cbWLAN_IOCTL_FIRST
|
cbWLAN_IOCTL_FIRST = 0,
|
||||||
|
cbWLAN_IOCTL_SET_AP_BEACON_INTERVAL = 9, //!< Beacon period in TUs
|
||||||
|
cbWLAN_IOCTL_GET_AP_BEACON_INTERVAL = 10, //!< Beacon period in TUs
|
||||||
} cbWLAN_Ioctl;
|
} cbWLAN_Ioctl;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue