Merge pull request #4338 from andreaslarssonublox/ublox_odin_driver_os_5_v1.3_rc2

u-blox ODIN driver v1.3 rc2 for mbed OS 5
pull/4273/head
Martin Kojtal 2017-05-19 08:42:14 +01:00 committed by GitHub
commit 5d0ce3c531
16 changed files with 470 additions and 115 deletions

View File

@ -18,20 +18,26 @@
#define ODIN_WIFI_INTERFACE_H
#include "WiFiInterface.h"
#include "Callback.h"
#include "mbed_events.h"
#include "rtos.h"
#include "cmsis_os.h"
#include "emac_api.h"
#include "mbed.h"
#include "netsocket/WiFiAccessPoint.h"
#include "nsapi_types.h"
#include "lwip/netif.h"
#include "rtos.h"
#include "cb_wlan.h"
typedef Queue<void*, 1> MsgQueue;
#define ODIN_WIFI_MAX_MAC_ADDR_STR (18)
#define ODIN_WIFI_SCAN_CACHE_SIZE (5)
class OdinWiFiInterface;
struct PrivContext;
struct odin_wifi_msg_s;
struct user_connect_s;
struct user_scan_s;
struct user_ap_start_s;
struct wlan_status_started_s;
struct wlan_status_connected_s;
struct wlan_status_connection_failure_s;
struct wlan_scan_indication_s;
/** OdinWiFiInterface class
* Implementation of the WiFiInterface for the ODIN-W2 module
@ -74,7 +80,8 @@ public:
* @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 connect(const char *ssid,
virtual nsapi_error_t connect(
const char *ssid,
const char *pass,
nsapi_security_t security = NSAPI_SECURITY_NONE,
uint8_t channel = 0);
@ -115,7 +122,7 @@ public:
/** Get the local network mask
*
* @return Null-terminated representation of the local network mask
* or null if no network mask has been recieved
* or null if no network mask has been received
*/
virtual const char *get_netmask();
@ -177,44 +184,161 @@ public:
* specified since the Wi-Fi driver might need some time to finish and cleanup.
* @return 0 on success, negative error code on failure
*/
virtual void set_timeout(int timeout);
virtual nsapi_error_t set_timeout(int ms);
virtual NetworkStack *get_stack();
protected:
private:
nsapi_error_t connect_async(const char *ssid,
const char *pass,
nsapi_security_t security = NSAPI_SECURITY_NONE,
uint8_t channel = 0,
void *data = NULL,
unsigned timeout = 0);
bool start(bool debug);
bool stop();
char _mac_addr_str[18];
// Private context to share between C and C++ calls
PrivContext* _priv_context;
const char *_ssid;
const char *_pass;
char _ip_address[IPADDR_STRLEN_MAX];
char _netmask[IPADDR_STRLEN_MAX];
char _gateway[IPADDR_STRLEN_MAX];
nsapi_security_t _security;
uint8_t _channel;
bool _use_dhcp;
int _timeout;
// Event queue when the driver context need to be used
EventQueue* _odin_event_queue;
int32_t target_id;
// Event queue for sending start up and connection events from driver to this class
MsgQueue _event_queue;
// Message queue for sending scan events from driver to this class
osMessageQId _scan_msg_queue_id;
osMessageQDef_t _queue_def;
enum OdinWifiState {
S_NOT_INITIALISED = 1,
S_WAIT_START,
S_STARTED,
S_WAIT_STOP,
S_STA_IDLE,
S_STA_WAIT_CONNECT,
S_STA_CONNECTED,
S_STA_DISCONNECTED_WAIT_CONNECT,
S_STA_CONNECTION_FAIL_WAIT_DISCONNECT,
//S_STA_LINK_LOSS_WAIT_DISCONNECT,
S_STA_WAIT_DISCONNECT,
S_AP_IDLE,
S_AP_WAIT_START,
S_AP_STARTED,
S_AP_WAIT_STOP,
S_AP_FAIL_WAIT_STOP,
S_AP_WAIT_DRV_STOP,
S_AP_WAIT_DRV_START,
S_INVALID
};
struct sta_s {
const char *ssid;
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 {
const char *ssid;
const char *passwd;
nsapi_security_t security;
uint8_t channel;
bool use_dhcp;
char ip_address[IPADDR_STRLEN_MAX];
char netmask[IPADDR_STRLEN_MAX];
char gateway[IPADDR_STRLEN_MAX];
int cnt_connected;
nsapi_error_t error_code;
};
struct scan_cache_s {
int count;
uint8_t last_channel;
cbWLAN_MACAddress bssid[ODIN_WIFI_SCAN_CACHE_SIZE];
};
OdinWifiState entry_connect_fail_wait_disconnect();
OdinWifiState entry_wait_connect();
OdinWifiState entry_wait_disconnect();
//OdinWifiState entry_link_loss_wait_disconnect(void);
OdinWifiState entry_ap_wait_start();
OdinWifiState entry_ap_started();
OdinWifiState entry_ap_wait_stop();
OdinWifiState entry_ap_fail_wait_stop();
OdinWifiState entry_ap_wait_drv_stop();
OdinWifiState entry_ap_wait_drv_start();
void handle_in_msg();
void handle_cached_msg();
void handle_user_connect(user_connect_s *user_connect);
void handle_user_disconnect();
void handle_user_scan(user_scan_s *user_scan);
void handle_user_connect_timeout();
void handle_user_stop();
void handle_user_ap_start(user_ap_start_s *user_ap_start);
void handle_user_ap_stop();
void handle_wlan_status_started(wlan_status_started_s *start);
void handle_wlan_status_stopped(void);
void handle_wlan_status_error(void);
void handle_wlan_status_connecting(void);
void handle_wlan_status_connected(wlan_status_connected_s *wlan_connect);
void handle_wlan_status_connection_failure(wlan_status_connection_failure_s *connect_failure);
void handle_wlan_status_disconnected(void);
void handle_wlan_scan_indication();
void handle_wlan_status_ap_up();
void handle_wlan_status_ap_down();
void init(bool debug);
nsapi_error_t wlan_set_channel(uint8_t channel);
nsapi_error_t wlan_connect(
const char *ssid,
const char *passwd,
nsapi_security_t security);
nsapi_error_t wlan_ap_start(
const char *ssid,
const char *pass,
nsapi_security_t security,
uint8_t channel);
void timeout_user_connect();
void update_scan_list(cbWLAN_ScanIndicationInfo *scan_info);
void send_user_response_msg(unsigned int type, nsapi_error_t error_code);
void wlan_status_indication(cbWLAN_StatusIndicationInfo status, void *data);
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;
OdinWifiState _state_sta;
OdinWifiState _state_ap;
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;
cbWLAN_StatusDisconnectedInfo _wlan_status_disconnected_info;
bool _scan_active;
WiFiAccessPoint *_scan_list;
nsapi_size_t _scan_list_size;
nsapi_size_t _scan_list_cnt;
struct scan_cache_s _scan_cache;
friend struct wlan_callb_s;
Mutex _mutex;
Queue<odin_wifi_msg_s, 6> _in_queue;
Queue<odin_wifi_msg_s, 1> _out_queue;
Queue<odin_wifi_msg_s, 1> _cache_queue;
MemoryPool<odin_wifi_msg_s, 7> *_msg_pool;
Thread _thread;
//Timeout _timeout; //Randomly lost interrupts/callbacks; replaced by Timer
Timer _timer;
bool _debug;
int _dbg_timeout;
};
#endif

