Infineon Logo AIROC BTSDK v4.9 - Documentation
 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
blecm.h File Reference

This file provides definitions and function prototypes for the Bluetooth LE Controller Manager (BLECM). More...

Macros

#define BLECM_MODULE_SMP   0x0
 
#define BLECM_MODULE_ATT   0x1
 
#define BLECM_MODULE_MAX   (BLECM_MODULE_ATT +1)
 
#define BLECM_MAX_CFA_TIMERS   0x4
 
#define BLECM_APP_NORMAL_TIMER_ID   0x0
 
#define BLECM_APP_FINE_RESOLUTION_TIMER_ID   0x1
 
#define BLECM_APP_LED_TIMER_ID   0x2
 
#define BLECM_APP_BUZ_TIMER_ID   0x3
 
#define BLECM_DBGUART_LOG   0x1
 
#define BLECM_DBGUART_LOG_L2CAP   0x2
 
#define BLECM_DBGUART_LOG_SMP   0x4
 
#define BLECM_DBGUART_LOG_ATT   0x8
 
#define BLECM_DBGUART_LOG_AP   0x10
 
#define BLECM_DBGUART_LOG_ENABLED()   (blecm_configFlag & BLECM_DBGUART_LOG)
 
#define BLECM_DBGUART_LOG_L2CAP_ENABLED()   (blecm_configFlag & BLECM_DBGUART_LOG_L2CAP)
 
#define BLECM_DBGUART_LOG_SMP_ENABLED()   (blecm_configFlag & BLECM_DBGUART_LOG_SMP)
 
#define BLECM_DBGUART_LOG_ATT_ENABLED()   (blecm_configFlag & BLECM_DBGUART_LOG_ATT)
 
#define BLECM_DBGUART_LOG_AP_ENABLED()   (blecm_configFlag & BLECM_DBGUART_LOG_AP)
 

Typedefs

typedef void(* BLECM_NO_PARAM_FUNC )(void)
 Types of some of the callbacks.
 
typedef INT32(* BLECM_FUNC_WITH_PARAM )(void *)
 
struct {
   UINT8   addr [6]
 BD_ADDR of the peer to add to/remove from filter accept list.
 
   UINT8   type
 Type of the peer address - public or random.
 
BLECM_SELECT_ADDR
 Defines a structure for use in setting up filter accept lists.
 
struct {
   UINT16   con_handle
 
   UINT16   db_size
 
   void *   p_db
 
   void *   dev_pinfo
 
