久久精品国产精品国产一区,少妇扒开毛毛自慰喷水,国产精品无码电影在线观看 ,久久天天躁夜夜躁狠狠85麻豆

思澈科技軟件開發(fā)工具包  2.20
ANCS客戶端

ANCS 介紹

Apple 通知中心服務(wù)(ANCS)是 IOS 設(shè)備中的 GATT 服務(wù)。 該服務(wù)可以通知配件在 IOS 設(shè)備中的通知,稱為 Nofication Provider(NP)。 本地設(shè)備充當(dāng)附件,稱為通知消費(fèi)者(NC)。

NP有3個(gè)特點(diǎn):

  • 通知來源 NC 啟用 CCCD 后,通知源特性將發(fā)送帶有 categoryID 和計(jì)數(shù)的通知。
    通知數(shù)據(jù)格式
    • 事件 ID 通知 NC 是否添加、修改或刪除通知。
    • EventFlags 通知通知的特殊性。 NC 可以決定是通知用戶還是只是過濾。
    • CategoryID 通知通知的類別,如來電、新聞或消息。
    • CategoryCount 通知通知中心中存在的通知計(jì)數(shù)。
    • NotificationUID 是用于標(biāo)識(shí)類別的 32 位 ID。
  • 控制點(diǎn)和數(shù)據(jù)源

    NC 可以向控制點(diǎn)寫入命令以與 NP 交互以獲取詳細(xì)信息或執(zhí)行操作。 有3個(gè)命令:

    • 獲取通知屬性。 此命令允許 NC 從 Notification 檢索通知的模式詳細(xì)信息。
      獲取通知屬性命令格式
      • CommandID 應(yīng)設(shè)置為 0
      • NotificationUID 來自通知源的通知。
      • AttributeIDs是NC想要獲取更多詳細(xì)信息的通知屬性。
        獲取通知屬性命令的響應(yīng)格式
      • CommandID、Notification UID、Attribute_ID 都與 get Notification Attributes 命令相同。
      • 屬性長度和屬性是與屬性ID 相關(guān)聯(lián)的長度和數(shù)據(jù)。 數(shù)據(jù)包括詳細(xì)信息。
    • 獲取APP屬性。 該命令允許 NC 檢索已安裝 APP 的詳細(xì)信息。
      獲取APP屬性命令格式
      • CommandID 應(yīng)設(shè)置為 1
      • APP Identifier 是從通知 APP_ID 屬性中獲取的字符串 ID。 表示在IOS中注冊(cè)的APP ID。
      • APP AttributeIDs是NC想要獲取更多詳細(xì)信息的APP屬性。
        獲取APP屬性命令的響應(yīng)格式
      • CommandID、APP Identifier 與 get APP Attributes 命令相同。
      • 屬性長度和屬性是與屬性ID 相關(guān)聯(lián)的長度和數(shù)據(jù)。 數(shù)據(jù)包括詳細(xì)信息。
    • 執(zhí)行通知操作。 此命令允許 NC 對(duì)特定 IOS 通知執(zhí)行預(yù)定操作。 有兩個(gè)動(dòng)作:
      1. 積極行動(dòng)
      2. 消極行動(dòng) IOS 會(huì)根據(jù)動(dòng)作執(zhí)行行為,但UI 行為取決于IOS 和通知。 例如,如果通知是來電,則積極動(dòng)作可能會(huì)接聽它,而消極動(dòng)作可能會(huì)拒絕它。 但行為可能會(huì)在其他通知中改變。

實(shí)施 ANCS NC

Sibles ANCS 提供 API 來搜索 IOS 設(shè)備中的 ANCS 并配置通知屬性。 用戶只需要執(zhí)行以下操作:

  1. 配置預(yù)期的通知和 APP 屬性和關(guān)聯(lián)長度。
  2. 收到APP_ID屬性信息后,使用相關(guān)API獲取APP屬性。
  3. 使用 perform action API 為指定的 attributeID 執(zhí)行動(dòng)作。

有關(guān) ANCS API 的詳細(xì)信息,請(qǐng)參閱 ANCS .

這是示例代碼:

int app_ancs_event_handler(uint16_t event_id, uint8_t *data, uint16_t len, uint32_t context)
{
switch (event_id)
{
// ANCS only allows paired device to access its service.
{
rt_kprintf("encryt ind %d", ind->conn_idx);
// configure attributes and its length.
// enable ANCS
break;
}
{
// Go through all attributes data.
rt_kprintf("received_notify %d, attr_count %d\r\n", notify->evt_id, notify->attr_count);
!(notify->evt_flag & BLE_ANCS_EVENT_FLAG_PRE_EXISTING)) // No need to shown pre-existing notifcations
{
ble_ancs_attr_value_t *value = notify->value;
ble_ancs_dev_app_id_name_t *app_id_name;
uint32_t i;
for (i = 0; i < notify->attr_count; i++)
{
if (value->len == 0)
{
value = (ble_ancs_attr_value_t *)((uint8_t *)value + sizeof(ble_ancs_attr_value_t));
continue;
}
if (value->attr_id == BLE_ANCS_NOTIFICATION_ATTR_ID_TITLE)
{
// Handle title content.
}
else if (value->attr_id == BLE_ANCS_NOTIFICATION_ATTR_ID_APP_ID)
{
// Get APP attribute
ble_ancs_get_app_attr(app_id, value->len + 1);
}
else if (value->attr_id == BLE_ANCS_NOTIFICATION_ATTR_ID_MESSAGE)
{
// Handle message content.
}
value = (ble_ancs_attr_value_t *)((uint8_t *)value + sizeof(ble_ancs_attr_value_t) + value->len);
}
break;
}
break;
}
{
// Handle APP display name
break;
}
default:
break;
}
return 0;
}
// Reigster event to listen ancs events.
BLE_EVENT_REGISTER(app_ancs_event_handler, NULL);
ble_ancs_noti_attr_t::evt_id
uint8_t evt_id
Definition: bf0_ble_ancs.h:257
len
uint16_t len
Definition: bf0_ble_ancs.h:226
ble_ancs_noti_attr_t::attr_count
uint8_t attr_count
Definition: bf0_ble_ancs.h:262
BLE_ANCS_GET_APP_ATTR_RSP
@ BLE_ANCS_GET_APP_ATTR_RSP
Definition: bf0_ble_ancs.h:85
ble_gap_encrypt_ind_t::conn_idx
uint8_t conn_idx
Connection index.
Definition: bf0_ble_gap.h:1719
BLE_ANCS_EVENT_FLAG_PRE_EXISTING
@ BLE_ANCS_EVENT_FLAG_PRE_EXISTING
Definition: bf0_ble_ancs.h:146
BLE_GAP_ENCRYPT_IND
@ BLE_GAP_ENCRYPT_IND
Definition: bf0_ble_gap.h:160
BLE_ANCS_EVENT_ID_NOTIFICATION_ADDED
@ BLE_ANCS_EVENT_ID_NOTIFICATION_ADDED
Definition: bf0_ble_ancs.h:133
data
uint8_t data[]
Definition: bf0_ble_ancs.h:227
ble_ancs_attr_enable
void ble_ancs_attr_enable(uint8_t attr_index, uint8_t enable, uint16_t len)
Configure notification attribte id and according length.
BLE_ANCS_NOTIFICATION_ATTR_ID_MESSAGE
@ BLE_ANCS_NOTIFICATION_ATTR_ID_MESSAGE
Definition: bf0_ble_ancs.h:169
BLE_ANCS_NOTIFICATION_ATTR_ID_APP_ID
@ BLE_ANCS_NOTIFICATION_ATTR_ID_APP_ID
Definition: bf0_ble_ancs.h:166
BLE_ANCS_NOTIFICATION_ATTR_ID_TITLE
@ BLE_ANCS_NOTIFICATION_ATTR_ID_TITLE
Definition: bf0_ble_ancs.h:167
ble_ancs_noti_attr_t::evt_flag
uint8_t evt_flag
Definition: bf0_ble_ancs.h:258
BLE_ANCS_NOTIFICATION_IND
@ BLE_ANCS_NOTIFICATION_IND
Definition: bf0_ble_ancs.h:84
ble_ancs_get_app_attr
int32_t ble_ancs_get_app_attr(uint8_t *app_id, uint8_t app_id_len)
Acquire app attribute via app ID.
ble_gap_encrypt_ind_t
The structure of BLE_GAP_ENCRYPT_IND.
Definition: bf0_ble_gap.h:1717
ble_ancs_enable
uint8_t ble_ancs_enable(uint8_t conn_idx)
Enable ble ancs profile service, it will search ANCS service from peer device. It should be called af...
ble_ancs_noti_attr_t::value
ble_ancs_attr_value_t * value
Definition: bf0_ble_ancs.h:263
ble_ancs_noti_attr_t
The structure of BLE_ANCS_NOTIFICATION_IND.
Definition: bf0_ble_ancs.h:256
BLE_EVENT_REGISTER
#define BLE_EVENT_REGISTER(func, context)
Macro of siflie ble event handler register.
Definition: bf0_ble_common.h:172