View File

@ -1,5 +1,5 @@
/*---------------------------------------------------------------------------
* Copyright (c) 2016, u-blox Malmö, All Rights Reserved
* Copyright (c) 2016, u-blox Malmö, All Rights Reserved
* SPDX-License-Identifier: LicenseRef-PBL
*
* This file and the related binary are licensed under the
@ -65,6 +65,11 @@
#define PACKET_TYPE_ALL (PACKET_TYPE_DM1 | PACKET_TYPE_DH1 | PACKET_TYPE_DM3 | PACKET_TYPE_DH3 | PACKET_TYPE_DM5 | PACKET_TYPE_DH5)
#define BD_ADDR_IS_STATIC_RANDOM(BdAddress) ((BdAddress[0] & 0xC0) == 0xC0)
#define BD_ADDR_IS_NON_RESOLVABLE(BdAddress) ((BdAddress[0] & 0xC0) == 0x00)
#define BD_ADDR_IS_RESOLVABLE(BdAddress) ((BdAddress[0] & 0xC0) == 0x40)
#define BT_INVALID_STATIC_LINK_KEY (0)
/*===========================================================================
* TYPES
*=========================================================================*/

View File

@ -129,6 +129,17 @@ 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);
@ -156,7 +167,7 @@ typedef struct
typedef void(*cbBCM_RoleDiscoveryCallback)(
cbBCM_Handle handle,
cb_int8 status,
cb_int8 role);
cb_uint8 role);
typedef void (*cbBCM_RssiCallback)(
cbBCM_Handle handle,
@ -226,6 +237,13 @@ typedef void(*cbBCM_LinkQualityCallback)(
cbBCM_LinkQualityEvt linkQualityEvt,
uint8 linkQuality);
typedef void(*cbBCM_ServiceClassEnabled)(cb_uint8 serviceChannel);
typedef void(*cbBCM_SetFlowSpecCallback)(
cb_uint8 status,
cbBCM_Handle handle,
cbBCM_FlowSpecParams parameters);
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
@ -245,12 +263,14 @@ extern void cbBCM_init(void);
* @param pServerChannel Pointer to return variable. The server channel is used to identify
* incoming connections.
* @param pConnectionCallback Callback structure for connection management.
* @param pServiceClassEnabled Callback structure to inform when service is running.
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_enableServerProfileSpp(
cb_char *pServiceName,
cb_uint8 *pServerChannel,
cbBCM_ConnectionCallback *pConnectionCallback);
cbBCM_ConnectionCallback *pConnectionCallback,
cbBCM_ServiceClassEnabled pServiceClassEnabled);
/**
* Enable a Dial Up Networking Profile (DUN)service record to
@ -260,12 +280,14 @@ extern cb_int32 cbBCM_enableServerProfileSpp(
* @param pServerChannel Pointer to return variable. The server channel is used to identify
* incoming connections.
* @param pConnectionCallback Callback structure for connection management.
* @param pServiceClassEnabled Callback structure to inform when service is running.
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_enableServerProfileDun(
cb_char *pServiceName,
cb_uint8 *pServerChannel,
cbBCM_ConnectionCallback *pConnectionCallback);
cbBCM_ConnectionCallback *pConnectionCallback,
cbBCM_ServiceClassEnabled pServiceClassEnabled);
/**
* Enable a service record with an application specific UUID.
@ -276,13 +298,15 @@ extern cb_int32 cbBCM_enableServerProfileDun(
* @param pServerChannel Pointer to return variable. The server channel is used to identify
* incoming connections.
* @param pConnectionCallback Callback structure for connection management.
* @param pServiceClassEnabled Callback structure to inform when service is running.
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_enableServerProfileUuid128(
cb_uint8 *pUuid128,
cb_char *pServiceName,
cb_uint8 *pServerChannel,
cbBCM_ConnectionCallback *pConnectionCallback);
cbBCM_ConnectionCallback *pConnectionCallback,
cbBCM_ServiceClassEnabled pServiceClassEnabled);
/**
@ -295,12 +319,14 @@ extern cb_int32 cbBCM_enableServerProfileUuid128(
* @param pServiceName The name of the service
* @param role The PAN role of the local device
* @param pConnectionCallback Callback structure for connection management.
* @param pServiceClassEnabled Callback structure to inform when service is running.
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_enableServerProfilePan(
cb_char *pServiceName,
cbBCM_PAN_Role role,
cbBCM_ConnectionCallback *pConnectionCallback);
cbBCM_ConnectionCallback *pConnectionCallback,
cbBCM_ServiceClassEnabled pServiceClassEnabled);
/**
* Enable device id service record.The device id service record is a method by which
@ -393,7 +419,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 pAclParameters Link configuration including link supervision timeout
* @param pAclParameters Link configuration including link supervision timeout
* and master slave policy. Pass NULL to use default connection
* parameters.
* @param pConnectionCallback Callback structure for connection management.
@ -439,7 +465,7 @@ extern cb_int32 cbBCM_rspConnectSppCnf(
* @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 pAclParameters Link configuration including link supervision timeout
* @param pAclParameters Link configuration including link supervision timeout
* and master slave policy. Pass NULL to use default connection
* parameters.
* @param pConnectionCallback Callback structure for connection management.
@ -457,7 +483,7 @@ extern cbBCM_Handle cbBCM_reqConnectDun(
* Accept or reject an incoming DUN connection. This is a
* response to a cbBCM_ConnectInd connection indication.
*
* @param handle Connection handle
* @param handle Connection handle
* @param accept TRUE to accept the incoming connection.
FALSE to reject.
* @return If the operation is successful cbBCM_OK is returned.
@ -505,7 +531,7 @@ extern cbBCM_Handle cbBCM_reqConnectUuid(
* Accept or reject an incoming SPP connection. This is a
* response to a cbBCM_ConnectInd connection indication.
*
* @param handle Connection handle
* @param handle Connection handle
* @param accept TRUE to accept the incoming connection.
FALSE to reject.
* @return If the operation is successful cbBCM_OK is returned.
@ -542,7 +568,7 @@ extern cbBCM_Handle cbBCM_reqConnectPan(
* Accept or reject an incoming PAN connection. This is a
* response to a cbBCM_ConnectInd connection indication.
*
* @param handle Connection handle
* @param handle Connection handle
* @param accept TRUE to accept the incoming connection.
* FALSE to reject.
* @return If the operation is successful cbBCM_OK is returned.
@ -604,7 +630,7 @@ extern cbBCM_Handle cbBCM_reqConnectSps(
/**
* Accept or reject an incoming SPS connection. This is a
* response to a cbBCM_ConnectInd connection indication.
* @param handle Connection handle
* @param handle Connection handle
* @param accept TRUE to accept the incoming connection.
* FALSE to reject.
* @return If the operation is successful cbBCM_OK is returned.
@ -813,10 +839,50 @@ extern cb_int32 cbBCM_registerDataCallback(
extern cbBCM_Handle cbBCM_getProtocolHandle(
cbBCM_Handle handle);
/**
* @brief Get the bcm id from acl handle for an active connection.
*
* @param handle Connection handle
* @return bcm handle.
*/
extern cbBCM_Handle cbBCM_getIdFromAclHandle(TConnHandle aclHandle);
/**
* @brief Get the acl handle from bcm handle.
*
* @param handle bcm handle
* @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.
*/
extern cb_int32 cbBCM_setFlowSpecification(
cbBCM_Handle handle,
cbBCM_FlowSpecParams parameters,
cbBCM_SetFlowSpecCallback flowSpecCallback);
/**
* @brief Change which packet types can be used for the connection identified by the handle
* @param handle Connection handle
* @param aclPacketType bit map according to packet types defined in bt_types.h
* @return If the operation is successful cbBCM_OK is returned.
*/
extern cb_int32 cbBCM_changeConnectionPacketType(
cbBCM_Handle handle,
TPacketType aclPacketType);
#ifdef __cplusplus
}
#endif
#endif /* _CB_BT_CONN_MAN_H_ */

