EMAC adaption added, updated ODIN drivers to v2.5.0 RC1

pull/6847/head
Asif Rizwan 2018-05-15 18:22:51 +05:00 committed by Kevin Bracey
parent 91531a2aaa
commit 0b14f1277e
26 changed files with 1833 additions and 621 deletions

View File

@ -587,6 +587,11 @@ nsapi_error_t LWIP::Interface::bringdown()
#if LWIP_IPV6
mbed_lwip_clear_ipv6_addresses(&netif);
#endif
#if LWIP_IPV4
ip_addr_set_zero(&(netif.ip_addr));
ip_addr_set_zero(&(netif.netmask));
ip_addr_set_zero(&(netif.gw));
#endif
osSemaphoreDelete(has_any_addr);
osSemaphoreAttr_t attr;

View File

@ -18,11 +18,28 @@
#include "lwip/debug.h"
#include "lwip/def.h"
#include "lwip_random.h"
#if defined(DEVICE_TRNG)
#include "hal/trng_api.h"
#endif
#include "randLIB.h"
void lwip_seed_random(void)
{
#if defined(DEVICE_TRNG)
uint32_t result;
size_t olen;
trng_t trng_obj;
trng_init(&trng_obj);
trng_get_bytes(&trng_obj, (uint8_t*)&result, sizeof result, &olen);
trng_free(&trng_obj);
srand(result);
#else
randLIB_seed_random();
#endif
}
void lwip_add_random_seed(uint64_t seed)

View File

@ -0,0 +1,304 @@
#if DEVICE_WIFI
#include "mbed_interface.h"
#include "mbed_assert.h"
#include "netsocket/nsapi_types.h"
#include "wifi_emac.h"
#include "cb_wlan_target_data.h"
#include "cb_wlan_types.h"
#include "cb_wlan.h"
#include "cb_otp.h"
#include "cb_main.h"
#define WIFI_EMAC_MTU_SIZE (1500U)
static const char _ifname[] = "WL0";
cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame);
cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame);
cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size);
void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame);
cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame);
cb_uint8 handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame);
void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
void send_wlan_packet(void *buf);
static const cbWLANTARGET_Callback _wlanTargetCallback =
{
handleWlanTargetCopyFromDataFrame,
handleWlanTargetCopyToDataFrame,
handleWlanTargetAllocDataFrame,
handleWlanTargetFreeDataFrame,
handleWlanTargetGetDataFrameSize,
handleWlanTargetGetDataFrameTID
};
void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data)
{
WIFI_EMAC &instance = WIFI_EMAC::get_instance();
bool linkUp = false;
bool sendCb = true;
(void)dummy;
(void)data;
switch (status) {
case cbWLAN_STATUS_CONNECTED:
case cbWLAN_STATUS_AP_STA_ADDED:
linkUp = true;
break;
case cbWLAN_STATUS_STOPPED:
case cbWLAN_STATUS_ERROR:
case cbWLAN_STATUS_DISCONNECTED:
case cbWLAN_STATUS_CONNECTION_FAILURE:
break;
case cbWLAN_STATUS_CONNECTING:
default:
sendCb = false;
break;
}
if (sendCb && instance.emac_link_state_cb) {
instance.emac_link_state_cb(linkUp);
}
}
void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo)
{
WIFI_EMAC &instance = WIFI_EMAC::get_instance();
(void)dummy;
if (instance.emac_link_input_cb) {
instance.emac_link_input_cb((void*)packetInfo->rxData);
}
}
cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
//emac_mem_buf_t* phead = (emac_mem_buf_t *)frame;
emac_mem_buf_t* pbuf = (emac_mem_buf_t *)frame;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
//pbuf = mem->get_next(phead);
while (pbuf != NULL) {
if ((pbufOffset + mem->get_len(pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, mem->get_len(pbuf) - (offsetInFrame - pbufOffset));
memcpy(buffer, (int8_t *)mem->get_ptr(pbuf) + (offsetInFrame - pbufOffset), copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = mem->get_next(pbuf);
break;
}
pbufOffset += mem->get_len(pbuf);
pbuf = mem->get_next(pbuf);
}
while (pbuf != NULL && bytesCopied < size) {
copySize = cb_MIN(mem->get_len(pbuf), size - bytesCopied);
memcpy(buffer, mem->get_ptr(pbuf), copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = mem->get_next(pbuf);
}
MBED_ASSERT(bytesCopied <= size);
return (bytesCopied == size);
}
cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
//emac_mem_buf_t* phead = (emac_mem_buf_t *)frame;
emac_mem_buf_t* pbuf = (emac_mem_buf_t *)frame;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
//pbuf = mem->get_next(phead);
while (pbuf != NULL) {
if ((pbufOffset + mem->get_len(pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, mem->get_len(pbuf) - (offsetInFrame - pbufOffset));
memcpy((uint8_t *)mem->get_ptr(pbuf) + (offsetInFrame - pbufOffset), buffer, copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = mem->get_next(pbuf);
break;
}
pbufOffset += mem->get_len(pbuf);
pbuf = mem->get_next(pbuf);
}
while (pbuf != NULL && bytesCopied < size) {
copySize = cb_MIN(mem->get_len(pbuf), size - bytesCopied);
memcpy(mem->get_ptr(pbuf), buffer, copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = mem->get_next(pbuf);
}
MBED_ASSERT(bytesCopied <= size);
return (bytesCopied == size);
}
cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
return (cbWLANTARGET_dataFrame*)mem->alloc_pool(size,0);
}
void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
mem->free((emac_mem_buf_t*)frame);
}
uint32_t handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
MBED_ASSERT(mem != NULL);
return mem->get_total_len((emac_mem_buf_t*)frame);
}
uint8_t handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame)
{
(void)frame;
return (uint8_t)cbWLAN_AC_BE;
}
WIFI_EMAC::WIFI_EMAC()
{
emac_link_input_cb = NULL;
emac_link_state_cb = NULL;
cbWLANTARGET_registerCallbacks((cbWLANTARGET_Callback*)&_wlanTargetCallback);
}
void send_wlan_packet(void *buf)
{
cbWLAN_sendPacket(buf);
}
bool WIFI_EMAC::link_out(emac_mem_buf_t *buf)
{
EMACMemoryManager *mem = WIFI_EMAC::get_instance().memory_manager;
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
emac_mem_buf_t *new_buf = mem->alloc_pool(mem->get_total_len(buf), 0);
if (new_buf != NULL) {
mem->copy(new_buf, buf);
int id = cbMAIN_getEventQueue()->call(send_wlan_packet, new_buf);
if (id != 0) {
cbMAIN_dispatchEventQueue();
} else {
mem->free(new_buf);
}
}
mem->free(buf);
return true;
}
bool WIFI_EMAC::power_up()
{
/* Initialize the hardware */
/* No-op at this stage */
return true;
}
uint32_t WIFI_EMAC::get_mtu_size() const
{
return WIFI_EMAC_MTU_SIZE;
}
void WIFI_EMAC::get_ifname(char *name, uint8_t size) const
{
memcpy(name, _ifname, (size < sizeof(_ifname)) ? size : sizeof(_ifname));
}
uint8_t WIFI_EMAC::get_hwaddr_size() const
{
return sizeof(cbWLAN_MACAddress);
}
bool WIFI_EMAC::get_hwaddr(uint8_t *addr) const
{
cbOTP_read(cbOTP_MAC_WLAN, sizeof(cbWLAN_MACAddress), addr);
return true;
}
void WIFI_EMAC::set_hwaddr(const uint8_t *addr)
{
/* No-op at this stage */
}
void WIFI_EMAC::set_link_input_cb(emac_link_input_cb_t input_cb)
{
emac_link_input_cb = input_cb;
cbMAIN_driverLock();
cbWLAN_registerPacketIndicationCallback(handleWlanPacketIndication, NULL);
cbMAIN_driverUnlock();
}
void WIFI_EMAC::set_link_state_cb(emac_link_state_change_cb_t state_cb)
{
emac_link_state_cb = state_cb;
cbMAIN_driverLock();
cbWLAN_registerStatusCallback(handleWlanStatusIndication, NULL);
cbMAIN_driverUnlock();
}
void WIFI_EMAC::power_down()
{
/* No-op at this stage */
}
void WIFI_EMAC::set_memory_manager(EMACMemoryManager &mem_mngr)
{
memory_manager = &mem_mngr;
}
uint32_t WIFI_EMAC::get_align_preference() const
{
return 1; // TODO not sure if there is a requirement but don't think so
}
void WIFI_EMAC::add_multicast_group(const uint8_t *address)
{
// TODO anything to do here for WiFi?
}
void WIFI_EMAC::remove_multicast_group(const uint8_t *address)
{
// TODO anything to do here for WiFi?
}
void WIFI_EMAC::set_all_multicast(bool all)
{
// TODO anything to do here for WiFi?
}
WIFI_EMAC &WIFI_EMAC::get_instance() {
static WIFI_EMAC emac;
return emac;
}
// Weak so a module can override
MBED_WEAK EMAC &EMAC::get_default_instance()
{
return WIFI_EMAC::get_instance();
}
#endif // DEVICE_WIFI

View File

@ -0,0 +1,132 @@
/*
* Copyright (c) 2017 ARM Limited. All rights reserved.
*/
#ifndef WIFI_EMAC_H_
#define WIFI_EMAC_H_
#include "EMAC.h"
#include "cb_wlan_target_data.h"
#include "cb_wlan.h"
class WIFI_EMAC : public EMAC {
public:
WIFI_EMAC();
static WIFI_EMAC &get_instance();
/**
* Return maximum transmission unit
*
* @return MTU in bytes
*/
virtual uint32_t get_mtu_size() const;
/**
* Return interface name
*
* @param name Pointer to where the name should be written
* @param size Maximum number of character to copy
*/
virtual void get_ifname(char *name, uint8_t size) const;
/**
* Returns size of the underlying interface HW address size.
*
* @return HW address size in bytes
*/
virtual uint8_t get_hwaddr_size() const;
/**
* Return interface-supplied HW address
*
* Copies HW address to provided memory, @param addr has to be of correct size see @a get_hwaddr_size
*
* HW address need not be provided if this interface does not have its own HW
* address configuration; stack will choose address from central system
* configuration if the function returns false and does not write to addr.
*
* @param addr HW address for underlying interface
* @return true if HW address is available
*/
virtual bool get_hwaddr(uint8_t *addr) const;
/**
* Set HW address for interface
*
* Provided address has to be of correct size, see @a get_hwaddr_size
*
* Called to set the MAC address to actually use - if @a get_hwaddr is provided
* the stack would normally use that, but it could be overridden, eg for test
* purposes.
*
* @param addr Address to be set
*/
virtual void set_hwaddr(const uint8_t *addr);
/**
* Sends the packet over the link
*
* That can not be called from an interrupt context.
*
* @param buf Packet to be send
* @return True if the packet was send successfully, False otherwise
*/
virtual bool link_out(emac_mem_buf_t *buf);
/**
* Initializes the HW
*
* @return True on success, False in case of an error.
*/
virtual bool power_up();
/**
* Deinitializes the HW
*
*/
virtual void power_down();
/**
* Sets a callback that needs to be called for packets received for that interface
*
* @param input_cb Function to be register as a callback
*/
virtual void set_link_input_cb(emac_link_input_cb_t input_cb);
/**
* Sets a callback that needs to be called on link status changes for given interface
*
* @param state_cb Function to be register as a callback
*/
virtual void set_link_state_cb(emac_link_state_change_cb_t state_cb);
/** Sets memory manager that is used to handle memory buffers
*
* @param mem_mngr Pointer to memory manager
*/
virtual void set_memory_manager(EMACMemoryManager &mem_mngr);
virtual uint32_t get_align_preference() const;
virtual void add_multicast_group(const uint8_t *address);
virtual void remove_multicast_group(const uint8_t *address);
virtual void set_all_multicast(bool all);
private:
emac_link_input_cb_t emac_link_input_cb; /**< Callback for incoming data */
emac_link_state_change_cb_t emac_link_state_cb; /**< Link state change callback */
EMACMemoryManager *memory_manager;
friend cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame);
friend cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame);
friend cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size);
friend void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame);
friend cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame);
friend void handleWlanStatusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
friend void handleWlanPacketIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
friend void send_wlan_packet(void *buf);
};
#endif /* WIFI_EMAC_H_ */

View File

