m2mb API docs  25.21.002
m2mb API sets documentation
m2mb_bt.h File Reference

Header file for m2mb_bt APIs. More...

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <pthread.h>
#include "m2mb_types.h"
#include "m2mb_os_types.h"
#include "m2mb_os_api.h"
#include "m2mb_os_sem.h"

Go to the source code of this file.

Data Structures

struct  M2MB_BT_BD_ADDR_S
 
struct  M2MB_BT_SCAN_REPORT_DATA_S
 
struct  M2MB_BT_SSP_REQUEST_T
 
struct  M2MB_BT_PIN_REQUEST_T
 BT PIN request. More...
 
struct  M2MB_BT_HFP_AG_CON_EVENT_T
 
struct  M2MB_BT_HFP_AG_DISCON_EVENT_T
 
struct  M2MB_BT_HFP_AG_AUDIO_CON_EVENT_T
 
struct  M2MB_BT_HFP_AG_AUDIO_DISCON_EVENT_T
 
struct  M2MB_BT_HFP_AG_DIAL_EVENT_T
 
struct  M2MB_BT_HFP_AG_CALL_IND_EVENT_T
 
struct  M2MB_BT_HFP_AG_CODEC_INFO_EVENT_T
 
struct  M2MB_BT_SPP_STATE_CHANGE_EVENT_S
 
struct  M2MB_BT_SPP_RX_DATA_EVENT_S
 
struct  M2MB_BT_SPP_RX_END_EVENT_S
 
struct  M2MB_BT_SPP_CONNECT_EVENT_S
 
struct  M2MB_BT_SPP_DISCONNECT_EVENT_S
 
struct  M2MB_BT_USER_EVENT_CTX_S
 
struct  M2MB_BT_BOND_LIST_INFO_S
 

Macros

#define M2MB_BT_MAX_DEVICE_NAME_LENGTH   (39+1)
 
#define M2MB_BT_MAX_MANUFACTURER_NAME_LENGTH   M2MB_BT_MAX_DEVICE_NAME_LENGTH
 
#define M2MB_BT_FIXPIN_SIZE   6
 
#define M2MB_BT_ADV_DATA_SIZE   32
 
#define M2MB_BT_SCAN_RSP_DATA_SIZE   32
 
#define M2MB_BT_ADDRESS_RESOLUTION_TIMEOUT   60
 
#define M2MB_BT_MAX_PHONE_NUMBER   82
 

Typedefs

typedef struct M2MB_BT_BD_ADDR_S M2MB_BT_BD_ADDR_T
 
typedef struct M2MB_BT_SCAN_REPORT_DATA_S M2MB_BT_SCAN_REPORT_DATA_T
 
typedef struct M2MB_BT_SPP_STATE_CHANGE_EVENT_S M2MB_BT_SPP_STATE_CHANGE_EVENT_T
 
typedef struct M2MB_BT_SPP_RX_DATA_EVENT_S M2MB_BT_SPP_RX_DATA_EVENT_T
 
typedef struct M2MB_BT_SPP_RX_END_EVENT_S M2MB_BT_SPP_RX_END_EVENT_T
 
typedef struct M2MB_BT_SPP_CONNECT_EVENT_S M2MB_BT_SPP_CONNECT_EVENT_T
 
typedef struct M2MB_BT_SPP_DISCONNECT_EVENT_S M2MB_BT_SPP_DISCONNECT_EVENT_T
 
typedef struct M2MB_BT_USER_EVENT_CTX_S M2MB_BT_USER_EVENT_CTX_T
 
typedef struct M2MB_BT_BOND_LIST_INFO_S M2MB_BT_BOND_LIST_INFO_T
 
typedef HANDLE M2MB_BT_HANDLE
 
typedef void(* m2mb_bt_event_callback) (M2MB_BT_HANDLE bt_handle, M2MB_BT_USER_EVENTS_T bt_event, UINT16 resp_size, void *resp, void *userdata)
 BT event callback. More...
 

Enumerations

enum  M2MB_BT_STATUS_T {
  M2MB_BT_STATUS_SUCCESS_E, M2MB_BT_STATUS_FAILURE_E, M2MB_BT_STATUS_OUT_OF_RANGE_E, M2MB_BT_STATUS_NOT_READY_E,
  M2MB_BT_STATUS_UNSUPPORTED_E, M2MB_BT_STATUS_PARAM_INVALID_E, M2MB_BT_STATUS_NO_MEM_E, M2MB_BT_STATUS_AUTH_FAILURE_E,
  M2MB_BT_STATUS_AUTH_REJECTED_E, M2MB_BT_STATUS_INVALID_E, M2MB_BT_STATUS_ERR_INVALID_HANDLE_E, M2MB_BT_STATUS_ERR_REQUEST_NOT_SUPPORTED_E,
  M2MB_BT_STATUS_ERR_TIMEOUT_E
}
 
