BNEP:
/* Functions provided by bnep_main.c*/
extern tBNEP_RESULT bnep_register_with_l2cap (void);
bnep_cb.reg_info.pL2CA_ConnectInd_Cb = bnep_connect_ind;
bnep_cb.reg_info.pL2CA_ConnectCfm_Cb = bnep_connect_cfm;
bnep_cb.reg_info.pL2CA_ConfigInd_Cb = bnep_config_ind;
bnep_cb.reg_info.pL2CA_ConfigCfm_Cb = bnep_config_cfm;
bnep_cb.reg_info.pL2CA_DisconnectInd_Cb = bnep_disconnect_ind;
bnep_cb.reg_info.pL2CA_DisconnectCfm_Cb = bnep_disconnect_cfm;
bnep_cb.reg_info.pL2CA_DataInd_Cb = bnep_data_ind;
bnep_cb.reg_info.pL2CA_CongestionStatus_Cb = bnep_congestion_ind;
extern tBNEP_CONN *bnep_conn_originate (UINT8 *p_bd_addr);
extern void bnep_process_timeout (TIMER_LIST_ENT *p_tle);
extern void bnep_connected (tBNEP_CONN *p_bcb);
/* Functions provided by bnep_utils.c
*/
extern tBNEP_CONN *bnepu_find_bcb_by_cid (UINT16 cid);
extern tBNEP_CONN *bnepu_find_bcb_by_bd_addr (UINT8 *p_bda);
extern tBNEP_CONN *bnepu_allocate_bcb (BD_ADDR p_rem_bda);
extern void bnepu_release_bcb (tBNEP_CONN *p_bcb);
extern void bnepu_send_peer_our_filters (tBNEP_CONN *p_bcb);
extern void bnepu_send_peer_our_multi_filters (tBNEP_CONN *p_bcb);
extern BOOLEAN bnepu_does_dest_support_prot (tBNEP_CONN *p_bcb, UINT16 protocol);
extern void bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol,
UINT8 *p_src_addr, UINT8 *p_dest_addr, BOOLEAN ext_bit);
extern void test_bnepu_build_bnep_hdr (tBNEP_CONN *p_bcb, BT_HDR *p_buf, UINT16 protocol,
UINT8 *p_src_addr, UINT8 *p_dest_addr, UINT8 type);
extern tBNEP_CONN *bnepu_get_route_to_dest (UINT8 *p_bda);
extern void bnepu_check_send_packet (tBNEP_CONN *p_bcb, BT_HDR *p_buf);
extern void bnep_send_command_not_understood (tBNEP_CONN *p_bcb, UINT8 cmd_code);
extern void bnepu_process_peer_filter_set (tBNEP_CONN *p_bcb, UINT8 *p_filters, UINT16 len);
extern void bnepu_process_peer_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data);
extern void bnepu_process_multicast_filter_rsp (tBNEP_CONN *p_bcb, UINT8 *p_data);
extern void bnep_send_conn_req (tBNEP_CONN *p_bcb);
extern void bnep_send_conn_responce (tBNEP_CONN *p_bcb, UINT16 resp_code);
extern void bnep_process_setup_conn_req (tBNEP_CONN *p_bcb, UINT8 *p_setup, UINT8 len);
extern void bnep_process_setup_conn_responce (tBNEP_CONN *p_bcb, UINT8 *p_setup);
extern UINT8 *bnep_process_control_packet (tBNEP_CONN *p_bcb, UINT8 *p, UINT16 *len, BOOLEAN is_ext);
extern void bnep_sec_check_complete (BD_ADDR bd_addr, void *p_ref_data, UINT8 result);
extern tBNEP_RESULT bnep_is_packet_allowed (tBNEP_CONN *p_bcb, BD_ADDR p_dest_addr, UINT16 protocol, BOOLEAN fw_ext_present, UINT8 *p_data);
extern UINT32 bnep_get_uuid32 (tBT_UUID *src_uuid);
extern void bnep_dump_status (void);
bnep_api.c
**
** Function BNEP_Init
**
** Description This function initializes the BNEP unit. It should be called
** before accessing any other APIs to initialize the control block
**
** Returns void
**
*******************************************************************************/
void BNEP_Init (void)
/*******************************************************************************
**
** Function BNEP_Deregister
**
** Description This function is called by the upper layer to de-register
** its callbacks.
**
** Parameters: void
**
**
** Returns void
**
*******************************************************************************/
void BNEP_Deregister (void)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_Connect
**
** Description This function creates a BNEP connection to a remote
** device.
**
** Parameters: p_rem_addr - BD_ADDR of the peer
** src_uuid - source uuid for the connection
** dst_uuid - destination uuid for the connection
** p_handle - pointer to return the handle for the connection
**
** Returns BNEP_SUCCESS if connection started
** BNEP_NO_RESOURCES if no resources
**
*******************************************************************************/
tBNEP_RESULT BNEP_Connect (BD_ADDR p_rem_bda,
tBT_UUID *src_uuid,
tBT_UUID *dst_uuid,
UINT16 *p_handle)
/*******************************************************************************
**
** Function BNEP_SetProtocolFilters
**
** Description This function sets the protocol filters on peer device
**
** Parameters: handle - Handle for the connection
** num_filters - total number of filter ranges
** p_start_array - Array of beginings of all protocol ranges
** p_end_array - Array of ends of all protocol ranges
**
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
** BNEP_TOO_MANY_FILTERS - if too many filters
** BNEP_SUCCESS - if request sent successfully
**
*******************************************************************************/
tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
UINT16 num_filters,
UINT16 *p_start_array,
UINT16 *p_end_array)
/*******************************************************************************
**
** Function BNEP_SetProtocolFilters
**
** Description This function sets the protocol filters on peer device
**
** Parameters: handle - Handle for the connection
** num_filters - total number of filter ranges
** p_start_array - Array of beginings of all protocol ranges
** p_end_array - Array of ends of all protocol ranges
**
** Returns BNEP_WRONG_HANDLE - if the connection handle is not valid
** BNEP_SET_FILTER_FAIL - if the connection is in wrong state
** BNEP_TOO_MANY_FILTERS - if too many filters
** BNEP_SUCCESS - if request sent successfully
**
*******************************************************************************/
tBNEP_RESULT BNEP_SetProtocolFilters (UINT16 handle,
UINT16 num_filters,
UINT16 *p_start_array,
UINT16 *p_end_array)
*******************************************************************************
**
** Function BNEP_GetMyBdAddr
**
** Description This function returns a pointer to the local device BD address.
** If the BD address has not been read yet, it returns NULL.
**
** Returns the BD address
**
*******************************************************************************/
UINT8 *BNEP_GetMyBdAddr (void)
/*******************************************************************************
**
** Function BNEP_SetTraceLevel
**
** Description This function sets the trace level for BNEP. If called with
** a value of 0xFF, it simply reads the current trace level.
**
** Returns the new (current) trace level
**
*******************************************************************************/
UINT8 BNEP_SetTraceLevel (UINT8 new_level)
/*******************************************************************************
**
** Function BNEP_SetTraceLevel
**
** Description This function sets the trace level for BNEP. If called with
** a value of 0xFF, it simply reads the current trace level.
**
** Returns the new (current) trace level
**
*******************************************************************************/
UINT8 BNEP_SetTraceLevel (UINT8 new_level)
pan_api.c
/*******************************************************************************
**
** Function PAN_Init
**
** Description This function initializes the PAN module variables
**
** Parameters: none
**
** Returns none
**
*******************************************************************************/
void PAN_Init (void)
/*******************************************************************************
**
** Function PAN_SetTraceLevel
**
** Description This function sets the trace level for PAN. If called with
** a value of 0xFF, it simply reads the current trace level.
**
** Returns the new (current) trace level
**
*******************************************************************************/
UINT8 PAN_SetTraceLevel (UINT8 new_level)
/*******************************************************************************
**
** Function PAN_SetMulticastFilters
**
** Description This function is used to set multicast filters on the peer
**
** Parameters: handle - handle for the connection
** num_filters - number of multicast filter ranges
** start - array of starting multicast filter addresses
** end - array of ending multicast filter addresses
**
**
** Returns PAN_SUCCESS if multicast filters are set successfully
** PAN_FAILURE if connection not found or error in setting
**
*******************************************************************************/
tBNEP_RESULT PAN_SetMulticastFilters (UINT16 handle,
UINT16 num_mcast_filters,
UINT8 *p_start_array,
UINT8 *p_end_array)
/*******************************************************************************
**
** Function PAN_SetProtocolFilters
**
** Description This function is used to set protocol filters on the peer
**
** Parameters: handle - handle for the connection
** num_filters - number of protocol filter ranges
** start - array of starting protocol numbers
** end - array of ending protocol numbers
**
**
** Returns PAN_SUCCESS if protocol filters are set successfully
** PAN_FAILURE if connection not found or error in setting
**
*******************************************************************************/
tPAN_RESULT PAN_SetProtocolFilters (UINT16 handle,
UINT16 num_filters,
UINT16 *p_start_array,
UINT16 *p_end_array)
/*******************************************************************************
**
** Function PAN_Register
**
** Description This function is called by the application to register
** its callbacks with PAN profile. The application then
** should set the PAN role explicitly.
**
** Parameters: p_register - contains all callback function pointers
**
**
** Returns none
**
*******************************************************************************//
void PAN_Register (tPAN_REGISTER *p_register)
pan_cb.pan_conn_state_cb = p_register->pan_conn_state_cb;
pan_cb.pan_bridge_req_cb = p_register->pan_bridge_req_cb;
pan_cb.pan_data_buf_ind_cb = p_register->pan_data_buf_ind_cb;
pan_cb.pan_data_ind_cb = p_register->pan_data_ind_cb;
pan_cb.pan_pfilt_ind_cb = p_register->pan_pfilt_ind_cb;
pan_cb.pan_mfilt_ind_cb = p_register->pan_mfilt_ind_cb;
pan_cb.pan_tx_data_flow_cb = p_register->pan_tx_data_flow_cb;
/*******************************************************************************
**
** Function PAN_Deregister
**
** Description This function is called by the application to de-register
** its callbacks with PAN profile. This will make the PAN to
** become inactive. This will deregister PAN services from SDP
** and close all active connections
**
** Parameters: none
**
**
** Returns none
**
*******************************************************************************/
void PAN_Deregister (void)
/*******************************************************************************
**
** Function PAN_SetRole
**
** Description This function is called by the application to set the PAN
** profile role. This should be called after PAN_Register.
** This can be called any time to change the PAN role
**
** Parameters: role - is bit map of roles to be active
** PAN_ROLE_CLIENT is for PANU role
** PAN_ROLE_GN_SERVER is for GN role
** PAN_ROLE_NAP_SERVER is for NAP role
** sec_mask - Security mask for different roles
** It is array of UINT8. The byte represent the
** security for roles PANU, GN and NAP in order
** p_user_name - Service name for PANU role
** p_gn_name - Service name for GN role
** p_nap_name - Service name for NAP role
** Can be NULL if user wants it to be default
**
** Returns PAN_SUCCESS - if the role is set successfully
** PAN_FAILURE - if the role is not valid
**
*******************************************************************************/
tPAN_RESULT PAN_SetRole (UINT8 role,
UINT8 *sec_mask,
char *p_user_name,
char *p_gn_name,
char *p_nap_name)
/*******************************************************************************
**
** Function PAN_Connect
**
** Description This function is called by the application to initiate a
** connection to the remote device
**
** Parameters: rem_bda - BD Addr of the remote device
** src_role - Role of the local device for the connection
** dst_role - Role of the remote device for the connection
** PAN_ROLE_CLIENT is for PANU role
** PAN_ROLE_GN_SERVER is for GN role
** PAN_ROLE_NAP_SERVER is for NAP role
** *handle - Pointer for returning Handle to the connection
**
** Returns PAN_SUCCESS - if the connection is initiated successfully
** PAN_NO_RESOURCES - resources are not sufficent
** PAN_FAILURE - if the connection cannot be initiated
** this can be because of the combination of
** src and dst roles may not be valid or
** allowed at that point of time
**
*******************************************************************************/
tPAN_RESULT PAN_Connect (BD_ADDR rem_bda, UINT8 src_role, UINT8 dst_role, UINT16 *handle)
/*******************************************************************************
**
** Function PAN_Disconnect
**
** Description This is used to disconnect the connection
**
** Parameters: handle - handle for the connection
**
** Returns PAN_SUCCESS - if the connection is closed successfully
** PAN_FAILURE - if the connection is not found or
** there is an error in disconnecting
**
*******************************************************************************/
tPAN_RESULT PAN_Disconnect (UINT16 handle)
/*******************************************************************************
**
** Function PAN_Write
**
** Description This sends data over the PAN connections. If this is called
** on GN or NAP side and the packet is multicast or broadcast
** it will be sent on all the links. Otherwise the correct link
** is found based on the destination address and forwarded on it
** If the return value is not PAN_SUCCESS the application should
** take care of releasing the message buffer
**
** Parameters: handle - handle for the connection
** dst - MAC or BD Addr of the destination device
** src - MAC or BD Addr of the source who sent this packet
** protocol - protocol of the ethernet packet like IP or ARP
** p_data - pointer to the data
** len - length of the data
** ext - to indicate that extension headers present
**
** Returns PAN_SUCCESS - if the data is sent successfully
** PAN_FAILURE - if the connection is not found or
** there is an error in sending data
**
*******************************************************************************/
tPAN_RESULT PAN_Write (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protocol, UINT8 *p_data, UINT16 len, BOOLEAN ext)
/*******************************************************************************
**
** Function PAN_WriteBuf
**
** Description This sends data over the PAN connections. If this is called
** on GN or NAP side and the packet is multicast or broadcast
** it will be sent on all the links. Otherwise the correct link
** is found based on the destination address and forwarded on it
** If the return value is not PAN_SUCCESS the application should
** take care of releasing the message buffer
**
** Parameters: handle - handle for the connection
** dst - MAC or BD Addr of the destination device
** src - MAC or BD Addr of the source who sent this packet
** protocol - protocol of the ethernet packet like IP or ARP
** p_buf - pointer to the data buffer
** ext - to indicate that extension headers present
**
** Returns PAN_SUCCESS - if the data is sent successfully
** PAN_FAILURE - if the connection is not found or
** there is an error in sending data
**
*******************************************************************************/
tPAN_RESULT PAN_WriteBuf (UINT16 handle, BD_ADDR dst, BD_ADDR src, UINT16 protocol, BT_HDR *p_buf, BOOLEAN ext)
libbt-brcm_bta
/*******************************************************************************
**
** Function BTA_PanEnable
**
** Description Enable PAN service. This function must be
** called before any other functions in the PAN API are called.
** When the enable operation is complete the callback function
** will be called with a BTA_PAN_ENABLE_EVT.
**
** Returns void
**
*******************************************************************************/
void BTA_PanEnable(tBTA_PAN_CBACK p_cback)
/*******************************************************************************
**
** Function BTA_PanDisable
**
** Description Disables PAN service.
**
**
** Returns void
**
*******************************************************************************/
void BTA_PanDisable(void)
/*******************************************************************************
**
** Function BTA_PanSetRole
**
** Description Sets PAN roles. When the enable operation is complete
** the callback function will be called with a BTA_PAN_SET_ROLE_EVT.
**
** Returns void
**
*******************************************************************************/
void BTA_PanSetRole(tBTA_PAN_ROLE role, tBTA_PAN_ROLE_INFO *p_user_info, tBTA_PAN_ROLE_INFO *p_gn_info,
tBTA_PAN_ROLE_INFO *p_nap_info)
/*******************************************************************************
**
** Function BTA_PanOpen
**
** Description Opens a connection to a peer device.
** When connection is open callback function is called
** with a BTA_PAN_OPEN_EVT.
**
**
** Returns void
**
*******************************************************************************/
BTA_API void BTA_PanOpen(BD_ADDR bd_addr, tBTA_PAN_ROLE local_role, tBTA_PAN_ROLE peer_role)
/*******************************************************************************
**
** Function BTA_PanClose
**
** Description Close a PAN connection to a peer device.
**
**
** Returns void
**
*******************************************************************************/
BTA_API void BTA_PanClose(UINT16 handle)
FLow:
==========================================================
btif/src/bluetooth.c
struct hw_module_t HAL_MODULE_INFO_SYM ->.methods = &bt_stack_module_methods
bt_stack_module_methods->open =
open_bluetooth_stack()
bt_interface_t* bluetooth__get_bluetooth_interface ->get_profile_interface
get_profile_interface (const char *profile_id)
BlueDroid 支援的profile:
if (is_profile(profile_id, BT_PROFILE_HANDSFREE_ID))
if (is_profile(profile_id, BT_PROFILE_SOCKETS_ID))
if (is_profile(profile_id, BT_PROFILE_PAN_ID))
if (is_profile(profile_id, BT_PROFILE_ADVANCED_AUDIO_ID))
if (is_profile(profile_id, BT_PROFILE_HIDHOST_ID))
if (is_profile(profile_id, BT_PROFILE_HEALTH_ID))
if (is_profile(profile_id, BT_PROFILE_GATT_ID))
if (is_profile(profile_id, BT_PROFILE_AV_RC_ID))
./btif/src/btif_pan.c:
--------------------------
static bt_status_t btpan_jni_init(const btpan_callbacks_t* callbacks)
void btif_pan_init()
BTA_PanEnable(bta_pan_callback);
btpan_cb.enabled = 1;
btpan_enable(BTPAN_LOCAL_ROLE);
bta_pan_api.c
----------------------
void BTA_PanEnable(tBTA_PAN_CBACK p_cback){
向 BTA system manager 註冊 BTA_ID_PAN
指定事件及回呼
p_buf->hdr.event = BTA_PAN_API_ENABLE_EVT;
p_buf->p_cback = p_cback;
bta_sys_sendmsg(p_buf); 送訊息給 bta_system
bta_pan_main.c
------------------------
BOOLEAN bta_pan_hdl_event(BT_HDR *p_msg)
case BTA_PAN_API_ENABLE_EVT:
bta_pan_api_enable((tBTA_PAN_DATA *) p_msg);
break;
bta_pan_enable()
PAN_Register()