@ -18,10 +18,13 @@
#define ODIN_WIFI_INTERFACE_H
#include "WiFiInterface.h"
#include "emac_api.h"
#ifdef DEVICE_WIFI_AP
#include "WiFiSoftAPInterface.h"
#endif
#include "mbed.h"
#include "netsocket/WiFiAccessPoint.h"
#include "netsocket/EMACInterface.h"
#include "nsapi_types.h"
#include "lwip/netif.h"
#include "rtos.h"
@ -42,7 +45,11 @@ struct wlan_scan_indication_s;
/** OdinWiFiInterface class
* Implementation of the WiFiInterface for the ODIN-W2 module
*/
class OdinWiFiInterface : public WiFiInterface
#ifdef DEVICE_WIFI_AP
class OdinWiFiInterface : public WiFiInterface, public WiFiSoftAPInterface, public EMACInterface
#else
class OdinWiFiInterface : public WiFiInterface, public EMACInterface
#endif
{
public:
/** OdinWiFiInterface lifetime
@ -101,61 +108,8 @@ public:
*/
virtual nsapi_error_t disconnect();
/** Get the local MAC address
*
* Provided MAC address is intended for info or debug purposes and
* may not be provided if the underlying network interface does not
* provide a MAC address
*
* @return Null-terminated representation of the local MAC address
* or null if no MAC address is available
*/
virtual const char *get_mac_address();
/** Get the local IP address
*
* @return Null-terminated representation of the local IP address
* or null if no IP address has been recieved
*/
virtual const char *get_ip_address();
/** Get the local network mask
*
* @return Null-terminated representation of the local network mask
* or null if no network mask has been received
*/
virtual const char *get_netmask();
/** Get the local gateway
*
* @return Null-terminated representation of the local gateway
* or null if no network mask has been recieved
*/
virtual const char *get_gateway();
/** Set a static IP address
*
* Configures this network interface to use a static IP address.
* Implicitly disables DHCP, which can be enabled in set_dhcp.
* Requires that the network is disconnected.
*
* @param address Null-terminated representation of the local IP address
* @param netmask Null-terminated representation of the local network mask
* @param gateway Null-terminated representation of the local gateway
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_network(const char *ip_address, const char *netmask, const char *gateway);
/** Enable or disable DHCP on the network
*
* Enables DHCP on connecting the network. Defaults to enabled unless
* a static IP address has been assigned. Requires that the network is
* disconnected.
*
* @param dhcp True to enable DHCP
* @return 0 on success, negative error code on failure
*/
virtual nsapi_error_t set_dhcp(bool dhcp);
/** Gets the current radio signal strength for active connection
*
@ -186,9 +140,99 @@ public:
*/
virtual nsapi_error_t set_timeout(int ms);
virtual NetworkStack *get_stack();
#ifdef DEVICE_WIFI_AP
protected:
/** 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 WiFiSoftAPInterface
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, 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);
/** 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, or 0 for any (Default: 0)
* @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:
@ -222,11 +266,7 @@ private:
const char *passwd;
nsapi_security_t security;
uint8_t channel;
bool use_dhcp;
int timeout_ms;
char ip_address[IPADDR_STRLEN_MAX];
char netmask[IPADDR_STRLEN_MAX];
char gateway[IPADDR_STRLEN_MAX];
};
struct ap_s {
@ -243,6 +283,7 @@ private:
int cnt_connected;
nsapi_error_t error_code;
uint16_t beacon_interval;
};
struct scan_cache_s {
@ -296,7 +337,8 @@ private:
const char *ssid,
const char *pass,
nsapi_security_t security,
uint8_t channel);
uint8_t channel,
uint16_t beacon_interval);
void timeout_user_connect();
void update_scan_list(cbWLAN_ScanIndicationInfo *scan_info);
@ -305,7 +347,6 @@ private:
void wlan_scan_indication(cbWLAN_ScanIndicationInfo *scan_info, cb_boolean is_last_result);
static bool _wlan_initialized; // Controls that cbWLAN is initiated only once
static emac_interface_t* _emac; // Not possible to remove added interfaces to the network stack => static and re-use
static int32_t _target_id;
OdinWifiState _state;
@ -314,7 +355,6 @@ private:
struct sta_s _sta;
struct ap_s _ap;
nsapi_stack_t _stack;
char _mac_addr_str[ODIN_WIFI_MAX_MAC_ADDR_STR];
cbWLAN_StatusConnectedInfo _wlan_status_connected_info;

View File

@ -36,7 +36,8 @@
#define SIZE_OF_BD_ADDR (6)
#define SIZE_OF_COD (3)
#define SIZE_OF_LINK_KEY (16)
#define SIZE_OF_NAME (248)
#define SIZE_OF_NAME_INCOMING (248)
#define SIZE_OF_NAME_OUTGOING (64)
#define SIZE_OF_PIN_CODE ((cb_uint8)16)
#define SIZE_OF_LAP (3)
#define SIZE_OF_AFH_LMP_HCI_CHANNEL_MAP (10)
@ -150,10 +151,16 @@ typedef struct
typedef struct
{
cb_uint8 Name[SIZE_OF_NAME];
cb_uint8 Name[SIZE_OF_NAME_INCOMING];
} TName;
typedef struct
{
cb_uint8 Name[SIZE_OF_NAME_OUTGOING];
} TNameOutgoing;
typedef struct
{
cb_uint8 PinCode[SIZE_OF_PIN_CODE];

View File

@ -120,6 +120,8 @@ typedef enum
typedef struct
{
TBdAddr address;
TNameOutgoing remoteName;
cb_int8 remoteRssi;
cbBCM_ConnectionType type;
TConnHandle aclHandle;
TBluetoothType btType;
@ -129,17 +131,6 @@ typedef struct
cb_char serviceName[cbBCM_SERVICE_NAME_MAX_LEN];
} cbBCM_ConnectionInfo;
typedef struct
{
cb_uint8 flags; /** Reserved for future use. */
cb_uint8 flowDirection; /** 0x00 for Outgoing Flow and 0x01 for Incoming Flow */
cb_uint8 serviceType; /** 0x00 No Traffic; 0x01 Best Effort; 0x02 Guaranteed */
cb_uint32 tokenRate; /** Token Rate in octets per second */
cb_uint32 tokenBucketSize; /** Token Bucket Size in octets */
cb_uint32 peakBandwidth; /** Peak Bandwidth in octets per second */
cb_uint32 latency; /** Latency in microseconds */
} cbBCM_FlowSpecParams;
typedef void (*cbBCM_ConnectInd)(
cbBCM_Handle handle,
cbBCM_ConnectionInfo info);
@ -238,12 +229,6 @@ typedef void(*cbBCM_LinkQualityCallback)(
uint8 linkQuality);
typedef void(*cbBCM_ServiceClassEnabled)(cb_uint8 serviceChannel);
typedef void(*cbBCM_SetFlowSpecCallback)(
cb_uint8 status,
cbBCM_Handle handle,
cbBCM_FlowSpecParams parameters);
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
@ -419,6 +404,7 @@ extern cb_uint16 cbBCM_getMaxLinksLE(void);
* @param serverChannel RFCOMM server channel that shall be used. Set to
* cbBCM_INVALID_SERVER_CHANNEL to perform automatic
* service search to find the server channel.
* @param pRemoteName Pointer used in case user connects to the Bluetooth name
* @param pAclParameters Link configuration including link supervision timeout
* and master slave policy. Pass NULL to use default connection
* parameters.
@ -430,7 +416,9 @@ extern cbBCM_Handle cbBCM_reqConnectSpp(
TBdAddr *pAddress,
cb_char *pServiceName,
cb_uint8 serverChannel,
cb_char *pRemoteName,
cbBCM_ConnectionParameters *pAclParameters,
cb_boolean qosEnable,
cbBCM_ConnectionCallback *pConnectionCallback);
/**
@ -477,6 +465,7 @@ extern cbBCM_Handle cbBCM_reqConnectDun(
cb_char *pServiceName,
cb_uint8 serverChannel,
cbBCM_ConnectionParameters *pAclParameters,
cb_boolean qosEnable,
cbBCM_ConnectionCallback *pConnectionCallback);
/**
@ -525,6 +514,7 @@ extern cbBCM_Handle cbBCM_reqConnectUuid(
cb_char *pServiceName,
cb_uint8 serverChannel,
cbBCM_ConnectionParameters *pAclParameters,
cb_boolean qosEnable,
cbBCM_ConnectionCallback *pConnectionCallback);
/**
@ -624,6 +614,7 @@ extern cb_int32 cbBCM_autoConnect(
*/
extern cbBCM_Handle cbBCM_reqConnectSps(
TBdAddr *pAddress,
cb_char *pRemoteName,
cbBCM_ConnectionParametersLe *pAclLeParams,
cbBCM_ConnectionCallback *pConnectionCallback);
@ -825,7 +816,7 @@ extern TBdAddr cbBCM_getAddress(cbBCM_Handle handle);
*/
extern cb_int32 cbBCM_registerDataCallback(
cbBCM_ConnectionType type,
cbBCM_DataCallback *pDataCallback);
const cbBCM_DataCallback *pDataCallback);
/**
* @brief Get the protocol handle for an active connection. Shall not be used
@ -854,19 +845,19 @@ extern cbBCM_Handle cbBCM_getIdFromAclHandle(TConnHandle aclHandle);
* @return acl handle
*/
extern TConnHandle cbBCM_getAclFromIdHandle(cbBCM_Handle bcmHandle);
/**
* @brief This will send cbHCI_cmdFlowSpecification command for the specified link
* with the specified parameters.
* @param handle Connection handle
* @param parameters Flow Specification parameters. For details see Bluetooth Core
* Specification [Vol 3] Part A, Section 5.3
* @param flowSpecCallback Callback contains the data in Flow Specification Complete event
* @return If the operation is successful cbBCM_OK is returned.
* @brief Set active poll mode to introduce periodic BT classic link polling.
* @param mode Active poll mode 0=disable, 1=enable (default period), 2-UINT16_MAX: period of poll
* @return If the update is successfully initiated cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_setFlowSpecification(
cbBCM_Handle handle,
cbBCM_FlowSpecParams parameters,
cbBCM_SetFlowSpecCallback flowSpecCallback);
extern cb_int32 cbBCM_setActivePollMode(cb_uint16 mode);
/**
* @brief Get active poll mode.
* @return Active poll mode 0=disable, 1=enable
*/
extern cb_uint16 cbBCM_getActivePollMode(void);
/**
* @brief Change which packet types can be used for the connection identified by the handle
@ -877,6 +868,7 @@ extern cb_int32 cbBCM_setFlowSpecification(
extern cb_int32 cbBCM_changeConnectionPacketType(
cbBCM_Handle handle,
TPacketType aclPacketType);
#ifdef __cplusplus
}

View File

@ -63,6 +63,10 @@ typedef enum
cbBM_INQUIRY_LIMITED = 1,
} cbBM_InquiryType;
typedef void(*cbBM_TIStatusCallback)(
cb_int32 status,
cb_int8 temperature);
typedef void (*cbBM_InquiryEventCallback)(
TBdAddr *pBdAddress,
TCod cod,
@ -82,10 +86,10 @@ typedef void (*cbBM_RemoteNameCallback)(
typedef enum
{
cbBM_DEVICE_DISCOVERY_LE_ALL = 0,
cbBM_DEVICE_DISCOVERY_LE_ALL = 0, // Limited size filtering to reduce duplicate results (for devices in filter).
cbBM_DEVICE_DISCOVERY_LE_GENERAL,
cbBM_DEVICE_DISCOVERY_LE_LIMITED,
cbBM_DEVICE_DISCOVERY_LE_ALL_NO_FILTERING
cbBM_DEVICE_DISCOVERY_LE_ALL_NO_FILTERING // No found devices filtered out due to previously found
} cbBM_DeviceDiscoveryTypeLe;
typedef enum
@ -96,10 +100,10 @@ typedef enum
typedef void (*cbBM_DeviceDiscoveryLeEventCallback)(
TBdAddr *pBdAddress,
cb_int8 rssi,
cb_char *pName,
TAdvData *pAdvData);
TBdAddr *pBdAddress, // Bluetooth address
cb_int8 rssi, // Tx power in dBm
cb_char *pName, // Remote name as null terminated string
TAdvData *pAdvData); // Advertisment data of remote device
typedef void (*cbBM_DeviceDiscoveryLeCompleteCallback)(
cb_int32 status);
@ -138,7 +142,7 @@ typedef enum
typedef void (*cbBM_ChannelMapCallb)(
cbBM_ChannelMapEvt chMapEvt,
TChannelMap *pChMap);
TChannelMap *pChMap); // Channel map bit mask
typedef void (*cbBM_InitComplete)(void);
typedef void(*cbBM_LocalAddressCb)(void);
@ -150,17 +154,6 @@ typedef enum
cbBM_LE_ROLE_PERIPHERAL = 2,
} cbBM_LeRole;
typedef struct
{
cb_uint8 flags;
cb_uint8 flowDirection;
cb_uint8 serviceType;
cb_uint32 tokenRate;
cb_uint32 tokenBucketSize;
cb_uint32 peakBandwidth;
cb_uint32 latency;
} cbBM_FlowSpecParams;
/**
* Bluetooth Manager initialization parameters.
*/
@ -191,6 +184,8 @@ typedef void(*cbBM_ServiceEnabled)(cb_uint8 serviceChannel);
*
* @param pInitParameters Init parameters
* @param initCompleteCallback Callback used to notify when the initialization is complete.
* @param pBtReadyCallback Callback used to notify when the customized Bluetooth
* initialization is ready.
* @return None
*/
extern void cbBM_init(
@ -198,45 +193,72 @@ extern void cbBM_init(
cbBM_InitComplete initCompleteCallback);
/**
* This function sets the default link supervision timeout. The specified timeout will
* apply for new connections.
* @param linkSupervisionTimeout timeout in milliseconds
* @return If the operation is successful cbBM_OK is returned.
* This function executes cbBM_setQosParams command according to parameters.
* @param connectConfig decides whether to turn off connectability and discoverability
* when max links are reached.
* @param qosConfig QoS enable=1, disable=0
* @param connectConfig QoS "off during connection"=0, "on during connection"=1
* @return true if in parameters are valid.
*/
extern cb_int32 cbBM_setQosParams(
cb_uint8 qosConfig,
cb_uint8 connectConfig);
/**
* This function sets the link supervision timeout in LLC.
* @param linkSupervisionTimeout in milliseconds
* @return true if in parameter is valid.
*/
extern cb_int32 cbBM_setLinkSupervisionTimeout(
cb_uint16 linkSupervisionTimeout);
/**
* This function gets the default link supervision timeout.
* @return link supervision timeout in milliseconds.
* This function gets the link supervision timeout from LLC.
* @return link supervision timeout in milliseconds
*/
extern cb_uint16 cbBM_getLinkSupervisionTimeout(void);
/**
* This function enables or disables the fast connect feature (interlaced page scan).
* @param fastConnect
* @param fastConnect enable=TRUE, disable=FALSE
* @return cbBM_OK if in parameter is valid.
*/
extern cb_int32 cbBM_setFastConnect(
cb_boolean fastConnect);
/**
* This function gets whether the fast connect feature is enabled or disabled.
* @return TRUE if feature is enabled
*/
* This function gets whether the fast connect feature is enabled or disabled.
* @return fast connect; enabled=TRUE, disabled=FALSE
*/
extern cb_boolean cbBM_getFastConnect(void);
/**
* This function enables or disables the fast discovery feature (interlaced inquiry scan).
* @param fastDiscovery
* @param fastDiscovery enable=TRUE, disable=FALSE
* @return cbBM_OK if in parameter is valid.
*/
extern cb_int32 cbBM_setFastDiscovery(
cb_boolean fastDiscovery);
/**
* This function gets whether the fast discovery feature is enabled or disabled.
* @return TRUE if feature is enabled
* @return fast connect enabled=TRUE, disabled=FALSE
*/
extern cb_boolean cbBM_getFastDiscovery(void);
/**
* This function sets the page timeout in LLC.
* @param pageTimeout in milliseconds
* @return cbBM_OK if successful
*/
extern cb_int32 cbBM_setPageTimeout(
cb_uint16 pageTimeout);
/**
* This function gets the page timeout from LLC.
* @return page timeout in milliseconds.
*/
extern cb_uint16 cbBM_getPageTimeout(void);
/**
* This function sets all default parameters for LE.
* This function needs to be called before the cbBM_init.
@ -247,7 +269,7 @@ extern void cbBM_setDefaultValuesLeParams(void);
* This function executes HCI_cmdWrScanEnable command according to parameters.
* @param discoverableMode discoverable mode
* @param connectableMode connectable mode
* @return true if HCI command could be executed.
* @return cbBM_OK if HCI command could be executed.
*/
extern cb_int32 cbBM_updateScan(
cbBM_DiscoverableMode discoverableMode,
@ -255,7 +277,8 @@ extern cb_int32 cbBM_updateScan(
/**
* Get the current Bluetooth address of the device from radio. This can
* be a way to get a alive-message from the radio.
* be a way to get a alive-message from the radio. Also, if the radio resets,
* the address is set to a chip default value.
*
* @param callback to application when address has been read.
*/
@ -272,7 +295,7 @@ extern cb_int32 cbBM_getLocalAddress(TBdAddr *pAddress);
* Set local name
* This sets the Bluetooth Classic device name as well as the Bluetooth Low
* Energy device name. Inquiry and advertising is updated.
* @param pName The new local name.
* @param pName The new local name (null terminated string). Max length is 32 chars.
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_setLocalName(cb_char* pName);
@ -281,7 +304,7 @@ extern cb_int32 cbBM_setLocalName(cb_char* pName);
* Get local name.
* Get the current local name.
* @param pName Pointer to return variable.
* @param length Max length of the name string.
* @param length Max length of the name string. Name will be truncated if length is too small.
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_getLocalName(
@ -344,13 +367,27 @@ extern cb_int32 cbBM_setMasterSlavePolicy(TMasterSlavePolicy policy);
*/
extern cb_int32 cbBM_getMasterSlavePolicy(TMasterSlavePolicy *pPolicy);
/**
* Enable/disable sniff mode
* @param enable TRUE=enable sniff mode, FALSE=disable sniff mode
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_setSniffMode(cb_boolean enable);
/**
* Get sniff mode
* @param pEnable Pointer to return variable
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_getSniffMode(cb_boolean *pEnable);
/**
* Set default channel map for Bluetooth Classic. Used to exclude channels
* from usage.
* Request an update of which channels shall be used by adaptive frequency hopping.
* typically this is not needed since the Bluetooth is very good at select which
* channels to use.
* @param channelMap Channel map. Note that at least 20 channels must be enabled.
* @param channelMap Channel map bit mask. Note that at least 20 channels must be enabled.
* @param channelMapCallback Callback used to notify if the channel map
* is accepted by the radio.
* @return If the operation is successfully initiated cbBM_OK is returned.
@ -361,7 +398,7 @@ extern cb_int32 cbBM_setAfhChannelMap(
/**
* Get the default channel map.
* @param pMap Pointer to return variable.
* @param pMap Pointer to return variable where the channel map bit mask is stored.
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_getAfhChannelMap(TChannelMap *pMap);
@ -390,9 +427,9 @@ extern cb_int32 cbBM_inquiryCancel(void);
/**
* Perform a remote name request for Bluetooth Classic.
* @param pAddress Pointer to address of remote device.
* @param clockOffset Clock offset. Can be found in inquiry response.
* @param clockOffset Clock offset. Can be found in inquiry response. Use 0 if not available.
* @param pageTimeout Page timeout in ms (Length of connection attempt).
* @param remoteNameCallb Callback used to notify the the completion of the
* @param remoteNameCallb Callback used to notify the completion of the
* name request.
* @return If the operation is successfully initiated cbBM_OK is returned.
*/
@ -405,16 +442,16 @@ extern cb_int32 cbBM_remoteName(
/**
* Add service class to inquiry response data. Typically
* not used by the application.
* @param uuid16 The UUID to add
* @param pCallback callback to indicate service is enabled.
* @param serviceChannel channel the service is started on.
* @param uuid16 The UUID to add. E.g. 0x1101=SPP, 0x1115=PANU, 0x1116=NAP
* @param pCallback callback to indicate service is enabled
* @param serviceChannel channel the service is started on
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_addServiceClass(cb_uint16 uuid16, cbBM_ServiceEnabled pCallback,cb_uint8 serviceChannel);
/**
* Check if service class is already registered.
* @param uuid16 The UUID to check
* @param uuid16 The UUID to check. E.g. 0x1101=SPP, 0x1115=PANU, 0x1116=NAP
* @return TRUE If the ServiceClass is registered, FALSE otherwise.
*/
cb_boolean cbBM_isServiceClassRegistered(cb_uint16 uuid16 );
@ -526,50 +563,6 @@ extern cb_int32 cbBM_getAdvData(
extern cb_int32 cbBM_getScanRspData(
TAdvData* pScanRspData);
/**
* Set default Bluetooth Low Energy connection parameters.
* Note that setting the connection parameters does not change
* the parameters on active connections.
* @param createConnectionTimeout Default timeout connection for connection attempts
* @param connIntervalMin Default connection min interval
* @param connIntervalMax Default connection max interval
* @param connLatency Default connection latency
* @param linklossTmo Default link loss timeout
* @return cbBM_OK is returned on success.
*/
cb_int32 cbBM_setAutoConnectionParams(
cb_uint32 createConnectionTimeout,
cb_uint16 connIntervalMin,
cb_uint16 connIntervalMax,
cb_uint16 connLatency,
cb_uint16 linklossTmo);
/**
* Get default Bluetooth Low Energy connection parameters.
* @param pCreateConnectionTimeout Default create connection timeout
* @param pConnIntervalMin Default connection min interval
* @param pConnIntervalMax Default connection max interval
* @param pConnLatency Default connection latency
* @param pLinklossTmo Default link loss timeout
* @return cbBM_OK is returned on success.
*/
cb_int32 cbBM_getAutoConnectionParams(
cb_uint32 *pCreateConnectionTimeout,
cb_uint16 *pConnIntervalMin,
cb_uint16 *pConnIntervalMax,
cb_uint16 *pConnLatency,
cb_uint16 *pLinklossTmo);
/**
* Get Bluetooth Low Energy scan parameters.
* @param pScanInterval Scan interval
* @param pScanWindow Scan window
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_getAutoconnScanParams(
cb_uint16 *pScanInterval,
cb_uint16 *pScanWindow);
/**
* Start an Bluetooth Low Energy device discovery.
* The event callback is called for every device that is found during inquiry.
@ -596,7 +589,7 @@ extern cb_int32 cbBM_deviceDiscoveryLeCancel(void);
/**
* Perform a remote name request for Bluetooth Low Energy.
* @param pAddress Pointer to address of remote device.
* @param remoteNameCallback Callback used to notify the the completion of the
* @param remoteNameCallback Callback used to notify the completion of the
* name request.
* @return If the operation is successfully initiated cbBM_OK is returned.
*/
@ -615,85 +608,413 @@ extern cb_int32 cbBM_add128BitsServiceClassLe(cb_uint8* uuid128);
/*
* Read the used max tx power .
* @return max tx power level as int8.
* @return max tx power level in dBm.
*/
extern cb_int8 cbBM_getMaxTxPower(void);
/*
* Read the connection parameters for Bond.
* @return cbCMLE_AclParamsLe pointer to values.
* @param bondParams Pointer to structure where the connection parameters are stored.
* @return void
*/
void cbBM_getBondParameters(TAclParamsLe* bondParams);
/*
* Read the connection parameters for connection.
* @return cbCMLE_AclParamsLe pointer to values.
* @param aclParams Pointer to structure where the connection parameters are stored.
* @return void
*/
void cbBM_getConnectParameters(TAclParamsLe* aclParams);
/*
* Read the connection parameters for remote name request.
* @return cbCMLE_AclParamsLe pointer to values.
* @param aclParams Pointer to structure where the connection parameters are stored.
* @return void
*/
void cbBM_getRemoteNameReqParameters(TAclParamsLe* aclParams);
cb_int32 cbBM_setForceClassicNotSupportedInAdv(cb_boolean enforceDisable);
cb_boolean cbBM_getForceClassicNotSupportedInAdv(void);
/*
* Sets the LE parameter.
* @newValue new parameter value.
* Read the vendor specific status of the WL18 chipset.
* @param callback Callback used to notify the completion of the
* status request.
*@return Returns cbBM_OK if successfully started.
*/
cb_int32 cbBM_getTISystemStatus(cbBM_TIStatusCallback callback);
/*
* Set BT classic as not supported in the peripheral advertisment.
* @param enforceDisable TRUE to set BT classic not supported
* @return cbBM_OK if successful
*/
cb_int32 cbBM_setForceClassicNotSupportedInAdv(cb_boolean enforceDisable);
/*
* Set BT classic as not supported in the peripheral advertisment.
*
* @return TRUE if BT classic is set to not supported in the peripheral advertisment.
*/
cb_boolean cbBM_getForceClassicNotSupportedInAdv(void);
/**
* Set min advertisment interval
*
* @param newValue Minimial interval value as slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setAdvertisingIntervalMin(cb_uint16 val);
/**
* Set max advertisment interval
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setAdvertisingIntervalMin(cb_uint16 newValue);
extern cb_int32 cbBM_setAdvertisingIntervalMax(cb_uint16 newValue);
/**
* Set advertisment channel map
*
* @param Bit mask of channels to use; Channel 37, 38, 39
* (cbBM_ADV_CHANNEL_MAP_CH_37_BIT, cbBM_ADV_CHANNEL_MAP_CH_38_BIT, cbBM_ADV_CHANNEL_MAP_CH_39_BIT)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setAdvChannelmap(cb_uint16 newValue);
/**
* Set min connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectConnIntervalMin(cb_uint16 newValue);
/**
* Set max connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectConnIntervalMax(cb_uint16 newValue);
/**
* Set connection latency
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectConnLatency(cb_uint16 newValue);
/**
* Set link loss (or supervision) timeout
*
* @param newValue Time in ms (make sure it is larger than the connection latency)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectLinklossTmo(cb_uint16 newValue);
/**
* Set create connection (or page) timeout
*
* @param newValue Time in ms
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectCreateConnTmo(cb_uint16 newValue);
/**
* Set connect scan interval
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectScanInterval(cb_uint16 newValue);
/**
* Set connect scan window
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setConnectScanWindow(cb_uint16 newValue);
/**
* Set min bond connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondConnIntervalMin(cb_uint16 newValue);
/**
* Set max bond connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondConnIntervalMax(cb_uint16 newValue);
/**
* Set bond connection latency
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondConnLatency(cb_uint16 newValue);
/**
* Set bond link loss (or supervision) timeout
*
* @param newValue Time in ms (make sure it is larger than the connection latency)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondLinklossTmo(cb_uint16 newValue);
/**
* Set bond create connection (or page) timeout
*
* @param newValue Time in ms
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondCreateConnTmo(cb_uint16 newValue);
/**
* Set bond scan interval
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondScanInterval(cb_uint16 newValue);
/**
* Set bond scan window
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setBondScanWindow(cb_uint16 newValue);
/**
* Set min remote name connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameConnIntervalMin(cb_uint16 newValue);
/**
* Set max remote name connection interval
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameConnIntervalMax(cb_uint16 newValue);
/**
* Set remote name connection latency
*
* @param newValue Time in slots (1 slot is 1.25ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameConnLatency(cb_uint16 newValue);
/**
* Set remote name link loss (or supervision) timeout
*
* @param newValue Time in ms (make sure it is larger than the connection latency)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameLinklossTmo(cb_uint16 newValue);
/**
* Set remote name create connection (or page) timeout
*
* @param newValue Time in ms
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameCreateConnTmo(cb_uint16 newValue);
/**
* Set remote name scan interval
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameScanInterval(cb_uint16 newValue);
/**
* Set remote name scan window
*
* @param newValue Time in slots (1 slot is 0.625ms)
* @return cbBM_OK is returned on success.
*/
extern cb_int32 cbBM_setRemoteNameScanWindow(cb_uint16 newValue);
/*
* Read the LE parameter.
* @return parameter.
/**
* Get min advertisment interval
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getAdvertisingIntervalMin(void);
/**
* Get max advertisment interval
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getAdvertisingIntervalMax(void);
/**
* Get advertisment channel map
*
* @return Bit mask of channels to use; Channel 37, 38, 39
* (cbBM_ADV_CHANNEL_MAP_CH_37_BIT, cbBM_ADV_CHANNEL_MAP_CH_38_BIT, cbBM_ADV_CHANNEL_MAP_CH_39_BIT)
*/
extern cb_uint16 cbBM_getAdvChannelmap(void);
/**
* Get min connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getConnectConnIntervalMin(void);
/**
* Get max connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getConnectConnIntervalMax(void);
/**
* Get connection latency
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getConnectConnLatency(void);
/**
* Get link loss (or supervision) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getConnectLinklossTmo(void);
/**
* Get create connection (or page) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getConnectCreateConnTmo(void);
/**
* Get connection scan interval
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getConnectScanInterval(void);
/**
* Get connection scan window
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getConnectScanWindow(void);
/**
* Get min bond connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getBondConnIntervalMin(void);
/**
* Get bond connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getBondConnIntervalMax(void);
/**
* Get bond connection latency
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getBondConnLatency(void);
/**
* Get bond link loss (or supervision) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getBondLinklossTmo(void);
/**
* Get bond connection (or page) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getBondCreateConnTmo(void);
/**
* Get bond scan interval
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getBondScanInterval(void);
/**
* Get bond scan window
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getBondScanWindow(void);
/**
* Get min remote name connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getRemoteNameConnIntervalMin(void);
/**
* Get max remote name connection interval
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getRemoteNameConnIntervalMax(void);
/**
* Get remote name connection latency
*
* @return Time in slots (1 slot is 1.25ms)
*/
extern cb_uint16 cbBM_getRemoteNameConnLatency(void);
/**
* Get remote name link loss (or supervision) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getRemoteNameLinklossTmo(void);
/**
* Get remote name connection (or page) timeout
*
* @return Time in ms
*/
extern cb_uint16 cbBM_getRemoteNameCreateConnTmo(void);
/**
* Get remote name scan interval
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getRemoteNameScanInterval(void);
/**
* Get remote name scan window
*
* @return Time in slots (1 slot is 0.625ms)
*/
extern cb_uint16 cbBM_getRemoteNameScanWindow(void);
#ifdef __cplusplus

View File

@ -153,7 +153,19 @@
#define cb_INT16_MIN ((cb_int16)0x8000)
#define cb_INT32_MIN ((cb_int32)0x80000000)
/* Packed struct default defines */
#ifndef cb_PACKED_STRUCT_ATTR_INLINE_POST
# define cb_PACKED_STRUCT_ATTR_INLINE_POST
#endif
#ifndef cb_PACKED_STRUCT_ATTR_INLINE_PRE
# define cb_PACKED_STRUCT_ATTR_INLINE_PRE
#endif
#ifndef cb_PACKED_STRUCT_ATTR_PRE
# define cb_PACKED_STRUCT_ATTR_PRE
#endif
#ifndef cb_PACKED_STRUCT_ATTR_POST
# define cb_PACKED_STRUCT_ATTR_POST
#endif
#define cb_PACKED_STRUCT_BEGIN(name) \
cb_PACKED_STRUCT_ATTR_PRE \

View File

@ -32,6 +32,13 @@ extern "C" {
/*===========================================================================
* DEFINES
*=========================================================================*/
#define cbHW_SECUREBOOT_SIGN_LENGTH 344
#define cbHW_FW_NAME_MAX_LENGTH 22
#define cbHW_FW_NAME_MIN_LENGTH 1
#define cbHW_FW_FLAG_MAX_LENGTH 8 // 8 bit fields
#define cbHW_FW_FLAG_MIN_LENGTH 1
#define cbHW_UNIQUE_ID_SIZE 12
typedef enum {
cbHW_PCB_VERSION_UNKNOWN,
cbHW_PCB_VERSION_1,
@ -64,6 +71,10 @@ typedef enum {
cbHW_SYSTICK_LOW_FREQ,
cbHW_SYSTICK_DEFAULT,
} cbHW_SysTickMode;
typedef enum {
cbHW_HASH_MD5
}cbHW_HashType;
/*===========================================================================
* TYPES
*=========================================================================*/
@ -78,8 +89,9 @@ typedef void (*cbHW_SysTickCb)(void);
void cbHW_init(void);
void cbHW_registerStopModeStatusEvt(cbHW_StopModeStatusEvt evt);
void cbHW_disableIrq(void);
void cbHW_disableAllIrq(void); // Should not be used unless extremely critical
void cbHW_enableIrq(void);
void cbHW_disableAllIrq(void); // Should not be used unless extremely critical
void cbHW_enableAllIrq(void);
void cbHW_enterSleepMode(void);
void cbHW_enterStopMode(void);
void cbHW_setWakeupEvent(void);
@ -95,6 +107,12 @@ void cbHW_setSysTickMode(cbHW_SysTickMode sysTickMode);
*/
void cbHW_delay(cb_uint32 us);
/**
* Puts the chip in NVIC soft reset
* @note: this does not reset any watchdog timer already enabled
*/
void cbHW_reset(void);
/**
* Wait for specified amount of microseconds using a software loop.
* @note Granularity may vary between systems.
@ -108,7 +126,7 @@ void cbHW_setSysFreq(cb_uint32 sysFreq);
cb_uint32 cbHW_getSysFreq(void);
void cbHW_writeBackupRegister(cb_uint32 registerId, cb_uint32 value);
cb_uint32 cbHW_readBackupRegister(cb_int32 registerId);
void cbHW_getHWId(cb_uint8 uid[12]);
void cbHW_getHWId(cb_uint8 uid[cbHW_UNIQUE_ID_SIZE]);
cbHW_PCBVersion cbHW_getPCBVersion(void);
/**
@ -136,12 +154,65 @@ cb_uint32 cbHW_getTickFrequency(void);
*/
cb_uint32 cbHW_getTicks(void);
/**
* Enter forced boot mode. The bootloader will start in x-modem
* mode and emit CCCC.. to notify that it is ready to receive
* a new fw.
* This function will return and boot mode will be entered
* after a device specific timeout.
* @param address x-modem file download start address
* @param baudrate x-modem download buadrate
* @return None
*/
void cbHW_forceBoot(cb_uint32 address, cb_uint32 baudrate);
/**
* Enter forced boot mode. The bootloader will start in x-modem
* mode and emit CCCC.. to notify that it is ready to receive
* a new fw.
* This function will return and boot mode will be entered
* after a device specific timeout.
* @param address x-modem file download start address
* @param baudrate x-modem download buadrate
* @param fwId firmware id
* @param fwSize firmware file size
* @param fwSignature firmware signature
* @param fwName firmware name
* @param fwFlags firmware flags
* @return None
*/
void cbHW_forceBootSecure(
cb_uint32 address,
cb_uint32 baudrate,
cb_uint32 fwId,
cb_uint32 fwSize,
cb_char* fwSignature,
cb_char* fwName,
cb_char* fwFlags);
/**
* Cancel entry into boot mode. The user canceled entry
* into forced boot mode.
* This function will clean up the RTC memory that was
* configured for a forced boot operation. Use this function
* for both cbHW_forceBootSecure and cbHW_forceBoot
* @return None
*/
void cbHW_cancelforceBoot(void);
void cbHW_enterProductionMode(cbHW_FlowControl flowControl);
cbHW_ResetReason cbHW_resetReason(void);
cbHW_FlowControl cbHW_flowControl(void);
void cbHW_enableAllIrq(void);
/**
* Calculates a hash over a dataset.
* @param type: type of hashing, MD5 for now
* @param pInData: pointer to Data over which the hashing should be done
* @param indataSize: size of data buffer.
* @param pOutData: pointer to result data
* @return None
*/
void cbHW_hash(cbHW_HashType type, const cb_uint8* pInData,cb_uint32 indataSize, cb_uint8* pOutData);
#ifdef __cplusplus
}

View File

@ -48,6 +48,10 @@ typedef enum
cbOTP_MAC_DEBUG_UNIT,
cbOTP_SERIAL_NUMBER,
cbOTP_TYPE_CODE,
cbOTP_SIGNATURE,
cbOTP_MAC_WLAN_AP,
cbOTP_UUID,
cbOTP_RF_FREQ_CALIBRATION,
cbOTP_RESERVED_UNUSED = 255
} cbOTP_Id;

View File

@ -29,6 +29,7 @@
#define _CB_PORT_TYPES_H_
#include <cb_comdefs.h>
#include "cb_assert.h"
#endif /* _CB_PORT_TYPES_H_ */

View File

@ -0,0 +1,178 @@
/**
*---------------------------------------------------------------------------
* Copyright (c) 2016, u-blox Malmö, All Rights Reserved
* SPDX-License-Identifier: LicenseRef-PBL
*
* This file and the related binary are licensed under the
* Permissive Binary License, Version 1.0 (the "License");
* you may not use these files except in compliance with the License.
*
* You may obtain a copy of the License here:
* LICENSE-permissive-binary-license-1.0.txt and at
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Component : WLAN driver
* File : cb_target.h
*
* Description : OWL222a Wireless LAN module representation
*-------------------------------------------------------------------------*/
/**
* @file cb_target.h Handles the lowest layer of communication to the target
* before the SDIO stack.
*
* @note Create and Destroy methods are not specified here as these are not part
* of the interface used by the driver. The application should specify these
* as needed and simply supply the driver with a target handle.
*
* @ingroup port
*/
#ifndef _CB_TARGET_H_
#define _CB_TARGET_H_
#include "cb_wlan_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================
* DEFINES
*=========================================================================*/
#define cbTARGET_SDIO_BLOCK_SIZE (256)
/*===========================================================================
* TYPES
*=========================================================================*/
typedef struct cbTARGET_Handle cbTARGET_Handle;
typedef struct cbTARGET_FunctionHandle cbTARGET_FunctionHandle;
typedef void(*cbTARGET_ISRHandler)(void* hCallback);
typedef enum {
cbTARGET_CBTYPE_IRQ,
cbTARGET_CBTYPE_START,
cbTARGET_CBTYPE_STOP,
} cbTARGET_CallbackType;
typedef enum cbTARGET_SDIO_Function {
cbTARGET_SDIO_FUNCTION_0,
cbTARGET_SDIO_FUNCTION_1,
cbTARGET_SDIO_FUNCTION_2,
cbTARGET_SDIO_FUNCTION_3,
cbTARGET_SDIO_FUNCTION_4,
cbTARGET_SDIO_FUNCTION_5,
cbTARGET_SDIO_FUNCTION_6,
cbTARGET_SDIO_FUNCTION_7,
} cbTARGET_SDIO_Function;
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
/**
* Map/resolve target handle from port specific identifier.
*
* @param targetId Port specific target identifier.
* @return Target handle matching target identifier.
*/
cbTARGET_Handle *cbTARGET_targetResolve(cb_int32 targetId);
/**
* Perform a hardware reset of the TARGET.
*/
void cbTARGET_reset(cbTARGET_Handle *hTarget);
/**
* Register a interrupt handler with the TARGET.
*/
void cbTARGET_registerISRHandler(cbTARGET_Handle *hTarget, cbTARGET_ISRHandler handler, void* hContext);
/**
* Initiate a SDIO function and return a controlling object.
*
* @param hTarget Handle to target object.
* @param func SDIO function to initiate.
* @return Handle to a SDIO function object.
*/
cbTARGET_FunctionHandle* cbTARGET_initFunction(cbTARGET_Handle *hTarget, cbTARGET_SDIO_Function func);
/**
* Write a buffer to the target using SDIO FIFO access.
*
* @param hFunction Handle to a SDIO target function object.
* @param address SDIO address.
* @param data Send buffer.
* @param dataSize Number of valid data bytes in transfer.
* @return True if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_FIFOWrite(cbTARGET_FunctionHandle* hFunction, cb_uint32 address, cb_uint8* data, cb_uint32 dataSize);
/**
* Read from the target into a buffer using SDIO FIFO access.
*
* @param hFunction Handle to a SDIO target function object.
* @param address SDIO address.
* @param data Receive buffer.
* @param dataSize Number of valid data bytes in transfer.
* @return TRUE if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_FIFORead(cbTARGET_FunctionHandle* hFunction, cb_uint32 address, cb_uint8* data, cb_uint32 dataSize);
/**
* Write a buffer to the target.
*
* @param hFunction Handle to a SDIO target function object.
* @param address SDIO address.
* @param data Send buffer.
* @param dataSize Number of valid data bytes in transfer.
* @return True if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_write(cbTARGET_FunctionHandle* hFunction, cb_uint32 address, cb_uint8* data, cb_uint32 dataSize);
/**
* Read from the target into a buffer.
*
* @param hFunction Handle to a SDIO target function object.
* @param address SDIO address.
* @param data Receive buffer.
* @param dataSize Number of valid data bytes in transfer.
* @return TRUE if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_read(cbTARGET_FunctionHandle* hFunction, cb_uint32 address, cb_uint8* data, cb_uint32 dataSize);
/**
* Write a single byte to the function 0 of the SDIO target.
*
* @param hTarget Handle to target object.
* @param address SDIO address.
* @param data Send buffer.
* @return True if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_f0_writeByte(cbTARGET_Handle *hTarget, cb_uint32 address, cb_uint8 data);
/**
* Read a single byte from the function 0 of the SDIO target.
*
* @param hTarget Handle to target object.
* @param address SDIO address.
* @param data Receive buffer.
* @return TRUE if successful, otherwise FALSE.
*/
cb_boolean cbTARGET_f0_readByte(cbTARGET_Handle *hTarget, cb_uint32 address, cb_uint8 *data);
cb_uint16 cbTARGET_getBlockSize(cbTARGET_Handle *hTarget);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -275,7 +275,7 @@
#ifndef cb_PACKED_STRUCT_BEGIN
# define cb_PACKED_STRUCT_BEGIN(name) \
cb_PACKED_STRUCT_ATTR_PRE \
typedef cb_PACKED_STRUCT_ATTR_INLINE_PRE struct name##_t
typedef cb_PACKED_STRUCT_ATTR_INLINE_PRE struct name
#endif
#ifndef cb_PACKED_STRUCT_END

View File

@ -48,7 +48,7 @@ extern "C" {
*
* @ingroup wlan
*/
#define cbWLAN_MAX_USERNAME_LENGTH 64
#define cbWLAN_MAX_USERNAME_LENGTH 32
/**
* Max password length in @ref cbWLAN_Util_PSKFromPWD and @ref cbWLAN_EnterpriseConnectParameters
@ -72,6 +72,16 @@ extern "C" {
*/
#define cbWLAN_MAX_DOMAIN_LENGTH 64
/**
* Size of the misc buffer in @ref cbWM_ChangeBSS and @ref cbWM_StartFT.
*
* @ingroup types
*/
#define MISC_BUFFER_SIZE 255
#define cbWLAN_FTIE_SIZE 255
#define cbWLAN_RSNIE_SIZE 44
#define cbWLAN_MDIE_SIZE 5
/*===========================================================================
* TYPES
@ -83,11 +93,12 @@ extern "C" {
*/
typedef struct cbWLAN_StartParameters {
cbWLAN_MACAddress mac; /**< MAC of WLAN interface, set to all zeros if hardware programmed address should be used. */
cb_boolean disable80211d;
cbWM_ModuleType deviceType; /**< Specify current device type. */
union {
struct {
cbWM_TxPowerSettings txPowerSettings; /**< Transmission power settings. */
cb_uint8 numberOfAntennas; /**< Number of antennas use for wifi (MIMO supports 2x2). */
cb_uint8 primaryAntenna; /**< Primary antenna selection. */
} ODIN_W26X;
} deviceSpecific;
} cbWLAN_StartParameters;
@ -129,26 +140,38 @@ typedef struct cbWLAN_WPAPSK {
*/
typedef struct cbWLAN_WPAPSKConnectParameters {
cbWLAN_WPAPSK psk; /**< WPA pre-shared key*/
#if defined(CB_FEATURE_802DOT11W)
#endif
} cbWLAN_WPAPSKConnectParameters;
#if defined(CB_FEATURE_802DOT11R)
/**
* Associate information elements with FT elements.
*
* @ingroup wlan
*/
typedef struct cbWLAN_AssociateInformationElements{
cb_uint8 wpaIe[cbWLAN_RSNIE_SIZE];
cb_uint32 wpaIeLen;
cb_uint8 mdIe[cbWLAN_MDIE_SIZE];
cb_uint32 mdIeLen;
cb_uint8 ftIe[cbWLAN_FTIE_SIZE];
cb_uint32 ftIeLen;
}cbWLAN_AssociateInformationElements;
#endif
typedef enum cbWLAN_CipherSuite {
cbWLAN_CIPHER_SUITE_NONE = 0x00,
cbWLAN_CIPHER_SUITE_WEP64 = 0x01,
cbWLAN_CIPHER_SUITE_WEP128 = 0x02,
cbWLAN_CIPHER_SUITE_TKIP = 0x04,
cbWLAN_CIPHER_SUITE_AES_CCMP = 0x08,
} cbWLAN_CipherSuite;
typedef enum cbWLAN_AuthenticationSuite {
cbWLAN_AUTHENTICATION_SUITE_NONE = 0x00,
cbWLAN_AUTHENTICATION_SUITE_SHARED_SECRET = 0x01,
cbWLAN_AUTHENTICATION_SUITE_PSK = 0x02,
cbWLAN_AUTHENTICATION_SUITE_8021X = 0x04,
cbWLAN_AUTHENTICATION_SUITE_USE_WPA = 0x08,
cbWLAN_AUTHENTICATION_SUITE_USE_WPA2 = 0x10,
} cbWLAN_AuthenticationSuite;
#if defined(CB_FEATURE_802DOT11W)
/**
* 80211w PMF specific connect parameters.
*
* @ingroup wlan
*/
typedef struct cbWLAN_PMFApParameters {
cbWLAN_PMF pmf; /**< MFPR, MFPC RSN capabilties*/
cb_uint8 comeBackTime; /**< 1 - 10 sec */
cb_uint16 saQueryTimeOut; /**< 100 - 500 msec */
} cbWLAN_PMFApParameters;
#endif
/**
* WPA Enterprise specific connect parameters.
@ -161,7 +184,9 @@ typedef struct cbWLAN_EnterpriseConnectParameters {
cb_uint8 passphrase[cbWLAN_MAX_PASSPHRASE_LENGTH]; /**< Passphrase string. */
cb_uint8 domain[cbWLAN_MAX_DOMAIN_LENGTH]; /**< Domain string. */
cbCERT_Stream *clientCertificate; /**< Stream handle to provide SSL certificate for authentication. */
cbCERT_Stream *clientPrivateKey; /**< STream handle to provide SSL private key for authentication. */
cbCERT_Stream *clientPrivateKey; /**< Stream handle to provide SSL private key for authentication. */
cbCERT_Stream *CACertificate; /**< Stream handle to provide CA certificate for server certificate validation,
Can be NULL if server certificate shouldn't be validated. */
} cbWLAN_EnterpriseConnectParameters;
/**
@ -170,9 +195,11 @@ typedef struct cbWLAN_EnterpriseConnectParameters {
* @ingroup wlan
*/
typedef struct cbWLAN_CommonApParameters {
cbWLAN_Ssid ssid; /**< SSID to connect to. */
cbWLAN_Channel channel; /**< Active channel. */
cbWLAN_RateMask basicRates; /**< Basic rates. */
cbWLAN_Ssid ssid; /**< SSID to connect to. */
cbWLAN_Channel channel; /**< Active channel. */
cbWLAN_RateMask basicRates; /**< Basic rates. */
cbWLAN_RateMask allowedRates; /**< BSS allowed rates. */
cb_uint8 dtimInterval; /**< Dtim Interval. */
}cbWLAN_CommonApParameters;
@ -185,10 +212,12 @@ typedef struct cbWLAN_WPAPSKApParameters {
cbWLAN_CipherSuite rsnCiphers; /**< Bit field indicating which ciphers that shall be displayed in RSN information elements. If 0 no RSN information elements is added to beacons and probe responses. */
cbWLAN_CipherSuite wpaCiphers; /**< Bit field indicating which ciphers that shall be displayed in WPA information elements. If 0 no WPA information elements is added to beacons and probe responses. */
cbWLAN_WPAPSK psk; /**< WPA pre-shared key*/
#if defined(CB_FEATURE_802DOT11W)
cbWLAN_PMFApParameters pmfParameters;
#endif
cb_uint32 gtkRekeyInterval; /**< Group rekey interval in seconds */
} cbWLAN_WPAPSKApParameters;
/**
* Scan parameters
*
@ -196,6 +225,7 @@ typedef struct cbWLAN_WPAPSKApParameters {
*/
typedef struct cbWLAN_ScanParameters {
cbWLAN_Ssid ssid; /**< SSID to scan for, set to zero length for broadcast scan. */
cbWLAN_Channel channel;
} cbWLAN_ScanParameters;
/**
@ -214,13 +244,16 @@ typedef struct cbWLAN_ScanIndicationInfo {
cbWLAN_AuthenticationSuite authenticationSuites; /**< Supported authentication suites */
cbWLAN_CipherSuite unicastCiphers; /**< Supported unicast cipher suites */
cbWLAN_CipherSuite groupCipher; /**< Supported group cipher suites */
#if defined(CB_FEATURE_802DOT11R)
cbWLAN_MDInformation mobilityDomainId; /**< Mobility Domain Id and Ft capability policy>*/
#endif
cbWLAN_RateMask basicRateSet; /**< Basic rate set, i.e. required rates. */
cbWLAN_RateMask supportedRateSet; /**< Supported rate set, super set of basic rate set. */
cb_uint32 beaconPeriod; /**< Beacon period in ms. */
cb_uint32 DTIMPeriod; /**< DTIM period in beacon intervals */
cb_uint8 countryCode[3]; /**< Three letter country code */
cb_uint32 flags; // QoS, short preamble, DFS, privacy,
cb_uint8 countryCode[2]; /**< Two letter country code */
cb_uint32 flags; /**< QoS, short preamble, DFS, privacy */
cb_uint16 RSNCapabilities; /**< Protected management frames capabilities*/
} cbWLAN_ScanIndicationInfo;
/**
@ -240,6 +273,8 @@ typedef enum {
cbWLAN_STATUS_AP_DOWN,
cbWLAN_STATUS_AP_STA_ADDED,
cbWLAN_STATUS_AP_STA_REMOVED,
cbWLAN_STATUS_80211r_REASSOCIATING,
cbWLAN_STATUS_80211r_REASSOCIATED,
} cbWLAN_StatusIndicationInfo;
/**
@ -252,6 +287,7 @@ typedef enum {
cbWLAN_STATUS_DISCONNECTED_NO_BSSID_FOUND,
cbWLAN_STATUS_DISCONNECTED_AUTH_TIMEOUT,
cbWLAN_STATUS_DISCONNECTED_MIC_FAILURE,
cbWLAN_STATUS_DISCONNECTED_ROAMING,
} cbWLAN_StatusDisconnectedInfo;
/**
@ -260,32 +296,9 @@ typedef enum {
* @ingroup wlan
*/
typedef enum {
cbWLAN_IOCTL_FIRST,
cbWLAN_IOCTL_SET_POWER_SAVE_MODE = cbWLAN_IOCTL_FIRST, //!< Set power mode @ref cbWLAN_IoctlPowerSaveMode
cbWLAN_IOCTL_GET_POWER_SAVE_MODE, //!< Get power mode @ref cbWLAN_IoctlPowerSaveMode
cbWLAN_IOCTL_SET_LISTEN_INTERVAL, //!< Set listen interval, integer value 0 - 16
cbWLAN_IOCTL_GET_LISTEN_INTERVAL, //!< Get listen interval, integer value 0 - 16
cbWLAN_IOCTL_SET_DTIM_ENABLE, //!< Set DTIM enable 0, disable 1 enable
cbWLAN_IOCTL_GET_DTIM_ENABLE, //!< Get DTIM enable 0, disable 1 enable
cbWLAN_IOCTL_SET_SLEEP_TIMEOUT, //!< Set enter power save entry delay (in ms). Power save mode will be entered only if there no activity during this delay
cbWLAN_IOCTL_GET_SLEEP_TIMEOUT, //!< Get enter power save entry delay (in ms). Power save mode will be entered only if there no activity during this delay
cbWLAN_IOCTL_LAST,
cbWLAN_IOCTL_SET_GSETTING = 1000, //!< Pipe to @ref cbWM_gSet.
cbWLAN_IOCTL_SET_TSETTING = 2000, //!< Pipe to @ref cbWM_tSet.
cbWLAN_IOCTL_GET_GSETTING = 3000, //!< Pipe to @ref cbWM_gGet.
cbWLAN_IOCTL_GET_TSETTING = 4000, //!< Pipe to @ref cbWM_tGet.
cbWLAN_IOCTL_FIRST
} cbWLAN_Ioctl;
/**
* Power save modes set using @ref cbWLAN_ioctl
*
* @ingroup wlan
*/
typedef enum {
cbWLAN_IOCTL_POWER_SAVE_MODE_OFF,
cbWLAN_IOCTL_POWER_SAVE_MODE_SLEEP,
cbWLAN_IOCTL_POWER_SAVE_MODE_DEEP_SLEEP
} cbWLAN_IoctlPowerSaveMode;
/**
* Start parameters indicated from WLAN driver for status indication
@ -306,6 +319,7 @@ typedef struct cbWLAN_StatusStartedInfo {
typedef struct cbWLAN_StatusConnectedInfo {
cbWLAN_MACAddress bssid; /**< BSSID of the BSS connected to. */
cbWLAN_Channel channel; /**< Operating channels of the BSS connected to. */
cb_uint16 mobilityDomainId;
} cbWLAN_StatusConnectedInfo;
/**
@ -335,7 +349,7 @@ typedef void (*cbWLAN_statusIndication)(void *callbackContext, cbWLAN_StatusIndi
/**
* Indication of received Ethernet data packet.
*
* @param callbackContext Context pointer provided in @ref cbWLAN_init.
* @param callbackContext Context pointer provided in @ref cbWLAN_registerPacketIndicationCallback.
* @param packetInfo Pointer to struct containing packet information and data pointers.
*/
typedef void (*cbWLAN_packetIndication)(void *callbackContext, cbWLAN_PacketIndicationInfo *packetInfo);
@ -343,7 +357,7 @@ typedef void (*cbWLAN_packetIndication)(void *callbackContext, cbWLAN_PacketIndi
/**
* Scan result indication from WLAN component.
*
* @param callbackContext Context pointer provided in @ref cbWLAN_init.
* @param callbackContext Context pointer provided in @ref cbWLAN_scan.
* @param bssDescriptor Pointer to struct containing scan result information.
* @param isLastResult @ref TRUE if scan scan is finished.
*/
@ -356,10 +370,9 @@ typedef void (*cbWLAN_scanIndication)(void *callbackContext, cbWLAN_ScanIndicati
/**
* Initialize WLAN component.
*
* @param callbackContext Context handle used in indication callbacks.
* @return @ref cbSTATUS_OK if successful, otherwise cbSTATUS_ERROR.
*/
cbRTSL_Status cbWLAN_init(void *callbackContext);
cbRTSL_Status cbWLAN_init();
/**
@ -399,6 +412,16 @@ cbRTSL_Status cbWLAN_connectWEP(cbWLAN_CommonConnectParameters *commonParams, cb
*/
cbRTSL_Status cbWLAN_connectWPAPSK(cbWLAN_CommonConnectParameters *commonParams, cbWLAN_WPAPSKConnectParameters *wpaParams);
/**
* Connect to access point with WPA Enterprise authentication.
* Connection progress is reported as @ref cbWLAN_statusIndication callbacks.
*
* @param commonParams Connection parameters.
* @param enterpriseParams WPA Enterprise specific connection parameters.
* @return @ref cbSTATUS_OK if call successful, otherwise cbSTATUS_ERROR.
*/
cbRTSL_Status cbWLAN_connectEnterprise(cbWLAN_CommonConnectParameters *commonParams, cbWLAN_EnterpriseConnectParameters *enterpriseParams);
/**
* Disconnect from access point or stop ongoing connection attempt.
* Disconnection progress is reported as @ref cbWLAN_statusIndication callback.
@ -545,6 +568,19 @@ cbRTSL_Status cbWLAN_getActiveChannelList(cbWLAN_ChannelList *channelList);
*/
cbRTSL_Status cbWLAN_ioctl(cbWLAN_Ioctl ioctl, void* value);
cbRTSL_Status cbWLAN_getVersion(cbWM_Version* version);
#if defined(CB_FEATURE_802DOT11R)
/**
* Called for changing the BSS
*
* @param params Parameter containing the BSS parameters.
*
* @return @ref cbSTATUS_OK if call successful, otherwise cbSTATUS_ERROR.
*/
cbRTSL_Status cbWLAN_changeBSS(cbWLAN_BSSChangeParameters params);
#endif
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,301 @@
/**
*---------------------------------------------------------------------------
* Copyright (c) 2016, u-blox Malmö, All Rights Reserved
* SPDX-License-Identifier: LicenseRef-PBL
*
* This file and the related binary are licensed under the
* Permissive Binary License, Version 1.0 (the "License");
* you may not use these files except in compliance with the License.
*
* You may obtain a copy of the License here:
* LICENSE-permissive-binary-license-1.0.txt and at
* https://www.mbed.com/licenses/PBL-1.0
*
* See the License for the specific language governing permissions and
* limitations under the License.
* Component : Wireless LAN driver
* File : cb_wlan_driver_config.h
*
* Description : OS related functions
*-------------------------------------------------------------------------*/
/**
* @file cb_wlan_driver_config.h Driver configuration.
* @ingroup port
*/
#ifndef _CB_WLAN_DRIVER_CONFIG_H_
#define _CB_WLAN_DRIVER_CONFIG_H_
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "cb_target.h"
#include "cb_status.h"
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================
* DEFINES
*=========================================================================*/
#define cbWLAN_ENABLE_802_11b
#define cbWLAN_ENABLE_802_11g
#define cbWLAN_ENABLE_802_11n
/*===========================================================================
* TYPES
*=========================================================================*/
#define cbTARGET_GSETTING_4_ADDRESS_MODE_STATION_DYNAMIC cb_BIT_0
#define cbTARGET_GSETTING_4_ADDRESS_MODE_STATION_ALWAYS cb_BIT_1
/**
* General settings and tuning parameters .
*
* @ingroup types
*/
typedef enum wm_gsetting_e {
cbTARGET_GSETTING_START = 0,
cbTARGET_GSETTING_PREAMBLE = cbTARGET_GSETTING_START, /**< 0 = Long preamble, 1 = Short preamble */
cbTARGET_GSETTING_MIN_SCAN_TIME, /**< Minimum scan time in TU per channel */
cbTARGET_GSETTING_MAX_SCAN_TIME, /**< Maximum scan time in TU per channel */
cbTARGET_GSETTING_SCAN_TYPE, /**< Use @ref cbWM_ScanType. */
cbTARGET_GSETTING_BEACON_INTERVAL, /**< Beacon interval for Ad-hoc/IBSS networks. */
cbTARGET_GSETTING_JOIN_FAILURE_TIMEOUT, /**< Time in beacons before the join procedure times out. */
cbTARGET_GSETTING_BT_COEX, /**< Bluetooth co-existence 0 = off, 1 = on */
cbTARGET_GSETTING_DATA_RATE, /**< Set the data rate to use. Use @ref cbWLAN_Rate */
cbTARGET_GSETTING_LINK_ADAPTION, /**< Dynamically adapt the data rate. 0 = off, 1 = on */
cbTARGET_GSETTING_POWER_SAVE, /**< 0 = off, 1 = Fast PSP, 2 = Max PSP */
cbTARGET_GSETTING_DTIM_ENABLE, /**< Enable DTIM when powersaving */
cbTARGET_GSETTING_QOS_ENABLE, /**< Enable QoS */
cbTARGET_GSETTING_RTS_THRESHOLD, /**< Set the RTS (Request to send) threshold */
cbTARGET_GSETTING_FRAGMENTATION_THRESHOLD, /**< Set the fragmentation threshold */
cbTARGET_GSETTING_TX_POWER, /**< Desired output power in dBm. */
cbTARGET_GSETTING_MAX_PASSIVE_SCAN_TIME, /**< Maximum scan time for passive scan */
cbTARGET_GSETTING_MODULE_TYPE, /**< Type of module. TODO: remove. Legacy parameter that shouldn't be possible to change. */
cbTARGET_GSETTING_SCAN_LISTEN_INTERVAL, /**< Listen interval between channel scans */
cbTARGET_GSETTING_SLEEP_TIMEOUT, /**< Only allow power save modes after this period of inactivity. Timeout in ms. Only used when power save is enabled */
cbTARGET_GSETTING_DOT11_SHORT_RETRY_LIMIT, /**< 802.11 short retry limit for station (dot11ShortRetryLimit). Bit 31-24 reserved, bit 23-16 EAPOL & Broadcast, bit 15-8 MGMT, bit 7-0 data. */
cbTARGET_GSETTING_DOT11_LONG_RETRY_LIMIT, /**< 802.11 long retry limit for station (dot11LongRetryLimit). Bit 31-24 reserved, bit 23-16 EAPOL & Broadcast, bit 15-8 MGMT, bit 7-0 data. */
cbTARGET_GSETTING_AP_DOT11_SHORT_RETRY_LIMIT, /**< 802.11 short retry limit for AP (dot11ShortRetryLimit). Bit 31-24 reserved, bit 23-16 EAPOL & Broadcast, bit 15-8 MGMT, bit 7-0 data. */
cbTARGET_GSETTING_AP_DOT11_LONG_RETRY_LIMIT, /**< 802.11 long retry limit for AP (dot11LongRetryLimit). Bit 31-24 reserved, bit 23-16 EAPOL & Broadcast, bit 15-8 MGMT, bit 7-0 data. */
cbTARGET_GSETTING_CHANNEL_TYPE, /**< 0-NO_HT, 1-HT20, 2-HT40MINUS, 3-HT40PLUS */
cbTARGET_GSETTING_PMF_STA, /**< Protected Management frame Option for STA*/
cbTARGET_GSETTING_REMAIN_ON_CHANNEL, /**< Set 0 disable, 1 enable */
cbTARGET_GSETTING_STA_TX_RATE_MASK, /**< TX rates for station. May be overridden if not supported by AP. Set to 0 for AP default. @sa cbWLAN_RateMask_e */
cbTARGET_GSETTING_RSSI_GOOD, /**< When to abort scanning and initiate connection */
cbTARGET_GSETTING_RSSI_BAD, /**< When to use BAD_RSSI_SCAN_YIELD_TIMEOUT for scanning between each channel for roaming */
cbTARGET_GSETTING_GOOD_RSSI_SCAN_YIELD_TIMEOUT, /**< Gap between each channel when doing background scan with a good connection */
cbTARGET_GSETTING_BAD_RSSI_SCAN_YIELD_TIMEOUT, /**< Gap between each channel when doing background scan with a bad connection */
cbTARGET_GSETTING_ROAM_BLACKLIST_LAST_BSSID_TIMEOUT, /**< How long a new connection to the last connected AP should be banned */
cbTARGET_GSETTING_FORCE_WORLD_MODE, /**< Set 0 disable, 1 enable */
cbTARGET_GSETTING_TX_PACKET_ACK_TIMEOUT_WD, /**< Max time for an Tx packet to not being acked by the radio before we send a soft-error event */
cbTARGET_GSETTING_CTS_PROTECTION, /** send CTS to self before transmission. 0 disable, 1 enable. */
cbTARGET_GSETTING_HIDDEN_SSID, /** Hidden ssid, 0 disable else enable. */
cbTARGET_GSETTING_AP_STA_INACTIVITY_TIMEOUT, /**< Aging period for Station in seconds */
cbTARGET_GSETTING_ROAMING_AREA_HYSTERESIS, /** Threshold between good and bad connection. */
cbTARGET_GSETTING_FT_MODE, /** 802.11r (FT) mode, 0 - Disabled, 1 - FT over air, 2 - FT over DS */
cbTARGET_GSETTING_4_ADDRESS_MODE, /** Bit0 - enable dynamic mode for station. Bit1 - always enable for station. */
cbTARGET_GSETTING_MAX,
} cbWM_GSETTING;
typedef enum targetConfigParams {
cbTARGET_CFG_FIRST,
cbTARGET_CFG_SET_POWER_SAVE_MODE = cbTARGET_CFG_FIRST, //!< Set power mode @ref cbWLAN_IoctlPowerSaveMode
cbTARGET_CFG_GET_POWER_SAVE_MODE, //!< Get power mode @ref cbWLAN_IoctlPowerSaveMode
cbTARGET_CFG_SET_LISTEN_INTERVAL, //!< Set listen interval, integer value 0 - 16
cbTARGET_CFG_GET_LISTEN_INTERVAL, //!< Get listen interval, integer value 0 - 16
cbTARGET_CFG_SET_DTIM_ENABLE, //!< Set DTIM enable 0, disable 1 enable
cbTARGET_CFG_GET_DTIM_ENABLE, //!< Get DTIM enable 0, disable 1 enable
cbTARGET_CFG_SET_SLEEP_TIMEOUT, //!< Set enter power save entry delay (in ms). Power save mode will be entered only if there no activity during this delay
cbTARGET_CFG_GET_SLEEP_TIMEOUT, //!< Get enter power save entry delay (in ms). Power save mode will be entered only if there no activity during this delay
cbTARGET_CFG_SET_RSSI_GOOD, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_GET_RSSI_GOOD, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_SET_RSSI_BAD, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_GET_RSSI_BAD, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_SET_GOOD_RSSI_YIELD_TMO, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_GET_GOOD_RSSI_YIELD_TMO, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_SET_BAD_RSSI_YIELD_TMO, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_GET_BAD_RSSI_YIELD_TMO, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_SET_BLACKLIST_LAST_BSSID_TIMEOUT, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_GET_BLACKLIST_LAST_BSSID_TIMEOUT, //!< SEE CORRESPONDING GSETTING
cbTARGET_CFG_LAST,
cbTARGET_CFG_SET_GSETTING = 1000, //!< Pipe to @ref cbWM_gSet.
cbTARGET_CFG_SET_TSETTING = 2000, //!< Pipe to @ref cbWM_tSet.
cbTARGET_CFG_GET_GSETTING = 3000, //!< Pipe to @ref cbWM_gGet.
cbTARGET_CFG_GET_TSETTING = 4000, //!< Pipe to @ref cbWM_tGet.
}cbTARGET_ConfigParams;
#define cbTARGET_GSETTING_REG(X) ((cb_uint32)((X) - cbTARGET_GSETTING_START))
/**
* Target specific settings and tuning parameters .
*
* @ingroup types
*/
typedef enum wm_tsetting_e {
cbTARGET_TSETTING_START = 1000,
cbTARGET_TSETTING_PS_LISTEN_INTERVAL = cbTARGET_TSETTING_START, /**< Powersave: Listen interval in beacons. */
cbTARGET_TSETTING_PS_FAST_PSP_TIMEOUT, /**< Powersave: In mode Fast PSP timeout in ms before entering PS. */
cbTARGET_TSETTING_ANTENNA_RECEIVE_DIVERSITY, /**< Enable receive antenna diversity. 0 = off, 1 = on. */
cbTARGET_TSETTING_QOS_WMM_NOACK, /**< Enable WMM QoS no-ack acknowledgment policy. 0 = normal ack, 1 = no-ack. */
cbTARGET_TSETTING_PS_BEACON_EARLY_TERMINATION, /**< Powersave: In Max PSP, use beacon early termination. */
cbTARGET_TSETTING_MAX,
} cbWM_TSETTING;
#define cbTARGET_TSETTING_REG(X) ((cb_uint32)((X) - cbTARGET_TSETTING_START))
/**
* Defines the type of scanning procedure.
* Passive scan will only listen for beacons.
* Active scan will send out a probe request
* and listen for both probe responses and beacons.
*
* @ingroup types
*/
typedef enum cbWM_ScanType_e {
cbWM_SCAN_INVALID,
cbWM_SCAN_ACTIVE,
cbWM_SCAN_PASSIVE,
} cbWM_ScanType;
/**
* Power save levels.
* @note Levels between 2 and cbWM_POWERSAVE_MAX are target specific.
*
* @ingroup types
*/
typedef enum cbWM_PowerSaveType_e {
cbWM_POWERSAVE_OFF = 0,
cbWM_POWERSAVE_FAST_PSP = 1,
cbWM_POWERSAVE_MAX_PSP = 2,
cbWM_POWERSAVE_MAX = cb_UINT8_MAX,
} cbWM_PowerSaveType;
/**
* Power save modes set using @ref cbWLAN_ioctl
*
* @ingroup wlan
*/
typedef enum {
cbTARGET_POWER_SAVE_MODE_OFF,
cbTARGET_POWER_SAVE_MODE_SLEEP,
cbTARGET_POWER_SAVE_MODE_DEEP_SLEEP
} cbTARGET_PowerSaveMode;
typedef enum {
cbWLAN_ONE_ANTENNA = 1,
cbWLAN_TWO_ANTENNAS
}cbWLAN_NUMBER_OF_ANTENNAS;
typedef enum {
cbWLAN_PRIMARY_ANTENNA_ONE = 1,
cbWLAN_PRIMARY_ANTENNA_TWO
}cbWLAN_PRIMARY_ANTENNA;
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
/**
* Get general tuning parameter.
*
* @param hTarget Handle to the current driver instance.
* @param setting setting to read.
* @return parameter value
*/
cb_uint32 cbTARGET_gGet(cbTARGET_Handle* hTarget, cbWM_GSETTING setting);
/**
* Set general tuning parameter.
*
* @param hTarget Handle to the current driver instance.
* @param setting setting to modify.
* @param value value to set.
*/
void cbTARGET_gSet(cbTARGET_Handle* hTarget, cbWM_GSETTING setting, cb_uint32 value);
/**
* Get target specific tuning parameter.
*
* @param hTarget Handle to the current driver instance.
* @param setting setting to read.
* @return parameter value
*/
cb_uint32 cbTARGET_tGet(cbTARGET_Handle* hTarget, cbWM_TSETTING setting);
/**
* Set target specific tuning parameter.
*
* @param hTarget Handle to the current driver instance.
* @param setting setting to modify.
* @param value value to set.
*/
void cbTARGET_tSet(cbTARGET_Handle* hTarget, cbWM_TSETTING setting, cb_uint32 value);
struct cb_wlan_configuration* cbTARGET_configuration_create();
cbRTSL_Status cbTARGET_configure(cbTARGET_Handle* hTarget, cbTARGET_ConfigParams parameter, void* value);
/*--------------------------------------------------------------------------
* Constants
*-------------------------------------------------------------------------*/
#define W_CONST_PREAMBLE (1)
#define W_CONST_LISTEN_INTERVAL (16)
#define W_CONST_MIN_SCAN_TIME (25)
#define W_CONST_MAX_SCAN_TIME (50)
#define W_CONST_SCAN_TYPE (cbWM_SCAN_ACTIVE)
#define W_CONST_BEACON_INTERVAL (100)
#define W_CONST_JOIN_FAILURE_TIMEOUT (600)
#define W_CONST_WLAN_BT_COEX (0)
#define W_CONST_DATA_RATE (cbWLAN_RATE_24)
#define W_CONST_LINK_ADAPTION (1)
#define W_CONST_POWER_SAVE (2)
#define W_CONST_DTIM_ENABLE (1)
#define W_CONST_QOS_ENABLE (1)
#define W_CONST_CHANNEL_TYPE (1) //HT20MHz
#define W_CONST_RTS_THRESHOLD (2347)
#define W_CONST_FRAGMENTATION_THRESHOLD (2346)
#define W_CONST_TX_POWER (15)
#define W_CONST_MAX_PASSIVE_SCAN_TIME (150)
#define W_CONST_SCAN_LISTEN_INTERVAL (150)
#define W_CONST_SLEEP_TIMEOUT (100) // Timeout in ms, 100ms timeout gives almost same throughput as without power save but still low power consumption
#define W_CONST_DEFAULT_MODULE_TYPE (cbWM_MODULE_UNKNOWN)
#define W_CONST_PMF_OPTIONAL (cbWLAN_PMF_OPTIONAL)
#define W_CONST_REMAIN_ON_CHANNEL (1) // Enabled
#define W_CONST_DEFAULT_STA_TX_RATES (0) // Use AP default
#define W_CONST_GOOD_RSSI (55)
#define W_CONST_BAD_RSSI (70)
#define W_CONST_GOOD_RSSI_SCAN_YIELD_TIMEOUT (1500)
#define W_CONST_BAD_RSSI_SCAN_YIELD_TIMEOUT (W_CONST_SCAN_LISTEN_INTERVAL)
#define W_CONST_BLACKLIST_LAST_BSSID_TIMEOUT (20) // Seconds
#define W_CONST_ROAMING_AREA_HYSTERESIS (3)
#define W_CONST_TX_PACKET_ACK_TIMEOUT (10000)
#define W_CONST_FT_MODE (2)
#define W_CONST_DEFAULT_FORCE_WORLD_MODE (0)
#define W_CONST_DEFAULT_AP_STA_INACTIVITY_TIMEOUT (120)
#define W_CONST_DEFAULT_DOT11_SHORT_RETRY_LIMIT (0x0a0a0a0aul)
#define W_CONST_DEFAULT_DOT11_LONG_RETRY_LIMIT (0x0a0a0a0aul)
#define W_CONST_DEFAULT_AP_DOT11_SHORT_RETRY_LIMIT (0x0a0a0a0aul)
#define W_CONST_DEFAULT_AP_DOT11_LONG_RETRY_LIMIT (0x0a0a0a0aul)
//Target specific values
#define W_CONST_PS_LISTEN_INTERVAL (0)
#define W_CONST_PS_FAST_PSP_TIMEOUT (50)
#define W_CONST_ANTENNA_RECEIVE_DIVERSITY (0)
#define W_CONST_PS_BEACON_EARLY_TERMINATION (0)
#define W_CONST_2_4GHZ_MGMT_RATE (cbWLAN_RATE_01)
#define W_CONST_5GHZ_MGMT_RATE (cbWLAN_RATE_06)
#define W_CONST_DEFAULT_RSSI (-100)
#ifdef __cplusplus
}
#endif
#endif /* _CB_SYSTEM_H_ */

View File

@ -61,15 +61,21 @@ extern "C" {
#define cbWLAN_OUI_SIZE 3
#define cbRATE_MASK_B (cbRATE_MASK_01 | cbRATE_MASK_02 | cbRATE_MASK_5_5 | cbRATE_MASK_11)
#define cbRATE_MASK_G (cbRATE_MASK_06 | cbRATE_MASK_09 | cbRATE_MASK_12 | cbRATE_MASK_18 | cbRATE_MASK_24 | cbRATE_MASK_36 | cbRATE_MASK_48 | cbRATE_MASK_54)
#define cbRATE_MASK_N (cbRATE_MASK_MCS0 | cbRATE_MASK_MCS1 | cbRATE_MASK_MCS2 | cbRATE_MASK_MCS3 | cbRATE_MASK_MCS4 | cbRATE_MASK_MCS5 | cbRATE_MASK_MCS6 | cbRATE_MASK_MCS7)
#define cbRATE_MASK_ALL (cbRATE_MASK_B | cbRATE_MASK_G | cbRATE_MASK_N)
#define cbRATE_MASK_B (cbRATE_MASK_01 | cbRATE_MASK_02 | cbRATE_MASK_5_5 | cbRATE_MASK_11)
#define cbRATE_MASK_G (cbRATE_MASK_06 | cbRATE_MASK_09 | cbRATE_MASK_12 | cbRATE_MASK_18 | cbRATE_MASK_24 | cbRATE_MASK_36 | cbRATE_MASK_48 | cbRATE_MASK_54)
#define cbRATE_MASK_A (cbRATE_MASK_G)
#define cbRATE_MASK_N (cbRATE_MASK_MCS0 | cbRATE_MASK_MCS1 | cbRATE_MASK_MCS2 | cbRATE_MASK_MCS3 | cbRATE_MASK_MCS4 | cbRATE_MASK_MCS5 | cbRATE_MASK_MCS6 | cbRATE_MASK_MCS7)
#define cbRATE_TX_MIMO (cbRATE_MASK_MCS8 | cbRATE_MASK_MCS9 | cbRATE_MASK_MCS10 | cbRATE_MASK_MCS11 | cbRATE_MASK_MCS12 | cbRATE_MASK_MCS13 | cbRATE_MASK_MCS14 | cbRATE_MASK_MCS15)
#define cbRATE_TX_WIDE (cbRATE_MASK_WIDE)
#define cbRATE_MASK_ALL (cbRATE_MASK_B | cbRATE_MASK_G | cbRATE_MASK_N | cbRATE_TX_MIMO | cbRATE_TX_WIDE)
#define cbWLAN_MAX_CHANNEL_LIST_LENGTH 38
#define cbWLAN_TX_POWER_AUTO 0xFF
#define cbWLAN_PMF_MFPR cb_BIT_6 // Bit 6: Management Frame Protection Required (MFPR)
#define cbWLAN_PMF_MFPC cb_BIT_7 // Bit 7: Management Frame Protection Capable (MFPC).
/*===========================================================================
* TYPES
*=========================================================================*/
@ -85,8 +91,31 @@ typedef enum cbWLAN_EncryptionMode_e {
cbWLAN_ENC_WEP128,
cbWLAN_ENC_TKIP,
cbWLAN_ENC_AES,
cbWLAN_ENC_BIP,
} cbWLAN_EncryptionMode;
typedef enum cbWLAN_CipherSuite {
cbWLAN_CIPHER_SUITE_NONE = 0x00,
cbWLAN_CIPHER_SUITE_WEP64 = 0x01,
cbWLAN_CIPHER_SUITE_WEP128 = 0x02,
cbWLAN_CIPHER_SUITE_TKIP = 0x04,
cbWLAN_CIPHER_SUITE_AES_CCMP = 0x08,
cbWLAN_CIPHER_SUITE_BIP = 0x10,
} cbWLAN_CipherSuite;
typedef enum cbWLAN_AuthenticationSuite {
cbWLAN_AUTHENTICATION_SUITE_NONE = 0x0000,
cbWLAN_AUTHENTICATION_SUITE_SHARED_SECRET = 0x0001,
cbWLAN_AUTHENTICATION_SUITE_PSK = 0x0002,
cbWLAN_AUTHENTICATION_SUITE_8021X = 0x0004,
cbWLAN_AUTHENTICATION_SUITE_USE_WPA = 0x0008,
cbWLAN_AUTHENTICATION_SUITE_USE_WPA2 = 0x0010,
cbWLAN_AUTHENTICATION_SUITE_PSK_SHA256 = 0x0020,
cbWLAN_AUTHENTICATION_SUITE_8021X_SHA256 = 0x0040,
cbWLAN_AUTHENTICATION_SUITE_8021X_FT = 0x0080,
cbWLAN_AUTHENTICATION_SUITE_PSK_FT = 0x0100,
} cbWLAN_AuthenticationSuite;
/**
* Enterprise authentication mode.
@ -206,6 +235,8 @@ enum cbWLAN_Rate_e {
cbWLAN_RATE_MCS13, // 26
cbWLAN_RATE_MCS14, // 27
cbWLAN_RATE_MCS15, // 28
cbWLAN_RATE_MAX, // 29
cbWLAN_RATE_UNSUPPORTED = 0xff
};
/**
@ -242,6 +273,7 @@ enum cbWLAN_RateMask_e {
cbRATE_MASK_MCS5 = 0x00020000,
cbRATE_MASK_MCS6 = 0x00040000,
cbRATE_MASK_MCS7 = 0x00080000,
//TX MIMO RATES
cbRATE_MASK_MCS8 = 0x00100000,
cbRATE_MASK_MCS9 = 0x00200000,
cbRATE_MASK_MCS10 = 0x00400000,
@ -250,8 +282,11 @@ enum cbWLAN_RateMask_e {
cbRATE_MASK_MCS13 = 0x02000000,
cbRATE_MASK_MCS14 = 0x04000000,
cbRATE_MASK_MCS15 = 0x08000000,
//TX RATE USE WIDE CHANNEL
cbRATE_MASK_WIDE = 0x80000000
};
/**
* Access categories
*
@ -271,8 +306,16 @@ typedef enum cbWLAN_AccessCategory_e {
cbWLAN_AC_NC = 7, /**< Voice (Network Control)*/
} cbWLAN_AccessCategory;
/**
* Fast Transition (802.11r) modes.
*
* @ingroup wlantypes
*/
typedef enum cbWLAN_FTMode_e {
cbWLAN_FT_OFF,
cbWLAN_FT_OVER_AIR,
cbWLAN_FT_OVER_DS,
} cbWLAN_FTMode;
/**
* connectBlue Hardware Identification
*
@ -337,6 +380,7 @@ typedef enum cbWLAN_OperationalMode_e {
typedef enum cbWLAN_KeyType_e {
cbWLAN_KEY_UNICAST,
cbWLAN_KEY_BROADCAST,
cbWLAN_KEY_IGTK,
} cbWLAN_KeyType;
typedef enum {
@ -353,6 +397,80 @@ typedef enum {
cbWLAN_AP_MODE_ENTERPRISE,
} cbWLAN_ApMode;
#if defined(CB_FEATURE_802DOT11R)
/**
* Description of the Mobility Domain Information Element
*
* @ingroup wlantypes
*/
cb_PACKED_STRUCT_BEGIN(cbWLAN_MDInformation) {
cb_uint8 eId;
cb_uint8 len;
cb_uint16 MDID;
cb_uint8 FtCapabilityPolicy;
} cb_PACKED_STRUCT_END(cbWLAN_MDInformation);
/**
* Description of the Timeout Interval Information Element
*
* @ingroup wlantypes
*/
cb_PACKED_STRUCT_BEGIN(cbWLAN_TimeOutInformation){
cb_uint8 eId;
cb_uint8 len;
cb_uint8 timeOutType;
cb_uint32 value;
} cb_PACKED_STRUCT_END(cbWLAN_TimeOutInformation);
/**
* Description of the Mobility Domain Information Element
*
* @ingroup wlantypes
*/
cb_PACKED_STRUCT_BEGIN(cbWLAN_FtInformation){
cb_uint8 eId;
cb_uint8 len;
cb_uint16 micControl;
cb_uint8 mic[16];
cb_uint8 ANonce[32];
cb_uint8 SNonce[32];
cb_uint8 optionalParams[174]; // length field can maximum be 256, therefore optional params can be max 172 bytes
} cb_PACKED_STRUCT_END(cbWLAN_FtInformation);
typedef struct cbWLAN_BSSChangeParameters {
cbWLAN_MACAddress currentBssid; /**< BSSID of connected AP. > */
cbWLAN_MACAddress targetBssid; /**< BSSID to connect to. > */
cbWLAN_Channel channel; /**< The channel the BSS is located on. > */
cb_uint32 reAssocDeadline; /**< Reassociation Deadline time*/
} cbWLAN_BSSChangeParameters;
#endif
//#if defined(CB_FEATURE_802DOT11W)
typedef enum {
cbWLAN_PMF_DISABLE = 0, /**< MFPC = 0, MFPR = 0 */
cbWLAN_PMF_OPTIONAL = 1, /**< MFPC = 1, MFPR = 0 */
cbWLAN_PMF_REQUIRED = 2, /**< MFPC = 1, MFPR = 1 */
} cbWLAN_PMF;
//#endif
typedef enum cbAP_KdeType_e {
RESERVED,
GTK_KDE,
RESERVED_2,
MAC_ADDRESS_KDE,
PMKID_KDE,
SMK_KDE,
NONCE_KDE,
LIFETIME_KDE,
ERROR_KDE,
IGTK_KDE,
KEY_ID_KDE,
} cbAP_KdeType;
/**
* Ethernet header
*
@ -467,6 +585,17 @@ typedef struct cbWM_TxPowerSettings_s {
cbWLAN_TxPower maxTxPowerLevel;
} cbWM_TxPowerSettings;
/**
* Describes the startup settings needed to boot properly.
*
* @ingroup types
*/
typedef struct cbWM_BootParameters_s {
cbWM_TxPowerSettings txPowerSettings;
cb_uint8 primaryAntenna;
cb_uint8 numberOfAntennas;
} cbWM_BootParameters;
/**
* Describes an access point.
*
@ -487,6 +616,10 @@ typedef struct cbWLAN_ApStaInformation {
cbWLAN_MACAddress MAC;
} cbWLAN_ApStaInformation;
typedef struct cbWLAN_HTCapabilities_st {
cbWLAN_RateMask rates;
cb_uint16 info;
}cbWLAN_HTCapabilities;
/*---------------------------------------------------------------------------
* VARIABLE DECLARATIONS
*-------------------------------------------------------------------------*/
@ -498,7 +631,6 @@ extern const cb_uint8 OUI_Epigram[cbWLAN_OUI_SIZE];
extern const cb_uint8 OUI_ConnectBlue[cbWLAN_OUI_SIZE];
extern const cb_uint8 OUI_IEEE8021[cbWLAN_OUI_SIZE];
extern const cb_uint8 PATTERN_HTInformationDraft[1];
extern const cb_uint8 PATTERN_TKIP[2];
extern const cb_uint8 PATTERN_WME_IE[3];
extern const cb_uint8 PATTERN_WME_PE[3];
@ -527,7 +659,7 @@ cbWLAN_Band cbWLAN_getBandFromChannel(cbWLAN_Channel channel);
* @param channel The channel to be queried for rates.
* @return The valid rates @ref cbWLAN_RateMask for the requested channel.
*/
cbWLAN_RateMask cbWLAN_getRatesForChannel(cbWLAN_Channel channel);
cbWLAN_RateMask cbWLAN_getRatesForChannel(cbWLAN_Channel channel, cb_uint8 numberOfAntennas);
/**
* Checks is the input rate is a 802.11n rate or not.
@ -544,6 +676,20 @@ cb_boolean cbWLAN_isNRate(cbWLAN_Rate rate);
*/
cb_boolean cbWLAN_isValidChannel(cbWLAN_Channel channel);
/**
* Checks if a channel is valid for HT40-
*
* @return @ref TRUE if the channel is valid. @ref FALSE otherwise.
*/
cb_boolean cbWLAN_isValidHT40MinusChannel(cbWLAN_Channel channel);
/**
* Checks if a channel is valid for HT40+
*
* @return @ref TRUE if the channel is valid. @ref FALSE otherwise.
*/
cb_boolean cbWLAN_isValidHT40PlusChannel(cbWLAN_Channel channel);
#ifdef __cplusplus
}
#endif

View File

@ -1,345 +0,0 @@
#if DEVICE_EMAC
#include <stdio.h>
#include "cb_main.h"
#include "cb_wlan.h"
#include "cb_wlan_types.h"
#include "cb_otp.h"
#include "cb_wlan_target_data.h"
#include "emac_api.h"
#include "mbed_assert.h"
#include "rtos.h"
#include "mbed_events.h"
/*===========================================================================
* DEFINES
*=========================================================================*/
#define WIFI_EMAC_API_MTU_SIZE (1500U)
/*===========================================================================
* TYPES
*=========================================================================*/
typedef struct {
emac_link_input_fn wifi_input_cb;
emac_link_state_change_fn wifi_state_cb;
void* link_input_user_data;
void* link_state_user_data;
bool linkStateRegistered;
} wifi_emac_api_s;
/*===========================================================================
* DECLARATIONS
*=========================================================================*/
static void statusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data);
static void packetIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo);
static cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame);
static cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame);
static cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size);
static void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame);
static cb_uint32 handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame);
static cb_uint8 handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame);
static uint32_t wifi_get_mtu_size(emac_interface_t *emac);
static void wifi_get_ifname(emac_interface_t *emac, char *name, uint8_t size);
static uint8_t wifi_get_hwaddr_size(emac_interface_t *emac);
static void wifi_get_hwaddr(emac_interface_t *emac, uint8_t *addr);
static void wifi_set_hwaddr(emac_interface_t *emac, uint8_t *addr);
static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf);
static bool wifi_power_up(emac_interface_t *emac);
static void wifi_power_down(emac_interface_t *emac);
static void wifi_set_link_input_cb(emac_interface_t *emac, emac_link_input_fn input_cb, void *data);
static void wifi_set_link_state_cb(emac_interface_t *emac, emac_link_state_change_fn state_cb, void *data);
/*===========================================================================
* DEFINITIONS
*=========================================================================*/
static wifi_emac_api_s _admin;
static const char _ifname[] = "WL0";
const emac_interface_ops_t wifi_emac_interface = {
.get_mtu_size = wifi_get_mtu_size,
.get_ifname = wifi_get_ifname,
.get_hwaddr_size = wifi_get_hwaddr_size,
.get_hwaddr = wifi_get_hwaddr,
.set_hwaddr = wifi_set_hwaddr,
.link_out = wifi_link_out,
.power_up = wifi_power_up,
.power_down = wifi_power_down,
.set_link_input_cb = wifi_set_link_input_cb,
.set_link_state_cb = wifi_set_link_state_cb
};
static emac_interface_t* _intf = NULL;
static const cbWLANTARGET_Callback _wlanTargetCallback =
{
handleWlanTargetCopyFromDataFrame,
handleWlanTargetCopyToDataFrame,
handleWlanTargetAllocDataFrame,
handleWlanTargetFreeDataFrame,
handleWlanTargetGetDataFrameSize,
handleWlanTargetGetDataFrameTID
};
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
static void statusIndication(void *dummy, cbWLAN_StatusIndicationInfo status, void *data)
{
bool linkUp = false;
bool sendCb = true;
(void)dummy;
(void)data;
switch (status) {
case cbWLAN_STATUS_CONNECTED:
case cbWLAN_STATUS_AP_STA_ADDED:
linkUp = true;
break;
case cbWLAN_STATUS_STOPPED:
case cbWLAN_STATUS_ERROR:
case cbWLAN_STATUS_DISCONNECTED:
case cbWLAN_STATUS_CONNECTION_FAILURE:
break;
case cbWLAN_STATUS_CONNECTING:
default:
sendCb = false;
break;
}
if (sendCb) {
_admin.wifi_state_cb(_admin.link_state_user_data, linkUp);
}
}
static void packetIndication(void *dummy, cbWLAN_PacketIndicationInfo *packetInfo)
{
(void)dummy;
_admin.wifi_input_cb(_admin.link_input_user_data, (void*)packetInfo->rxData);
}
static cb_boolean handleWlanTargetCopyFromDataFrame(uint8_t* buffer, cbWLANTARGET_dataFrame* frame, uint32_t size, uint32_t offsetInFrame)
{
void* dummy = NULL;
emac_stack_mem_t** phead = (emac_stack_mem_chain_t **)&frame;
emac_stack_mem_t* pbuf;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
while (pbuf != NULL) {
if ((pbufOffset + emac_stack_mem_len(dummy, pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, emac_stack_mem_len(dummy, pbuf) - (offsetInFrame - pbufOffset));
memcpy(buffer, (int8_t *)emac_stack_mem_ptr(dummy, pbuf) + (offsetInFrame - pbufOffset), copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
break;
}
pbufOffset += emac_stack_mem_len(dummy, pbuf);
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
}
while (pbuf != NULL && bytesCopied < size) {
copySize = cb_MIN(emac_stack_mem_len(dummy, pbuf), size - bytesCopied);
memcpy(buffer, emac_stack_mem_ptr(dummy, pbuf), copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
}
MBED_ASSERT(bytesCopied <= size);
return (bytesCopied == size);
}
static cb_boolean handleWlanTargetCopyToDataFrame(cbWLANTARGET_dataFrame* frame, uint8_t* buffer, uint32_t size, uint32_t offsetInFrame)
{
void* dummy = NULL;
emac_stack_mem_t** phead = (emac_stack_mem_chain_t **)&frame;
emac_stack_mem_t* pbuf;
uint32_t copySize, bytesCopied = 0, pbufOffset = 0;
MBED_ASSERT(frame != NULL);
MBED_ASSERT(buffer != NULL);
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
while (pbuf != NULL) {
if ((pbufOffset + emac_stack_mem_len(dummy, pbuf)) >= offsetInFrame) {
copySize = cb_MIN(size, emac_stack_mem_len(dummy, pbuf) - (offsetInFrame - pbufOffset));
memcpy((uint8_t *)emac_stack_mem_ptr(dummy, pbuf) + (offsetInFrame - pbufOffset), buffer, copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
break;
}
pbufOffset += emac_stack_mem_len(dummy, pbuf);
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
}
while (pbuf != NULL && bytesCopied < size) {
copySize = cb_MIN(emac_stack_mem_len(dummy, pbuf), size - bytesCopied);
memcpy(emac_stack_mem_ptr(dummy, pbuf), buffer, copySize);
buffer += copySize;
bytesCopied += copySize;
pbuf = emac_stack_mem_chain_dequeue(dummy, phead);
}
MBED_ASSERT(bytesCopied <= size);
return (bytesCopied == size);
}
static cbWLANTARGET_dataFrame* handleWlanTargetAllocDataFrame(uint32_t size)
{
void* dummy = NULL;
return (cbWLANTARGET_dataFrame*)emac_stack_mem_alloc(dummy, size, 0);
}
static void handleWlanTargetFreeDataFrame(cbWLANTARGET_dataFrame* frame)
{
void* dummy = NULL;
emac_stack_mem_free(dummy, (emac_stack_mem_t*)frame);
}
static uint32_t handleWlanTargetGetDataFrameSize(cbWLANTARGET_dataFrame* frame)
{
void* dummy = NULL;
return emac_stack_mem_chain_len(dummy, (emac_stack_mem_t*)frame);
}
static uint8_t handleWlanTargetGetDataFrameTID(cbWLANTARGET_dataFrame* frame)
{
(void)frame;
return (uint8_t)cbWLAN_AC_BE;
}
/*===========================================================================
* API FUNCTIONS
*=========================================================================*/
static uint32_t wifi_get_mtu_size(emac_interface_t *emac)
{
(void)emac;
return WIFI_EMAC_API_MTU_SIZE;
}
static void wifi_get_ifname(emac_interface_t *emac, char *name, uint8_t size)
{
(void)emac;
MBED_ASSERT(name != NULL);
memcpy((void*)name, (void*)&_ifname, cb_MIN(size, sizeof(_ifname)));
}
static uint8_t wifi_get_hwaddr_size(emac_interface_t *emac)
{
(void)emac;
return sizeof(cbWLAN_MACAddress);
}
static void wifi_get_hwaddr(emac_interface_t *emac, uint8_t *addr)
{
(void)emac;
cbOTP_read(cbOTP_MAC_WLAN, sizeof(cbWLAN_MACAddress), addr);
}
static void wifi_set_hwaddr(emac_interface_t *emac, uint8_t *addr)
{
(void)emac;
(void)addr;
// Do nothing, not possible to change the address
}
static void send_packet(emac_interface_t *emac, void *buf)
{
cbWLAN_sendPacket(buf);
emac_stack_mem_free(emac,buf);
}
static bool wifi_link_out(emac_interface_t *emac, emac_stack_mem_t *buf)
{
(void)emac;
// Break call chain to avoid the driver affecting stack usage for the IP stack thread too much
emac_stack_mem_t *new_buf = emac_stack_mem_alloc(emac, emac_stack_mem_chain_len(emac,buf),0);
if (new_buf != NULL) {
emac_stack_mem_copy(emac, new_buf, buf);
int id = cbMAIN_getEventQueue()->call(send_packet, emac, new_buf);
if (id != 0) {
cbMAIN_dispatchEventQueue();
}
else {
emac_stack_mem_free(emac, new_buf);
}
}
return true;
}
static bool wifi_power_up(emac_interface_t *emac)
{
(void)emac;
return true;
}
static void wifi_power_down(emac_interface_t *emac)
{
(void)emac;
}
static void wifi_set_link_input_cb(emac_interface_t *emac, emac_link_input_fn input_cb, void *data)
{
void *dummy = NULL;
(void)emac;
_admin.wifi_input_cb = input_cb;
_admin.link_input_user_data = data;
cbMAIN_driverLock();
cbWLAN_registerPacketIndicationCallback(packetIndication, dummy);
cbMAIN_driverUnlock();
}
static void wifi_set_link_state_cb(emac_interface_t *emac, emac_link_state_change_fn state_cb, void *data)
{
cbRTSL_Status result;
void *dummy = NULL;
(void)emac;
_admin.wifi_state_cb = state_cb;
_admin.link_state_user_data = data;
if (!_admin.linkStateRegistered) {
cbMAIN_driverLock();
result = cbWLAN_registerStatusCallback(statusIndication, dummy);
cbMAIN_driverUnlock();
if (result == cbSTATUS_OK) {
_admin.linkStateRegistered = true;
}
}
}
emac_interface_t* wifi_emac_get_interface()
{
if (_intf == NULL) {
_intf = (emac_interface_t*)malloc(sizeof(emac_interface_t));
if (_intf) {
_intf->hw = NULL;
memcpy((void*)&_intf->ops, &wifi_emac_interface, sizeof(wifi_emac_interface));
}
}
return _intf;
}
void wifi_emac_init_mem(void)
{
cbWLANTARGET_registerCallbacks((cbWLANTARGET_Callback*)&_wlanTargetCallback);
}
#endif

View File

@ -1,10 +0,0 @@
#include "emac_api.h"
#ifndef WIFI_EMAC_API_H
#define WIFI_EMAC_API_H
emac_interface_t* wifi_emac_get_interface();
void wifi_emac_init_mem();
#endif

View File

@ -2144,8 +2144,8 @@
"inherits": ["FAMILY_STM32"],
"core": "Cortex-M4F",
"extra_labels_add": ["STM32F4", "STM32F439", "STM32F439ZI","STM32F439xx", "STM32F439xI", "STM_EMAC"],
"macros": ["MBEDTLS_CONFIG_HW_SUPPORT", "HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000", "CB_INTERFACE_SDIO","CB_CHIP_WL18XX","SUPPORT_80211D_ALWAYS","WLAN_ENABLED","MBEDTLS_ARC4_C","MBEDTLS_DES_C","MBEDTLS_MD4_C","MBEDTLS_MD5_C","MBEDTLS_SHA1_C"],
"device_has_add": ["CAN", "EMAC", "TRNG", "FLASH"],
"macros": ["MBEDTLS_CONFIG_HW_SUPPORT", "HSE_VALUE=24000000", "HSE_STARTUP_TIMEOUT=5000", "CB_INTERFACE_SDIO","CB_CHIP_WL18XX","SUPPORT_80211D_ALWAYS","WLAN_ENABLED","CB_FEATURE_802DOT11W","CB_FEATURE_802DOT11R","MBEDTLS_ARC4_C","MBEDTLS_DES_C","MBEDTLS_MD4_C","MBEDTLS_MD5_C","MBEDTLS_SHA1_C"],
"device_has_add": ["CAN", "EMAC", "TRNG", "FLASH", "WIFI"],
"device_has_remove": ["RTC", "SLEEP"],
"features": ["LWIP"],
"device_name": "STM32F439ZI",