enum  M2MB_BT_INIT_STATE_T { M2MB_BT_STATE_UNINITIALIZED, M2MB_BT_STATE_INITIALIZED }
 
enum  M2MB_BT_ADV_TYPE_T { M2MB_BT_ADVERTISE_ON_WITH_CUSTOMIZED_ADV_DISABLE, M2MB_BT_ADVERTISE_ON_WITH_CUSTOMIZED_ADV_ENABLE, M2MB_BT_ADVERTISE_OFF }
 
enum  M2MB_BT_MSG_T { M2MB_BT_GAP_EVENT_SSP_REQUEST, M2MB_BT_GAP_API_SSP_REPLY }
 
enum  M2MB_BT_USER_EVENTS_T {
  M2MB_BT_AG_HFP_CONNECT_EVENT_E, M2MB_BT_AG_HFP_DISCONNECT_EVENT_E, M2MB_BT_AG_HFP_CALL_INCOMING_EVENT_E, M2MB_BT_AG_HFP_CALL_ANSWER_EVENT_E,
  M2MB_BT_AG_HFP_CALL_REJECT_EVENT_E, M2MB_BT_AG_HFP_CALL_HOLD_EVENT_E, M2MB_BT_AG_HFP_CALL_OUTGOING_EVENT_E, M2MB_BT_AG_HFP_CALL_DISCONNECT_EVENT_E,
  M2MB_BT_AG_HFP_AUDIO_CONNECT_EVENT_E, M2MB_BT_AG_HFP_AUDIO_DISCONNECT_EVENT_E, M2MB_BT_AG_HFP_VOLUME_CTRL_EVENT_E, M2MB_BT_AG_HFP_CODEC_INFO_EVENT_E,
  M2MB_BT_SCAN_EVENT_E, M2MB_BT_DISCOVERY_START_EVENT_E, M2MB_BT_DISCOVERY_STOP_EVENT_E, M2MB_BT_SSP_PIN_NOTIFICATION_EVENT_E,
  M2MB_BT_SSP_PIN_EVENT_E, M2MB_BT_SSP_CONF_EVENT_E, M2MB_BT_SSP_REQUEST_EVENT_E, M2MB_BT_SPP_SERVER_STATE_CHANGE_EVENT_E = 256,
  M2MB_BT_SPP_PEER_CONNECT_IND, M2MB_BT_SPP_PEER_DISCONNECT_IND, M2MB_BT_SPP_PEER_RX_DATA_EVENT_E, M2MB_BT_SPP_PEER_RX_END_EVENT_E
}
 
enum  M2MB_BT_HFP_AG_CODEC_TYPE_T { M2MB_BT_HFP_AG_CODEC_NONE, M2MB_BT_HFP_AG_CODEC_WBS, M2MB_BT_HFP_AG_CODEC_NBS }
 
enum  M2MB_BT_AG_HFP_DIAL_MSG_ID_T { M2MB_BT_AG_HFP_DIAL_MSG_ID_DIAL_OUT_NUMBER, M2MB_BT_AG_HFP_DIAL_MSG_ID_REDIAL, M2MB_BT_AG_HFP_DIAL_MSG_ID_MEM_DIAL }
 
enum  M2MB_BT_SPP_SERVER_STATE_T { M2MB_BT_SPP_STATE_SERVER_INACTIVE = 0, M2MB_BT_SPP_STATE_SERVER_ACTIVE =1 }
 
enum  M2MB_BT_SPP_DEVICE_STATE_T { M2MB_BT_SPP_STATE_DEVICE_CONNECTED =2, M2MB_BT_SPP_STATE_DEVICE_RECEIVE =3, M2MB_BT_SPP_STATE_DEVICE_DISCONNECTED =4 }
 
enum  M2MB_BT_CONFIG_PARAM_T {
  M2MB_BT_CFG_BD_ADDR_GET_E, M2MB_BT_CFG_DEVICE_NAME_GET_E, M2MB_BT_CFG_DEVICE_NAME_SET_E, M2MB_BT_CFG_MANUFACTURER_NAME_GET_E,
  M2MB_BT_CFG_MANUFACTURER_NAME_SET_E
}
 