   void *   smp_pinfo
 
BLECM_CON_MUX_INFO
 Internal connection mux data structure.
 

Enumerations

enum  BLECM_APP_EVT_ENUM {
  BLECM_APP_EVT_START_UP, BLECM_APP_EVT_LINK_UP, BLECM_APP_EVT_LINK_DOWN, BLECM_APP_EVT_ADV_TIMEOUT,
  BLECM_APP_EVT_ENTERING_HIDOFF, BLECM_APP_EVT_ABORTING_HIDOFF, BLECM_APP_EVT_MAX
}
 

Functions

void blecm_init (void)
 BLECM Initialization. More...
 
void blecm_start (void)
 BLECM Start. More...
 
void blecm_setFilterEnable (UINT8 enable)
 Enable/Disable CFA filter. More...
 
UINT8 blecm_getFilterEnable (void)
 Reading current CFA filter value. More...
 
void blecm_regAppEvtHandler (BLECM_APP_EVT_ENUM, BLECM_NO_PARAM_FUNC func)
 Register Event Handler. More...
 
void blecm_regAclRxHandler (void *)
 Register for ACL Data receive. More...
 
void blecm_regEncryptionChangedHandler (void *)
 Register for Encryption Changed event. More...
 
void blecm_activateModule (INT32 moduleIdx, BLECM_FUNC_WITH_PARAM handler)
 
void blecm_clearActivateModule (INT32 moduleIdx)
 
void blecm_startTimerSource (INT32 id, BLECM_FUNC_WITH_PARAM appCb, UINT32 ticks)
 Starts a software timer. More...
 
void blecm_stopTimerSource (INT32 id)
 Stopps a software timer. More...
 
void blecm_refreshConnIdletimer (void)
 Restarts the connection idle timer. More...
 
void blecm_startConnIdleTimer (BLEAPP_TIMER_CB cb)
 Starts the connection idle timer. More...
 
void blecm_stopConnIdleTimer (void)
 Stops the connection idle timer. More...
 
int blecm_needToResolveRandomAddress (void)
 
void blecm_enableRandomAddressResolution (void)
 Enable address resolution. More...
 
void blecm_disableRandomAddressResolution (void)
 Disable address resolution. More...
 
void blecm_storeRPA (UINT8 *rpa, INT32 idx)
 Stores random public address. More...
 
int blecm_lookupAddress (INT32 type, UINT32 *rpa)
 Looks up the given random public address in the key store. More...
 
int blecm_resolveRPA (INT32 type, UINT32 *rpa)
 Lookup and resolve address. More...
 
void blecm_log (char *)
 
void blecm_log1 (char *str, INT32 val)
 
void blecm_logBytes (char *str, UINT8 *data, INT32 len)
 
void blecm_log_byteArray (UINT8 *, INT32 len)
 
void blecm_log_6 (char *, INT32, INT32, INT32, INT32, INT32, INT32)
 
void blecm_setAdvEnable (INT32 enableFlag)
 
void blecm_setAdvParam (INT32 interval, INT32 advType, INT32 advAdrType, INT32 advChanMap, INT32 advFilterPolicy, INT32 initAdrType, UINT8 *initAdr)
 
void blecm_hciReset (void)
 
void blecm_hciReadBdAddr (void)
 
void blecm_getRand (void)
 
void blecm_hciEncrypt (UINT8 *key, UINT8 *text)
 
void blecm_hciLTKReply (UINT16 handle, UINT8 *ltk)
 
void blecm_hciLTKNegReply (UINT16 handle)
 
void blecm_disconnect (INT32 errCode)
 
void blecm_setAdvData (UINT8 *data, INT32 len)
 
void blecm_setScanRspData (UINT8 *data, INT32 len)
 
UINT32 blecm_setAdvDuringConnEnable (int enableFlag)
 Enable/disable Advertisement during connection. More...
 
void blecm_enablescatternet (void)
 Enable scatternet in the controller. More...
 
void blecm_setTxPowerInConnection (INT8 maxTxPowerDb)
 Sets the maximum TX power. More...
 
void blecm_EndTest (void)
 Ends all LE tests that were started with blecm_StartReveiverTest or blecm_StartTransmitterTest. More...
 
UINT8 blecm_StartReveiverTest (UINT8 channel)
 Starts the standard LE receiver test on the given channel. More...
 
UINT8 blecm_StartTransmitterTest (UINT8 channel, UINT8 packetLength, UINT8 packetType)
 Starts the standard LE transmitter test with the given parameters. More...
 
void blecm_startAdv (INT32 advType, INT32 advInterval, INT32 advChannel, INT32 advAdrType, INT32 advFilterPolicy, INT32 initiatorAdrType, UINT8 *initiatorAdr)
 Set advertising parameters and starts advertisements. More...
 
INT32 blecm_getAvailableTxBuffers (void)
 Gets the number of available transmit buffers in the controller.
 
INT32 blecm_incAvailableTxBuffers (void)
 
INT32 blecm_decAvailableTxBuffers (void)
 
void blecm_setAvailableTxBuffers (INT32 val)
 
INT32 blecm_needToSelectAddress (void)
 
INT32 blecm_SelectAddress (BLECM_SELECT_ADDR *p_select_addr, UINT8 num)
 Clears and then adds the given addresses to the filter accept list. More...
 
INT32 blecm_SelectTargetAddress (BLECM_SELECT_ADDR *p_select_addr, UINT8 num)
 
void blecm_enableAddressSelection (void)
 Enables filter accept list at the stack leyer.
 
void blecm_disableAddressSelection (void)
 Disables filter accept list at the stack leyer. More...
 
void blecm_startScan (INT32 scanType, INT32 scanInterval, INT32 scanWindow, INT32 scanAdrType, INT32 scanFilterPolicy, INT32 filterDuplicates)
 Configure LE scan parameters and start LE scan. More...
 
void blecm_setScanParam (INT32 scanType, INT32 scanInterval, INT32 scanWindow, INT32 scanAdrType, INT32 scanFilterPolicy)
 Set the LE scan parameters. More...
 
void blecm_scanOn (INT32 filterDuplicates)
 Enable LE scans. More...
 
void blecm_setScanEnable (INT32 enableFlag, INT32 filterDuplicates)
 Configure controller for LE scan. More...
 
void blecm_CreateConnection (INT32 scanInterval, INT32 scanWindow, INT32 initiatorFilterPolicy, INT32 peerAddressType, char *peerAddress, INT32 ownAddressType, INT32 connMinInterval, INT32 connMaxInterval, INT32 connLatency, INT32 supervisionTimeout, INT32 connMinEventLen, INT32 connMaxEventLen)
 Create a Link Layer connection to a connectable advertiser. More...
 
void blecm_CreateConnectionCancel (void)
 Cancel attempt to create a Link Layer connection. More...
 
void blecm_ConnectionUpdate (INT32 connHandle, INT32 connMinInterval, INT32 connMaxInterval, INT32 connLatency, INT32 supervisionTimeout, INT32 connMinEventLen, INT32 connMaxEventLen)
 Connection update request. More...
 
void blecm_RegleAdvReportCb (BLECM_FUNC_WITH_PARAM cb)
 Register to receive advertisement report. More...
 
void blecm_startEncryption (INT32 Connection_Handle, UINT8 *Random_Number, INT32 Encrypted_Diversifier, UINT8 *Long_Term_Key)
 
INT32 blecm_needToConMux (void)
 
void blecm_enableConMux (void)
 Enable connection muxing. More...
 
void blecm_disableConMux (void)
 Disable connection muxing. More...
 
void blecm_ConMuxInit (INT32 con_num)
 Initialize connection mux. More...
 
void blecm_AddConMux (INT32 index, UINT16 con_handle, UINT16 db_size, void *p_db, void *dev_pinfo, void *smp_pinfo)
 Add the connection to the list of known connections we can mux between. More...
 
void blecm_DelConMux (int index)
 Delete the connection mux/context at the given index. More...
 
INT32 blecm_FindFreeConMux (void)
 Find a free connection mux/context slot. More...
 
INT32 blecm_FindConMux (UINT16 con_handle)
 Look up the connection information structure given a handle. More...
 
UINT16 blecm_GetDbSizeConMux (UINT16 con_handle)
 Get the GATT DB size given a connection handle. More...
 
void * blecm_GetDbConMux (UINT16 con_handle)
 Get the GATT DB given a connection handle. More...
 
void * blecm_GetDevConMux (UINT16 con_handle)
 Get the device information given a connection handle. More...
 
void * blecm_GetSmpConMux (UINT16 con_handle)
 Get the SMP information given a connection handle. More...
 
void blecm_ResetPtrConMux (void)
 Reset the connection context.
 
void blecm_SetPtrConMux (UINT16 con_handle)
 Set all the connection contexts to the one for the given connection. More...
 
INT32 blecm_needToGATTDB16 (void)
 
void blecm_enableGATTDB16 (void)
 Enable 16-bit length fields in application GATT DB. More...
 
void blecm_disableGATTDB16 (void)
 Disable 16-bit length fields in app GATT DB.
 

Variables

UINT32 blecm_configFlag
 

Detailed Description

This file provides definitions and function prototypes for the Bluetooth LE Controller Manager (BLECM).

Function Documentation

void blecm_AddConMux ( INT32  index,
UINT16  con_handle,
UINT16  db_size,
void *  p_db,
void *  dev_pinfo,
void *  smp_pinfo 
)

Add the connection to the list of known connections we can mux between.

Typically done on connection up.

Parameters
indexThe index into which to add the connection information.
con_handleThe connection handle of this connection. This handle is used to look up the connection info structure.
db_sizeThe size of the GATT DB to be associated with the connection.
p_dbThe pointer to the GATT DB to be associated with this connection.
dev_pinfoDevice information in EMCONINFO_DEVINFO for this connection.
smp_pinfoThe SMP information from LESMP_INFO for this connection.
void blecm_ConMuxInit ( INT32  con_num)

Initialize connection mux.

This nees to be done once by the app in the create function.

Parameters
con_numThe max number of connections that can be active at any point in time.
void blecm_DelConMux ( int  index)

Delete the connection mux/context at the given index.

Typically done on connection down.

Parameters
indexThe index of the connection information to delete.
void blecm_disableAddressSelection ( void  )

Disables filter accept list at the stack leyer.

To fully disable filter accept list, call blecm_SelectAddress() with NULL, 0 and then invoke this.

void blecm_disableConMux ( void  )

Disable connection muxing.

Generally never done.

void blecm_enableConMux ( void  )

Enable connection muxing.

This needs to be done once by the app in the create function.

void blecm_enableGATTDB16 ( void  )

Enable 16-bit length fields in application GATT DB.

This needs to be invoked before the first access to GATT DB occurs (early in create function). The GATT DB provided in the set_cfg function should use 16-bit lengths.

void blecm_enablescatternet ( void  )

Enable scatternet in the controller.

Parameters
NONE
void blecm_EndTest ( void  )

Ends all LE tests that were started with blecm_StartReveiverTest or blecm_StartTransmitterTest.

Parameters
NONE
INT32 blecm_FindConMux ( UINT16  con_handle)

Look up the connection information structure given a handle.

Parameters
con_handleConnection handle of the connection to look up for.
Returns
Index of the connection info structure or -1 when not found.
INT32 blecm_FindFreeConMux ( void  )

Find a free connection mux/context slot.

Returns
Index of the first unused connection info structure or -1 when none are free.
void* blecm_GetDbConMux ( UINT16  con_handle)

Get the GATT DB given a connection handle.

Parameters
con_handleConnection handle of the connection to look up for.
Returns
GATT DB or NULL when not found.
UINT16 blecm_GetDbSizeConMux ( UINT16  con_handle)

Get the GATT DB size given a connection handle.

Parameters
con_handleConnection handle of the connection to look up for.
Returns
GATT DB size or 0 when not found.
void* blecm_GetDevConMux ( UINT16  con_handle)

Get the device information given a connection handle.

Parameters
con_handleConnection handle of the connection to look up for.
Returns
Device information pointer or NULL when not found.
void* blecm_GetSmpConMux ( UINT16  con_handle)

Get the SMP information given a connection handle.

Parameters
con_handleConnection handle of the connection to look up for.
Returns
SMP information pointer or NULL when not found.
void blecm_scanOn ( INT32  filterDuplicates)

Enable LE scans.

Parameters
filterDuplicates
  • HCIULP_SCAN_DUPLICATE_FILTER_OFF Duplicate filtering disabled
  • HCIULP_SCAN_DUPLICATE_FILTER_ON Duplicate filtering enabled
INT32 blecm_SelectAddress ( BLECM_SELECT_ADDR p_select_addr,
UINT8  num 
)

Clears and then adds the given addresses to the filter accept list.

Parameters
p_select_addrArray of addresses to add to the filter accept list.
numThe number of items to add to the filter accept list. Max is 5.
Returns
1 on success; 0 on failure.
UINT32 blecm_setAdvDuringConnEnable ( int  enableFlag)

Enable/disable Advertisement during connection.

Parameters
enableFlag1 - Enable, 0 - disable
void blecm_SetPtrConMux ( UINT16  con_handle)

Set all the connection contexts to the one for the given connection.

This is used by the stack to switch connection contexts.

void blecm_setScanParam ( INT32  scanType,
INT32  scanInterval,
INT32  scanWindow,
INT32  scanAdrType,
INT32  scanFilterPolicy 
)

Set the LE scan parameters.

Parameters
LE_Scan_Type
  • HCIULP_PASSIVE_SCAN Passive Scanning. No SCAN_REQ packets shall be sent.
  • HCIULP_ACTIVE_SCAN Active scanning. SCAN_REQ packets may be sent.
LE_Scan_IntervalTime interval from when the Controller started its last LE scan until it begins the subsequent LE scan.
LE_Scan_WindowThe duration of the LE scan.
Own_Address_Type
  • HCIULP_PUBLIC_ADDRESS
  • HCIULP_RANDOM_ADDRESS
scanFilterPolicy
  • HCIULP_SCAN_FILTER_POLICY_ACCEPT_LIST_NOT_USED
  • HCIULP_SCAN_FILTER_POLICY_ACCEPT_LIST_USED
void blecm_setTxPowerInConnection ( INT8  maxTxPowerDb)

Sets the maximum TX power.

Parameters
maxTxPowerDbThe max TX power allowed in dB.
void blecm_startAdv ( INT32  advType,
INT32  advInterval,
INT32  advChannel,
INT32  advAdrType,
INT32  advFilterPolicy,
INT32  initiatorAdrType,
UINT8 *  initiatorAdr 
)

Set advertising parameters and starts advertisements.

Sets the advertisement parameters and starts it.

Parameters
advTypeThe advertismenet type. See LE_Set_Advertising_Parameters HCI command for acceptable values.
advIntervalThe advertisement interval in Bluetooth slots (min 32, max 16384).
advChannelThe advertisement channel mask (can bitwise OR). 0x01 for ch37; 0x02 for ch38; 0x04 for ch39.
advAdrTypeThe advertiser type (Public/random).
advFilterPolicyThe filter policy to use. See Bluetooth spec for acceptable values.
initiatorAdrTypeThe address type of the peer device - valid only when advType is directed advertisement.
initiatorAdrThe address of the peer device - valid only when advType is directed advertisement.
UINT8 blecm_StartReveiverTest ( UINT8  channel)

Starts the standard LE receiver test on the given channel.

Parameters
channelThe channel to use for the test. 0-39.
Returns
<ReturnValue> True if test was started successfully, else could not start the test.
UINT8 blecm_StartTransmitterTest ( UINT8  channel,
UINT8  packetLength,
UINT8  packetType 
)

Starts the standard LE transmitter test with the given parameters.

Parameters
channelThe channel to use for the test. 0-39.
packetLengthThe Length test packet. 0-37
packetTypeThe type of packet to use - The following are supported: {0x00, "Pseudo-Random bit sequence 9"}, {0x01, "Pattern of alternating bits '11110000'"}, {0x02, "Pattern of alternating bits '10101010'"}, {0x03, "Pseudo-Random bit sequence 15 - Optional"}, {0x04, "Pattern of All '1' bits - Optional"}, {0x05, "Pattern of All '0' bits - Optional"}, {0x06, "Pattern of alternating bits '00001111' - Optional"}, {0x07, "Pattern of alternating bits '01010101' - Optional"}
Returns
<ReturnValue> True if test was started successfully, else could not start the test.