MT2523 API Reference  LinkIt SDK v4
bt_spp.h
1 /* Copyright Statement:
2  *
3  * (C) 2005-2016 MediaTek Inc. All rights reserved.
4  *
5  * This software/firmware and related documentation ("MediaTek Software") are
6  * protected under relevant copyright laws. The information contained herein
7  * is confidential and proprietary to MediaTek Inc. ("MediaTek") and/or its licensors.
8  * Without the prior written permission of MediaTek and/or its licensors,
9  * any reproduction, modification, use or disclosure of MediaTek Software,
10  * and information contained herein, in whole or in part, shall be strictly prohibited.
11  * You may only use, reproduce, modify, or distribute (as applicable) MediaTek Software
12  * if you have agreed to and been bound by the applicable license agreement with
13  * MediaTek ("License Agreement") and been granted explicit permission to do so within
14  * the License Agreement ("Permitted User"). If you are not a Permitted User,
15  * please cease any access or use of MediaTek Software immediately.
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES
18  * ARE PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
19  * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
21  * NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
22  * SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
23  * SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO LOOK ONLY TO SUCH
24  * THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. RECEIVER EXPRESSLY ACKNOWLEDGES
25  * THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES
26  * CONTAINED IN MEDIATEK SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK
27  * SOFTWARE RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
28  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND
29  * CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
30  * AT MEDIATEK'S OPTION, TO REVISE OR REPLACE MEDIATEK SOFTWARE AT ISSUE,
31  * OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY RECEIVER TO
32  * MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
33  */
34 
35 #ifndef __BT_SPP_H__
36 #define __BT_SPP_H__
37 
38 #include "bt_type.h"
39 #include "bt_sdp.h"
230 #define BT_SPP_INVALID_HANDLE 0x00000000
231 
235 #define BT_SPP_SDP_ATTRIBUTE_UUID_LENGTH BT_SDP_ATTRIBUTE_HEADER_8BIT(17)
236 
241 #define BT_SPP_SDP_ATTRIBUTE_UUID BT_SDP_UUID_128BIT
242 
247 #define BT_SPP_SDP_ATTRIBUTE_PROTOCOL_DESCRIPTOR(server_id) \
248  BT_SDP_ATTRIBUTE_HEADER_8BIT(12), \
249  BT_SDP_ATTRIBUTE_HEADER_8BIT(3), \
250  BT_SDP_UUID_16BIT(BT_SDP_PROTOCOL_L2CAP), \
251  BT_SDP_ATTRIBUTE_HEADER_8BIT(5), \
252  BT_SDP_UUID_16BIT(BT_SDP_PROTOCOL_RFCOMM), \
253  BT_SDP_UINT_8BIT(server_id)
254 
259 #define BT_SPP_SDP_ATTRIBUTE_PUBLIC_BROWSE_GROUP \
260  BT_SDP_ATTRIBUTE_HEADER_8BIT(3), \
261  BT_SDP_UUID_16BIT(BT_SDP_SERVICE_CLASS_PUBLIC_BROWSE_GROUP)
262 
266 #define BT_SPP_SDP_ATTRIBUTE_LANGUAGE \
267  BT_SDP_ATTRIBUTE_HEADER_8BIT(9), \
268  BT_SDP_UINT_16BIT(0x656E), \
269  BT_SDP_UINT_16BIT(0x006A), \
270  BT_SDP_UINT_16BIT(0x0100)
271 
275 #define BT_SPP_SDP_ATTRIBUTE_SIZE_OF_SERVICE_NAME(size) \
276  BT_SDP_TEXT_8BIT(size)
277 
282 #define BT_SPP_SDP_ATTRIBUTE_SERVICE_CLASS_ID_LIST(uuid_array) \
283  BT_SDP_ATTRIBUTE(BT_SDP_ATTRIBUTE_ID_SERVICE_CLASS_ID_LIST, uuid_array)
284 
289 #define BT_SPP_SDP_ATTRIBUTE_PROTOCOL_DESC_LIST(protocol_descriptor_array) \
290  BT_SDP_ATTRIBUTE(BT_SDP_ATTRIBUTE_ID_PROTOCOL_DESC_LIST, protocol_descriptor_array)
291 
296 #define BT_SPP_SDP_ATTRIBUTE_BROWSE_GROUP_LIST(browse_group_array) \
297  BT_SDP_ATTRIBUTE(BT_SDP_ATTRIBUTE_ID_BROWSE_GROUP_LIST, browse_group_array)
298 
303 #define BT_SPP_SDP_ATTRIBUTE_LANGUAGE_BASE_LIST(language_array) \
304  BT_SDP_ATTRIBUTE(BT_SDP_ATTRIBUTE_ID_LANG_BASE_ID_LIST, language_array)
305 
311 #define BT_SPP_SDP_ATTRIBUTE_SERVICE_NAME(name_array) \
312  BT_SDP_ATTRIBUTE(BT_SDP_ATTRIBUTE_ID_SERVICE_NAME + 0x0100, name_array)
313 
317 #define BT_SPP_CONNECT_IND (BT_MODULE_SPP | 0x0000)
319 #define BT_SPP_CONNECT_CNF (BT_MODULE_SPP | 0x0001)
321 #define BT_SPP_DISCONNECT_IND (BT_MODULE_SPP | 0x0002)
323 #define BT_SPP_DATA_RECEIVED_IND (BT_MODULE_SPP | 0x0003)
325 #define BT_SPP_READY_TO_SEND_IND (BT_MODULE_SPP | 0x0004)
331 #define BT_STATUS_SPP_TX_NOT_AVAILABLE (BT_MODULE_SPP |0xE0)
337 #define BT_SPP_SERVER_ID_START 0x06
338 #define BT_SPP_SERVER_ID_END 0x1E
352 typedef struct {
353  uint32_t handle;
354  uint16_t max_packet_length;
356 
358 typedef struct {
359  uint32_t handle;
360  uint8_t local_server_id;
361  bt_bd_addr_t *address;
365 typedef struct {
366  uint32_t handle;
368 
370 typedef struct {
371  uint32_t handle;
373 
375 typedef struct {
376  uint32_t handle;
377  uint8_t *packet;
378  uint16_t packet_length;
384 BT_EXTERN_C_BEGIN
396  uint32_t *handle,
397  const bt_bd_addr_t *address,
398  const uint8_t *uuid128);
399 
408 bt_status_t bt_spp_connect_response(uint32_t handle, bool accept);
409 
422  uint32_t handle,
423  uint8_t *packet,
424  uint16_t packet_length);
425 
433 bt_status_t bt_spp_disconnect(uint32_t handle);
434 
440 void bt_spp_hold_data(uint8_t *data);
441 
447 void bt_spp_release_data(uint8_t *data);
448 
449 BT_EXTERN_C_END
450 
457 #endif /*__BT_SPP_H__*/
458 
void bt_spp_hold_data(uint8_t *data)
This function holds the SPP packet until it is fully consumed.
uint32_t handle
The SPP handle of the current connection.
Definition: bt_spp.h:371
bt_status_t bt_spp_connect_response(uint32_t handle, bool accept)
This function is for the SPP server to accept or reject connection from a remote client, the BT_SPP_CONNECT_CNF event is reported to indicate the result of the response.
This structure defines BT_SPP_DATA_RECEIVED_IND.
Definition: bt_spp.h:380
void bt_spp_release_data(uint8_t *data)
This function releases the SPP packet after it is consumed.
This structure defines BT_SPP_DISCONNECT_IND.
Definition: bt_spp.h:370
uint32_t handle
The SPP handle of the current connection.
Definition: bt_spp.h:376
bt_status_t bt_spp_send(uint32_t handle, uint8_t *packet, uint16_t packet_length)
This function sends data to a remote device.
This structure defines BT_SPP_CONNECT_IND.
Definition: bt_spp.h:363
uint8_t bt_bd_addr_t[6]
Address type, defined in Bluetooth core specification version 4.2.
Definition: bt_type.h:180
int32_t bt_status_t
Define the status type, returned from the APIs, and defined as BT_STATUS_XXX.
Definition: bt_type.h:173
This structure defines BT_SPP_CONNECT_CNF.
Definition: bt_spp.h:357
bt_status_t bt_spp_disconnect(uint32_t handle)
This function disconnects an existing connection, the BT_SPP_DISCONNECT_IND event is reported to indi...
bt_status_t bt_spp_connect(uint32_t *handle, const bt_bd_addr_t *address, const uint8_t *uuid128)
This function is for the SPP client to connect to a remote server, the BT_SPP_CONNECT_CNF event is re...
This structure defines BT_SPP_READY_TO_SEND_IND.
Definition: bt_spp.h:375