enum  M2MB_BT_HFP_VOL_CTRL_TYPE_T { M2MB_BT_HFP_VOL_CTRL_TYPE_SPK, M2MB_BT_HFP_VOL_CTRL_TYPE_MIC }
 

Functions

M2MB_BT_STATUS_T m2mb_bt_initialize (M2MB_BT_HANDLE *bt_handle, m2mb_bt_event_callback bt_callback, void *user_data)
 Initialization of BT. More...
 
M2MB_BT_STATUS_T m2mb_bt_get_init_state (M2MB_BT_HANDLE bt_handle, M2MB_BT_INIT_STATE_T *state)
 Getting BT initialization state. More...
 
M2MB_BT_STATUS_T m2mb_bt_shutdown (M2MB_BT_HANDLE bt_handle)
 Deinitialization of BT. More...
 
M2MB_BT_STATUS_T m2mb_bt_conf (M2MB_BT_HANDLE bt_handle, UINT8 num_cmds,...)
 BT configuration API. More...
 
M2MB_BT_STATUS_T m2mb_bt_scan_start (M2MB_BT_HANDLE bt_handle, M2MB_BT_BD_ADDR_T bd_addr)
 Starts BT scanning. More...
 
M2MB_BT_STATUS_T m2mb_bt_scan_stop (M2MB_BT_HANDLE bt_handle)
 Stops BT scanning. More...
 
M2MB_BT_STATUS_T m2mb_bt_bond_list_get (M2MB_BT_HANDLE bt_handle, M2MB_BT_BOND_LIST_INFO_T **bond_list_info, UINT32 *num_of_entries)
 Gets the bond information. More...
 
M2MB_BT_STATUS_T m2mb_bt_bond_delete (M2MB_BT_HANDLE bt_handle, M2MB_BT_BD_ADDR_T bd_addr)
 Deletes bond information. More...
 
M2MB_BT_STATUS_T m2mb_bt_sspconf_reply (M2MB_BT_HANDLE bt_handle, M2MB_BT_BD_ADDR_T bd_addr, UINT32 accept_flag)
 passkey conformation More...
 
M2MB_BT_STATUS_T m2mb_bt_ssppin_reply (M2MB_BT_HANDLE bt_handle, M2MB_BT_BD_ADDR_T bd_addr, INT32 ssppin, UINT8 accept_flag)
 passkey/pin response More...
 

Detailed Description

Header file for m2mb_bt APIs.

m2m/m2m_generic/common/m2mb_inc/m2mb_bt.h

m2mb_bt APIs provide actions and events for BT classic core functionalities

Note
Author
bhask.nosp@m.ar.n.nosp@m.aik@t.nosp@m.elit.nosp@m..com
Date
27/08/2020 @ Modified 21/01/2021 BT SPP Feature support

Macro Definition Documentation

◆ M2MB_BT_MAX_DEVICE_NAME_LENGTH

#define M2MB_BT_MAX_DEVICE_NAME_LENGTH   (39+1)

GAP_DEVICE_NAME_LEN in gap.h

Typedef Documentation

◆ m2mb_bt_event_callback

typedef void(* m2mb_bt_event_callback) (M2MB_BT_HANDLE bt_handle, M2MB_BT_USER_EVENTS_T bt_event, UINT16 resp_size, void *resp, void *userdata)

BT event callback.

register this callback during BT init

Enumeration Type Documentation

◆ M2MB_BT_CONFIG_PARAM_T

Enumerator
M2MB_BT_CFG_BD_ADDR_GET_E 

Indicates BT device address get.

M2MB_BT_CFG_DEVICE_NAME_GET_E 

Indicates BT device name get.

M2MB_BT_CFG_DEVICE_NAME_SET_E 

Indicates BT device name set.

M2MB_BT_CFG_MANUFACTURER_NAME_GET_E 

Indicates BT device manufacturer name get.

M2MB_BT_CFG_MANUFACTURER_NAME_SET_E 

Indicates BT device manufacturer name set.

◆ M2MB_BT_USER_EVENTS_T

Enumerator
M2MB_BT_SSP_CONF_EVENT_E 

Indicates BT SSP conformation event.

M2MB_BT_SPP_SERVER_STATE_CHANGE_EVENT_E 

SPP state change indication

M2MB_BT_SPP_PEER_CONNECT_IND 

Connect indication

