MT2523 API Reference  LinkIt SDK v4
bt_notify.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_NOTIFY_H__
36 #define __BT_NOTIFY_H__
37 #include "stdbool.h"
38 #include <stdint.h>
39 #include <string.h>
40 #include <stdio.h>
41 #ifdef __MTK_BLE_ONLY_ENABLE__
42 #include "bt_spp_dummy.h"
43 #else
44 #include "bt_spp.h"
45 #endif
46 #include <FreeRTOS.h>
47 #include <timers.h>
48 
174 /*****************************************************************************
175  * define
176  *****************************************************************************/
187 #define BT_NOTIFY_MIN_RECEIVE_DATA_BUF_SIZE (2*1024 + 1)
188 #define BT_NOTIFY_MIN_PARSER_BUF_SIZE (3*1024)
189 #define BT_NOTIFY_MAX_CHANNEL 1
190 #define BT_NOTIFY_MAX_SENDER_LENGTH 50
191 #define BT_NOTIFY_MAX_PAGE_CONTENT_LENGTH 300
192 #define BT_NOTIFY_MAX_PAGE_TITLE_LENGTH 30
193 #define BT_NOTIFY_MAX_PHONE_NUMBER_LENGTH 20
195 /*actions related*/
196 #define BT_NOTIFY_MAX_ACTION_NUM 5
197 #define BT_NOTIFY_MAX_ACTION_NAME_LENGTH 20
198 #define BT_NOTIFY_MAX_ACTION_ID_LENGTH 20
199 #define BT_NOTIFY_MAX_GROUP_ID_LENGTH 30
200 #define BT_NOTIFY_MAX_SENDER_RECEIVER_ID_LENGTH 16
201 #ifdef _ICON_SUPPORT_ /*Define _ICON_SUPPORT_ macro to enable the notification icon feature, i.e. a notification with icon data from a remote device. The application needs to decode the icon data itself.*/
202 #define BT_NOTIFY_MAX_ICON_SIZE 2560
203 #endif /*_ICON_SUPPORT_*/
204 
205 
206 
222 typedef void (*bt_notify_callback_t)(void *data);
227 typedef enum {
239 
244 typedef struct {
247  int32_t error_code;
249  uint16_t length;
251 
252 
257 typedef enum {
262 
267 typedef enum {
271 
272 
273 #ifdef _ICON_SUPPORT_ /*Define _ICON_SUPPORT_ macro to enable the notification icon feature, i.e. a notification with icon data from a remote device. The application needs to decode the icon data itself.*/
274 typedef struct {
275  uint8_t icon_buffer[BT_NOTIFY_MAX_ICON_SIZE]; /*Requires a Base64 decoder.*/
276  uint32_t icon_size;
277 } bt_notify_data_icon_t;
278 #endif /*_ICON_SUPPORT_*/
279 
284 typedef struct page_struct {
287  struct page_struct *next;
289 
294 typedef struct {
295  uint16_t action_id[BT_NOTIFY_MAX_ACTION_ID_LENGTH];
296  uint16_t action_name[BT_NOTIFY_MAX_ACTION_NAME_LENGTH];
298 
303 typedef struct {
304  uint16_t sender[BT_NOTIFY_MAX_SENDER_LENGTH];
305  uint32_t page_num;
307  uint32_t action_number;
309  uint8_t group_id[BT_NOTIFY_MAX_GROUP_ID_LENGTH];
310  uint32_t timestamp;
311  uint32_t app_id;
313  uint32_t msg_id;
314 #ifdef _ICON_SUPPORT_ /*Define _ICON_SUPPORT_ macro to enable the notification icon feature, i.e. a notification with icon data from a remote device. The application needs to decode the icon data itself.*/
315  bt_notify_data_icon_t *icon;
316 #endif /*_ICON_SUPPORT_*/
317 
319 
324 typedef struct {
325  uint16_t sender[BT_NOTIFY_MAX_SENDER_LENGTH];
326  uint16_t sender_number[BT_NOTIFY_MAX_PHONE_NUMBER_LENGTH];
328  uint32_t msg_id;
329  uint32_t timestamp;
331 
336 typedef struct {
337  uint16_t sender[BT_NOTIFY_MAX_SENDER_LENGTH];
338  uint16_t sender_number[BT_NOTIFY_MAX_PHONE_NUMBER_LENGTH];
339  uint32_t msg_id;
340  uint32_t missed_call_count;
341  uint32_t timestamp;
343 
349 typedef struct {
358 
364 typedef enum {
377 
382 typedef enum {
387 
418 int32_t bt_notify_send_data(bt_bd_addr_t *bt_addr, const char *data, uint16_t data_len, bool is_new);
419 
425 void bt_notify_init(uint8_t sdp_id);
426 
434 
435 
442 #endif/*__BT_NOTIFY_H__*/
uint32_t msg_id
The notification ID.
Definition: bt_notify.h:328
Registration is successful.
Definition: bt_notify.h:374
Define the page structure of the notification received from a remote device.
Definition: bt_notify.h:284
Connection indication event.
Definition: bt_notify.h:229
Invalid event.
Definition: bt_notify.h:228
#define BT_NOTIFY_MAX_SENDER_RECEIVER_ID_LENGTH
The maximum length of the sender ID or the receiver ID.
Definition: bt_notify.h:200
Data received event.
Definition: bt_notify.h:232
bt_notify_data_source_t bt_notify_get_data_source(bt_bd_addr_t *bt_addr)
Call this function to get the data transfer mode.
Define the missed call content received from the remote device.
Definition: bt_notify.h:336
#define BT_NOTIFY_MAX_ACTION_NAME_LENGTH
The maximum length of the action name.
Definition: bt_notify.h:197
Notification parsing error.
Definition: bt_notify.h:367
Define the notification content received from a remote device.
Definition: bt_notify.h:303
#define BT_NOTIFY_MAX_PHONE_NUMBER_LENGTH
The maximum length of the phone number.
Definition: bt_notify.h:193
uint16_t length
The length of the data received from the remote device.
Definition: bt_notify.h:249
uint32_t page_num
The notification&#39;s page number.
Definition: bt_notify.h:305
struct page_struct * next
The next page.
Definition: bt_notify.h:287
Data transfer in the DOGP mode.
Definition: bt_notify.h:385
uint32_t msg_id
The notification ID.
Definition: bt_notify.h:313
bt_notify_remote_system_type_t
Define the remote device system type.
Definition: bt_notify.h:257
#define BT_NOTIFY_MAX_GROUP_ID_LENGTH
The maximum length of the group ID field of the notification.
Definition: bt_notify.h:199
uint32_t app_id
The application ID of a remote device.
Definition: bt_notify.h:311
bt_notify_sms_t sms
SMS notification.
Definition: bt_notify.h:355
Data transfer in the SPP mode.
Definition: bt_notify.h:384
The action type to add a new notification.
Definition: bt_notify.h:268
uint32_t missed_call_count
The number of missed calls.
Definition: bt_notify.h:340
void(* bt_notify_callback_t)(void *data)
Defines the callback function type.
Definition: bt_notify.h:222
The command type (DATA, SYNC, ACKY, ACKN, VERN) have already registered in the service,.
Definition: bt_notify.h:371
bt_notify_notification_t notification
Generic notification.
Definition: bt_notify.h:354
bt_notify_data_source_t
This structure defines the data transfer mode, SPP or DOGP mode.
Definition: bt_notify.h:382
SMS notification event.
Definition: bt_notify.h:235
Define the structure for the callback content.
Definition: bt_notify.h:349
bt_notify_result_t
This structure defines the Bluetooth notification service results.
Definition: bt_notify.h:364
Repeated registration from the same sender with the same customized command.
Definition: bt_notify.h:372
Disconnection indication event.
Definition: bt_notify.h:230
uint32_t action_number
The action number.
Definition: bt_notify.h:307
Generic notification.
Definition: bt_notify.h:233
#define BT_NOTIFY_MAX_PAGE_TITLE_LENGTH
The maximum length of the page title.
Definition: bt_notify.h:192
uint32_t msg_id
The notification ID.
Definition: bt_notify.h:339
Success.
Definition: bt_notify.h:375
bt_notify_event_t evt_id
If the event ID is BT_NOTIFY_EVENT_DATA_RECEIVED, read the corresponding event_data field from this s...
Definition: bt_notify.h:350
Not implemented yet.
Definition: bt_notify.h:373
The remote device is an iOS device.
Definition: bt_notify.h:260
int32_t bt_notify_send_data(bt_bd_addr_t *bt_addr, const char *data, uint16_t data_len, bool is_new)
Call this function to send data.
#define BT_NOTIFY_MAX_ACTION_ID_LENGTH
The maximum length of the action ID field.
Definition: bt_notify.h:198
uint32_t timestamp
The timestamp.
Definition: bt_notify.h:310
The remote device is an Android device.
Definition: bt_notify.h:259
void bt_notify_init(uint8_t sdp_id)
This function initializes the Bluetooth notification service.
No available channel.
Definition: bt_notify.h:368
struct page_struct bt_notify_page_content_list_t
Define the page structure of the notification received from a remote device.
The action type to delete a notification.
Definition: bt_notify.h:269
bt_notify_action_type_t action
The action type.
Definition: bt_notify.h:312
uint32_t timestamp
The timestamp.
Definition: bt_notify.h:341
Invalid parameter is given during the registration.
Definition: bt_notify.h:370
bt_bd_addr_t bt_addr
The remote device&#39;s Bluetooth address.
Definition: bt_notify.h:352
The event indicating that the data could be sent.
Definition: bt_notify.h:231
Define the SMS content received from a remote device.
Definition: bt_notify.h:324
bt_notify_page_content_list_t * page_content
The message content.
Definition: bt_notify.h:327
#define BT_NOTIFY_MAX_PAGE_CONTENT_LENGTH
The length of the page content.
Definition: bt_notify.h:191
uint8_t bt_bd_addr_t[6]
Address type, defined in Bluetooth core specification version 4.2.
Definition: bt_type.h:180
Not supported.
Definition: bt_notify.h:365
bt_notify_event_t
The structure defines the Bluetooth notification service indication event.
Definition: bt_notify.h:227
Define the structure of the event BT_NOTIFY_EVENT_DATA_RECEIVED.
Definition: bt_notify.h:244
Missed call notification event.
Definition: bt_notify.h:234
uint32_t timestamp
the timestamp.
Definition: bt_notify.h:329
Invalid value.
Definition: bt_notify.h:383
bt_notify_result_t bt_notify_deregister_callback(const bt_bd_addr_t *bt_addr, bt_notify_callback_t cb_ptr)
This function unregisters the callback function that has already been registered. ...
uint16_t content[300]
The page content.
Definition: bt_notify.h:285
Invalid parameter.
Definition: bt_notify.h:366
#define BT_NOTIFY_MIN_RECEIVE_DATA_BUF_SIZE
Define the macros for the maximum and minimum buffer sizes and lengths.
Definition: bt_notify.h:187
bt_notify_event_data_t event_data
Data from remote device.
Definition: bt_notify.h:353
uint16_t title[30]
The page title.
Definition: bt_notify.h:286
int32_t error_code
The error code from the remote device.
Definition: bt_notify.h:247
bt_notify_action_type_t
Define the action type of the notification received from a remote device.
Definition: bt_notify.h:267
#define BT_NOTIFY_MAX_ACTION_NUM
The maximum number of actions.
Definition: bt_notify.h:196
bt_notify_result_t bt_notify_register_callback(const bt_bd_addr_t *bt_addr, char *sender, bt_notify_callback_t cb_ptr)
This function registers a callback function to the Bluetooth notification service.
Define the action content of the notification received from a remote device.
Definition: bt_notify.h:294
Invalid value.
Definition: bt_notify.h:258
#define BT_NOTIFY_MAX_SENDER_LENGTH
The maximum length of the sender field of the notification.
Definition: bt_notify.h:190
bt_notify_page_content_list_t * page_content
The notification&#39;s page content.
Definition: bt_notify.h:306
The end of event definition.
Definition: bt_notify.h:236
Failed.
Definition: bt_notify.h:369
bt_notify_missed_call_t missed_call
Missed call notification.
Definition: bt_notify.h:356
bt_notify_remote_system_type_t remote_system
The remote device&#39;s OS.
Definition: bt_notify.h:351