View File

@ -141,6 +141,7 @@ typedef void (*cbBM_ChannelMapCallb)(
TChannelMap *pChMap);
typedef void (*cbBM_InitComplete)(void);
typedef void(*cbBM_LocalAddressCb)(void);
typedef enum
{
@ -149,6 +150,17 @@ 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.
*/
@ -157,12 +169,13 @@ typedef struct
TBdAddr address; /** Bluetooth address that shall be assigned to controller. Pass invalidBdAddress to use controller default address*/
cbBM_LeRole leRole; /** Bluetooth low energy role */
cb_int8 maxOutputPower; /** Maximum output power. */
cb_uint32 nvdsStartIdLinkKeysClassic; /** Start id for CLASSIC link keys storage in NVDS. */
cb_uint32 maxLinkKeysClassic; /** Max number of CLASSIC link keys */
cb_uint32 nvdsStartIdLinkKeysLe; /** Start id for BLE link keys storage in NVDS. */
cb_uint32 maxLinkKeysLe; /** Max number of link keys BLE*/
cb_int32 nvdsStartIdLinkKeysClassic; /** Start id for CLASSIC link keys storage in NVDS. */
cb_int32 maxLinkKeysClassic; /** Max number of CLASSIC link keys */
cb_int32 nvdsStartIdLinkKeysLe; /** Start id for BLE link keys storage in NVDS. */
cb_int32 maxLinkKeysLe; /** Max number of link keys BLE*/
} cbBM_InitParams;
typedef void(*cbBM_ServiceEnabled)(cb_uint8 serviceChannel);
/*===========================================================================
* FUNCTIONS
*=========================================================================*/
@ -184,12 +197,70 @@ extern void cbBM_init(
cbBM_InitParams *pInitParameters,
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.
*/
extern cb_int32 cbBM_setLinkSupervisionTimeout(
cb_uint16 linkSupervisionTimeout);
/**
* This function gets the default link supervision timeout.
* @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
* @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
*/
extern cb_boolean cbBM_getFastConnect(void);
/**
* This function enables or disables the fast discovery feature (interlaced inquiry scan).
* @param fastDiscovery
* @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
*/
extern cb_boolean cbBM_getFastDiscovery(void);
/**
* This function sets all default parameters for LE.
* This function needs to be called before the cbBM_init.
*/
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.
*/
extern cb_int32 cbBM_updateScan(
cbBM_DiscoverableMode discoverableMode,
cbBM_ConnectableMode connectableMode);
/**
* Get the current Bluetooth address of the device from radio. This can
* be a way to get a alive-message from the radio.
*
* @param callback to application when address has been read.
*/
extern void cbBM_checkRadioAlive(cbBM_LocalAddressCb callback);
/**
* Get the current Bluetooth address of the device.
* @param pAddress Pointer to return variable.
@ -335,9 +406,11 @@ 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.
* @return If the operation is successful cbBM_OK is returned.
*/
extern cb_int32 cbBM_addServiceClass(cb_uint16 uuid16);
extern cb_int32 cbBM_addServiceClass(cb_uint16 uuid16, cbBM_ServiceEnabled pCallback,cb_uint8 serviceChannel);
/**
* Check if service class is already registered.
@ -350,9 +423,11 @@ cb_boolean cbBM_isServiceClassRegistered(cb_uint16 uuid16 );
* Add service class to inquiry response data. Typically
* not used by the application.
* @param uuid128 The UUID to add.
* @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_add128BitsServiceClass(cb_uint8* uuid128);
extern cb_int32 cbBM_add128BitsServiceClass(cb_uint8* uuid128, cbBM_ServiceEnabled pCallback, cb_uint8 serviceChannel);
/**
* Set maximum Bluetooth Classic ACL links the stack
@ -521,7 +596,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 the completion of the
* name request.
* @return If the operation is successfully initiated cbBM_OK is returned.
*/
@ -560,6 +635,9 @@ void cbBM_getConnectParameters(TAclParamsLe* aclParams);
*/
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.

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
* Component : Bluetooth Serial
* Component : Bluetooth PAN Data Manager
* File : cb_bt_pan.h
*
* Description : Data management for PAN profile

View File

@ -346,7 +346,7 @@ extern cb_int32 cbBSM_getAllNumberBondedDevices(
* @return If the operation is successful cbBSM_OK is returned.
*/
extern cb_int32 cbBSM_getBondedDevice(
uint32 deviceIndex,
cb_int32 deviceIndex,
TBdAddr* pBdAddr,
cb_boolean pIsLe);
@ -365,6 +365,14 @@ extern cb_int32 cbBSM_deleteBondedDevice(TBdAddr* pBdAddress);
*/
extern cb_int32 cbBSM_deleteAllBondedDevices(void);
/**
* Initializes the static Link Keys for both classic and LE.
* nvdsId: nvds id for the static link key,
* (0) disables the use of a static link key.
*
* @return cbBSM_OK.
*/
cb_int32 cbBSM_setStaticLinkKeyNvdsId(cb_int32 nvdsId);
#ifdef __cplusplus
}
#endif

View File

@ -89,7 +89,7 @@ extern cb_int32 cbBTM_enableDUT(cbBTM_TestCallback callback);
* 0x03 = BT EDR 3MB (8-DPSK)
* 0x04 = BT LE (BLE, GMSK)
* 0x05 = ANT (GFSK)
* @param testPattern Range: 0x00 - 0x07
* @param testPattern Range: 0x00 - 0x07
* 0x00 = PN9
* 0x01 = PN15
* 0x02 = ZOZO (101010101010101010)
@ -165,7 +165,7 @@ extern cb_int32 cbBTM_tiDrpbTesterConRx(
* @param frequencyMode 0x00 = Hopping 0x03 = Single frequency
* @param txSingleFrequency Transmission frequency in MHz,Range 2402 - 2480, 0xFFFF = no TX
* @param rxSingleFrequency Transmission frequency in MHz,Range 2402 - 2480, 0xFFFF = no RX
* @param aclDataPattern ACL TX packet data pattern Range: 0x00 - 0x05
* @param aclDataPattern ACL TX packet data pattern Range: 0x00 - 0x05
* 0x00 = All 0
* 0x01 = All 1
* 0x02 = ZOZO (101010101010101010)

View File

@ -0,0 +1,80 @@
/*---------------------------------------------------------------------------
* 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
* File : cb_cert_utils.h
*
* Description :
*-------------------------------------------------------------------------*/
/**
* @file cb_cert_utils.h The main WLAN component interface.
* All functions declared extern needs to be provided by another/upper layer.
* @ingroup wlan
*/
#ifndef _CB_CERT_UTILS_H_
#define _CB_CERT_UTILS_H_
#include "cb_types.h"
#include "cb_status.h"
#ifdef __cplusplus
extern "C" {
#endif
/*===========================================================================
* DEFINES
*=========================================================================*/
#define cbCERT_CRT_MAX_CHAIN_LENGTH 5ul
/*===========================================================================
* TYPES
*=========================================================================*/
typedef struct cbCERT_Stream_s cbCERT_Stream;
typedef cb_uint32 cbCERT_StreamPosition;
/**
* Stream vtable interface used by WLAN supplicant to access SSL certificates
* for WPA Enterprise authentication.
*
* @ingroup wlan
*/
struct cbCERT_Stream_s {
cb_int32(*read)(const cbCERT_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */
cb_int32(*write)(const cbCERT_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */
void(*rewind)(const cbCERT_Stream *stream); /**< Rewind function pointer, rewind stream internal iterator to the beginning. Mandatory for all streams. */
void(*setPosition)(const cbCERT_Stream *stream, cbCERT_StreamPosition position); /**< Set absolute position. */
cbCERT_StreamPosition(*getPosition)(const cbCERT_Stream *stream); /**< Get current position. */
cb_uint32(*getSize)(const cbCERT_Stream *stream); /**< GetSize function pointer, return total size of stream contents. */
};
/*===========================================================================
* CERT API
*=========================================================================*/
cbRTSL_Status cbCERT_Util_parseDERCert(cbCERT_Stream const * const certificate, cbCERT_Stream const * const outputStream);
cbRTSL_Status cbCERT_Util_parseDERKey(cbCERT_Stream const * const key, cbCERT_Stream const * const outputStream);
cbRTSL_Status cbCERT_Util_parsePEMCert(cbCERT_Stream const * const certificate, cbCERT_Stream const * const outputStream);
cbRTSL_Status cbCERT_Util_parsePEMKey(cbCERT_Stream const * const certificate, cb_char const * const key, cb_uint32 keyLength, cbCERT_Stream const * const outputStream);
#ifdef __cplusplus
}
#endif
#endif /* _CB_CERT_UTILS_H_ */

View File

@ -31,9 +31,9 @@
* app must wait until all responses from an outstanding request have been
* received.
* - In the callback of the request another request can not be done except when
* - The request is interrupted by setting the return value to FALSE
* or when in the last callback which contains an error code.
* - Most of the GATT requests can be interrupted by returning FALSE in the
* the request is interrupted by setting the return value to FALSE
* or when in the last callback which contains an error code.
* - Most of the GATT requests can be interrupted by returning FALSE in the
* callback.
*
* See Bluetooth 4.0 specification for more info on GATT and ATT chapters:

View File

@ -76,7 +76,7 @@ extern "C" {
* cbGATT_CLIENT_CHAR_CONFIG - callback that is called when remote device writes the client config cbGATT_ServerWriteClientConfig
* cbGATT_SERVER_CHAR_CONFIG - callback that is called when remote device writes the server config cbGATT_ServerWriteServerConfig
* cbGATT_CHAR_USER_DESC and all other CHARACTERISTICS value - cbGATT_ServerWriteAttr callback
* @param pAttrHandle Pointer where to write the attribute handle in case it's needed by the app.
* @param pAttrHandle Pointer where to write the attribute handle in case it's needed by the app.
* If not needed, pass NULL. Will be written after the service has been added.
*/
typedef struct
@ -152,7 +152,7 @@ typedef cbGATT_ErrorCode (*cbGATT_ServerReadAttr)(
* @param pAttr Pointer to attribute record
* @param pAttrValue Pointer where to get the data
* @param length The length.
* @param writeMethod Which write method the client is using.
* @param writeMethod Which write method the client is using.
* This depends on the properties in the attribute table.
* @param offset The offset of the written data
* @return cbGATT_ERROR_CODE_OK if accepted or some cbGATT_ERROR_CODE_* code when failed.
@ -183,7 +183,7 @@ typedef cbGATT_ErrorCode (*cbGATT_ServerReadClientConfig)(
* @param connHandle Connection handle
* @param attrHandle Handle of the attribute value
* @param config The config to be stored
* @param writeMethod Which write method the client is using.
* @param writeMethod Which write method the client is using.
* This depends on the properties in the attribute table.
* @return cbGATT_ERROR_CODE_OK if accepted or some cbGATT_ERROR_CODE_* code when failed.
*/
@ -210,7 +210,7 @@ typedef cbGATT_ErrorCode (*cbGATT_ServerReadServerConfig)(
* @param connHandle Connection handle
* @param attrHandle Handle of the attribute value
* @param config The config to be stored
* @param writeMethod Which write method the client is using.
* @param writeMethod Which write method the client is using.
* This depends on the properties in the attribute table.
* @return cbGATT_ERROR_CODE_OK if accepted or some cbGATT_ERROR_CODE_* code when failed.
*/
@ -254,7 +254,7 @@ cb_int32 cbGATT_deregisterAllServers(void);
/**
* Send notification to GATT client. The characteristicValueNotificationCnf
* callback will be called when finished and a new notification can be sent.
* The client config notification must have been enabled by the GATT client
* The client config notification must have been enabled by the GATT client
* before an notification can be sent.
* @param connHandle Connection handle
* @param attrHandle Handle of the attribute value
@ -264,16 +264,16 @@ cb_int32 cbGATT_deregisterAllServers(void);
* @return cbGATT_OK if succeeded or some cbGATT_ERROR* when failed.
*/
cb_int32 cbGATT_notification(
TConnHandle connHandle,
cb_uint16 attrHandle,
cb_uint8* pData,
cb_uint16 length,
TConnHandle connHandle,
cb_uint16 attrHandle,
cb_uint8* pData,
cb_uint16 length,
cb_uint8 appHandle);
/**
* Send indication to GATT client. The characteristicValueIndicationCnf
* callback will be called when finished and a new indication can be sent.
* The client config indication must have been enabled by the GATT client
* The client config indication must have been enabled by the GATT client
* before an indication can be sent.
* @param connHandle Connection handle
* @param attrHandle Handle of the attribute value
@ -283,17 +283,17 @@ cb_int32 cbGATT_notification(
* @return cbGATT_OK if succeeded or some cbGATT_ERROR* when failed.
*/
cb_int32 cbGATT_indication(
TConnHandle connHandle,
cb_uint16 attrHandle,
cb_uint8* pData,
cb_uint16 length,
TConnHandle connHandle,
cb_uint16 attrHandle,
cb_uint8* pData,
cb_uint16 length,
cb_uint8 appHandle);
/**
* Delay write respone to client, see cbGATT_ServerWriteAttr
* @param connHandle Connection handle
* @param attrHandle Handle of the attribute value
* @param errorCode Error code, use cbGATT_ERROR_CODE_OK if OK otherwise some cbGATT_ERROR_CODE_*
* @param errorCode Error code, use cbGATT_ERROR_CODE_OK if OK otherwise some cbGATT_ERROR_CODE_*
* @return cbGATT_OK if succeeded or some cbGATT_ERROR* when failed.
*/
cb_int32 cbGATT_writeRsp(
@ -305,15 +305,15 @@ cb_int32 cbGATT_writeRsp(
* Add service list to attribute database
* @param pAttrList Attribute list
* @param attrListSize Size of the attribute list
* @param startHandle Start handle. Note that startHandle for the application
* should start at lowest 1024, cbGATT_APP_START_SERVICE_HANDLE.
* @param startHandle Start handle. Note that startHandle for the application
* should start at lowest 1024, cbGATT_APP_START_SERVICE_HANDLE.
* 1-1023 is reserved for GATT/GAP and other u-blox services.
* @return cbGATT_OK if succeeded or some cbGATT_ERROR* when failed.
*/
cb_int32 cbGATT_addService(
const cbGATT_Attribute* pAttrList,
cb_uint16 attrListSize,
cb_int16 startHandle);
cb_uint16 attrListSize,
cb_uint16 startHandle);
/**
* NOTE: Only for tests

View File

@ -59,6 +59,11 @@ typedef enum {
cbHW_IRQ_LOW = 12U
}cbHW_PRIO_LVL;
typedef enum {
cbHW_SYSTICK_DISABLED,
cbHW_SYSTICK_LOW_FREQ,
cbHW_SYSTICK_DEFAULT,
} cbHW_SysTickMode;
/*===========================================================================
* TYPES
*=========================================================================*/
@ -79,6 +84,7 @@ void cbHW_enterSleepMode(void);
void cbHW_enterStopMode(void);
void cbHW_setWakeupEvent(void);
void cbHW_resetWakeupEvent(void);
void cbHW_setSysTickMode(cbHW_SysTickMode sysTickMode);
/**
* Wait for specified amount of microseconds. May be interrupt dependent.
@ -143,4 +149,3 @@ void cbHW_enableAllIrq(void);
#endif

View File

@ -26,7 +26,9 @@
*=========================================================================*/
#define OK(status) (status == cbSTATUS_OK)
#define BUSY(status) (status == cbSTATUS_BUSY)
#define ERR(status) (status == cbSTATUS_ERROR)
/*===========================================================================
* TYPES
*=========================================================================*/
@ -36,6 +38,7 @@
cbSTATUS_OK,
cbSTATUS_ERROR,
cbSTATUS_BUSY,
cbSTATUS_RECEIVE_DATA_MODE,
cbSTATUS_TIMEOUT
} cbRTSL_Status;

View File

@ -31,6 +31,7 @@
#include "cb_types.h"
#include "cb_wlan_types.h"
#include "cb_cert_utils.h"
#include "cb_status.h"
#ifdef __cplusplus
@ -75,25 +76,6 @@ extern "C" {
/*===========================================================================
* TYPES
*=========================================================================*/
typedef struct cbWLAN_Stream_s cbWLAN_Stream;
typedef cb_uint32 cbWLAN_StreamPosition;
/**
* Stream vtable interface used by WLAN supplicant to access SSL certificates
* for WPA Enterprise authentication.
*
* @ingroup wlan
*/
struct cbWLAN_Stream_s {
cb_int32 (*read)(const cbWLAN_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */
cb_int32 (*write)(const cbWLAN_Stream *stream, void *buf, cb_uint32 count); /**< Read function pointer, place count bytes in buf. */
void (*rewind)(const cbWLAN_Stream *stream); /**< Rewind function pointer, rewind stream internal iterator to the beginning. Mandatory for all streams. */
void (*setPosition)(const cbWLAN_Stream *stream, cbWLAN_StreamPosition position); /**< Set absolute position. */
cbWLAN_StreamPosition (*getPosition)(const cbWLAN_Stream *stream); /**< Get current position. */
cb_uint32 (*getSize)(const cbWLAN_Stream *stream); /**< GetSize function pointer, return total size of stream contents. */
};
/**
* Start parameters passed to WLAN driver.
*
@ -178,8 +160,8 @@ typedef struct cbWLAN_EnterpriseConnectParameters {
cb_uint8 username[cbWLAN_MAX_USERNAME_LENGTH]; /**< Username string. */
cb_uint8 passphrase[cbWLAN_MAX_PASSPHRASE_LENGTH]; /**< Passphrase string. */
cb_uint8 domain[cbWLAN_MAX_DOMAIN_LENGTH]; /**< Domain string. */
cbWLAN_Stream *clientCertificate; /**< Stream handle to provide SSL certificate for authentication. */
cbWLAN_Stream *clientPrivateKey; /**< STream handle to provide SSL private key for authentication. */
cbCERT_Stream *clientCertificate; /**< Stream handle to provide SSL certificate for authentication. */
cbCERT_Stream *clientPrivateKey; /**< STream handle to provide SSL private key for authentication. */
} cbWLAN_EnterpriseConnectParameters;
/**
@ -200,9 +182,10 @@ typedef struct cbWLAN_CommonApParameters {
* @ingroup wlan
*/
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*/
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*/
cb_uint32 gtkRekeyInterval; /**< Group rekey interval in seconds */
} cbWLAN_WPAPSKApParameters;
@ -286,8 +269,11 @@ typedef enum {
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;
/**