M2MB_BT_SPP_PEER_DISCONNECT_IND 

Disconnect indication

M2MB_BT_SPP_PEER_RX_DATA_EVENT_E 

Data reception indication

M2MB_BT_SPP_PEER_RX_END_EVENT_E 

End of data reception

Function Documentation

◆ m2mb_bt_bond_delete()

M2MB_BT_STATUS_T m2mb_bt_bond_delete ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_BD_ADDR_T  bd_addr 
)

Deletes bond information.

This function deletes bond information for a praticular bd address or entire bond information

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[in]bd_addrremote device address
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_bond_list_get()

M2MB_BT_STATUS_T m2mb_bt_bond_list_get ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_BOND_LIST_INFO_T **  bond_list_info,
UINT32 *  num_of_entries 
)

Gets the bond information.

This function gives the bond list information

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[out]bond_list_infoPointer to bond list info structure
[out]num_of_entriesnumber of bonded bt devices in the bond list
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_conf()

M2MB_BT_STATUS_T m2mb_bt_conf ( M2MB_BT_HANDLE  bt_handle,
UINT8  num_cmds,
  ... 
)

BT configuration API.

This API will accept variable length arguments as part of its last parameter. bt_handle:bt_handle from BT init API num_cmds: number of params follows after this param VA_ARGS (...): This final parameter is variable argument list. Make sure the first parameter in the variable arugument list is the Action on param (enum type to set or get bt param), followed by the "bt config param values". "bt config param values" can be a pointer to structure which is defined based on m2mb_bt_conf enum type (or) bt config param values can be passed individually to the API.

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[in]num_cmdsspecifies number of params follows after this param
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_get_init_state()

M2MB_BT_STATUS_T m2mb_bt_get_init_state ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_INIT_STATE_T *  state 
)

Getting BT initialization state.

Gets BT init state by passing handle

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[out]statefilled with BT state
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_initialize()

M2MB_BT_STATUS_T m2mb_bt_initialize ( M2MB_BT_HANDLE *  bt_handle,
m2mb_bt_event_callback  bt_callback,
void *  user_data 
)

Initialization of BT.

Initializes BT Module and gives handle for application to be used in all contexts and starts event callback

Parameters
[in]bt_callbackBT event callback function pointer. This function is called for all BT related events
[in]user_dataA pointer to generic BT user data that will be returned as it is in the callback
[out]bt_handlePointer to bt_handle. This is filled by m2mb_bt_initialize API. This should be used in all M2MB BT API's
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note
M2MB_BT_HANDLE is valid until m2mb_bt_shutdown(M2MB_BT_HANDLE bt_handle) is called

Example

<C code example>

◆ m2mb_bt_scan_start()

M2MB_BT_STATUS_T m2mb_bt_scan_start ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_BD_ADDR_T  bd_addr 
)

Starts BT scanning.

Starts scanning for particular device (BT address) or scans available devices (Advertising devices)

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[in]bd_addrremote device address
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_scan_stop()

M2MB_BT_STATUS_T m2mb_bt_scan_stop ( M2MB_BT_HANDLE  bt_handle)

Stops BT scanning.

Stop BT scanning

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_shutdown()

M2MB_BT_STATUS_T m2mb_bt_shutdown ( M2MB_BT_HANDLE  bt_handle)

Deinitialization of BT.

Deinitialization of BT by passing bt handle

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_sspconf_reply()

M2MB_BT_STATUS_T m2mb_bt_sspconf_reply ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_BD_ADDR_T  bd_addr,
UINT32  accept_flag 
)

passkey conformation

This function conforms the passkey from user end

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[in]bd_addrremote device address
[in]confirmation_flagflag states whether to pair or not (true or false).
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>

◆ m2mb_bt_ssppin_reply()

M2MB_BT_STATUS_T m2mb_bt_ssppin_reply ( M2MB_BT_HANDLE  bt_handle,
M2MB_BT_BD_ADDR_T  bd_addr,
INT32  ssppin,
UINT8  accept_flag 
)

passkey/pin response

This function is called whenever a callback has been registered for the specified passkey response data event.

Parameters
[in]bt_handlespecifies the BT handle previously created through m2mb_bt_initialize
[in]bd_addrremote device address
[in]ssppinSSP passkey - 6 digits SSPPIN
[in]accept_flagflag states whether to pair or not (true or false).
Returns
M2MB_BT_STATUS_T: used for success or failure see m2mb_bt.h for details
Note

Example

<C code example>