This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ADDING Extra "notification attributes" IN ANCS

Hi, team

I am using  nRF5_SDK_15.3.0_59ac345/examples/ble_peripheral/ble_app_ancs_c sample application. and i wnated to add extra notification attribute. 

added BLE_ANCS_KEY1 in this Enum  ble_ancs_c_notif_attr_id_val_t.

/**@brief IDs for iOS notification attributes. */
typedef enum
{
BLE_ANCS_NOTIF_ATTR_ID_APP_IDENTIFIER = 0, /**< Identifies that the attribute data is of an "App Identifier" type. */
BLE_ANCS_NOTIF_ATTR_ID_TITLE, /**< Identifies that the attribute data is a "Title". */
BLE_ANCS_NOTIF_ATTR_ID_SUBTITLE, /**< Identifies that the attribute data is a "Subtitle". */
BLE_ANCS_NOTIF_ATTR_ID_MESSAGE, /**< Identifies that the attribute data is a "Message". */
BLE_ANCS_NOTIF_ATTR_ID_MESSAGE_SIZE, /**< Identifies that the attribute data is a "Message Size". */
BLE_ANCS_NOTIF_ATTR_ID_DATE, /**< Identifies that the attribute data is a "Date". */
BLE_ANCS_NOTIF_ATTR_ID_POSITIVE_ACTION_LABEL, /**< The notification has a "Positive action" that can be executed associated with it. */
BLE_ANCS_NOTIF_ATTR_ID_NEGATIVE_ACTION_LABEL, /**< The notification has a "Negative action" that can be executed associated with it. */
BLE_ANCS_KEY1,
} ble_ancs_c_notif_attr_id_val_t;

and also added "KEY1" to lit_attrid

/**@brief String literals for the iOS notification attribute types. Used when printing to UART. */
static char const * lit_attrid[BLE_ANCS_NB_OF_NOTIF_ATTR] =
{
"App Identifier",
"Title",
"Subtitle",
"Message",
"Message Size",
"Date",
"Positive Action Label",
"Negative Action Label"
"KEY1"
};

and added in service_init function

ret = nrf_ble_ancs_c_attr_add(&m_ancs_c,
BLE_ANCS_KEY1,
m_attr_negaction,
ATTR_DATA_SIZE);

APP_ERROR_CHECK(ret);

And I am sending push pay load

{ 

"aps":{ 
"alert":{ 
"body":"Body",
"title":"title",
"subtitle":"New Subtitle",
"key1":"Value1"
}
}

}

from the following site https://pushtry.com

and following  printed in the serial monitor 

<info> app: App Identifier: com.xcubelabs.demo
<info> app: Title: title
<info> app: Subtitle: New Subtitle
<info> app: Message: Body
<info> app: Message Size: 4
<info> app: Date: 20200113T
<info> app: Positive Action Label: (N/A)
<info> app: Negative Action LabelKEY1: Clear
<info> app: : (N/A)

But i didnt get that key value. 

please help me out this problem. if any Example code snippets are availble please send to me .

The main file and header file is attached below

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/**
* Copyright (c) 2012 - 2019, Nordic Semiconductor ASA
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form, except as embedded into a Nordic
* Semiconductor ASA integrated circuit in a product or a software update for
* such product, must reproduce the above copyright notice, this list of
* conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* 3. Neither the name of Nordic Semiconductor ASA nor the names of its
* contributors may be used to endorse or promote products derived from this
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

nrf_ble_ancs_c.h

We look forward to your inputs.

We appreciate your quick response on this.

Thank you.