adding notify permission to the characteristic

6 posts / 0 new
Last post
mohit3112
Offline
Last seen:6 months 2 weeks ago
Expert
加入:2014-08-04 13:45
adding notify permission to the characteristic

Hi,
I am trying to implement extra permissions in one of the characteristics in diss profile ( just for the sake of understanding the process ) , earlier it was read only , i also included the write command indication handler details are given below

diss.c
---------
/// Full DIS Database Description - Used to add attributes into the database
[DIS_IDX_MANUFACTURER_NAME_VAL] = {ATT_CHAR_MANUF_NAME, PERM(RD, ENABLE) | PERM(WR, ENABLE) | PERM(NTF, ENABLE), DIS_VAL_MAX_LEN, 0, NULL}

const struct att_char_desc diss_manufacturer_name_char = ATT_CHAR(ATT_CHAR_PROP_RD | ATT_CHAR_PROP_WR | ATT_CHAR_PROP_NTF , DIS_MANUFACTURER_NAME_CHAR,
ATT_CHAR_MANUF_NAME);

also i have implemented gattc_write_cmd_ind_handler

currently i am able to read and write to and from LightBlue iOS app to the DA14580 , It does show the notify function on app ( that is 'listen for notification' ) , but when i tap on 'listen for notification' it does not do anything ( unlike when in accelerometer profile 'listen for notification ' on tap changes to 'stop listening' i.e listening activated ) . so basically notify permission is not enabling properly . Can you point me to proper documentation or the method to implement notify permission in the characteristic .

Thanks

mohit3112
Offline
Last seen:6 months 2 weeks ago
Expert
加入:2014-08-04 13:45
I am waiting for any update

I am waiting for any update on my problem if you need more information , i can provide that too

gl_dialog
Offline
Last seen:3 years 3 months ago
工作人员
加入:2014-02-07 13:35
Dear Mohit,

Dear Mohit,

What you have done is perfecly right, well done!
You need to implement the BLE timer to send value every x seconds and then it will work.

Example:

1) in the void app_connection_func(struct gapc_connection_req_ind const *param) function, you need to call the function:

app_timer_set(APP_TIMER, TASK_APP, 500); // Interrupt every 5 seconds.

Beforehand, you need to declare the handler in the app_task_handlers.h as follow:

/* Default State handlers definition. */
EXTERN const struct ke_msg_handler app_default_state[] =
{
{APP_TIMER, (ke_msg_func_t)app_update_value_handler},
...
}

2) in the handler which is going to be triggered from the BLE timer every 5 seconds, you can write a new value into the characteristic:

int app_update_value_handler(ke_msg_id_t const msgid,
void const *param,
ke_task_id_t const dest_id,
ke_task_id_t const src_id)
{
uint8_t SetVal[20]={0};
app_timer_set(APP_TIMER, TASK_APP,100);
有效载荷+ +;

struct sample128_set_value_cmd *msg= KE_MSG_ALLOC(SAMPLE128_SET_VALUE_CMD,
TASK_SAMPLE128, TASK_APP,
sample128_set_value_cmd);
SetVal[0]=payload;
SetVal[1]=payload;
SetVal[2]=payload;
SetVal[3]=payload;
SetVal[4]=payload;
SetVal[5]=payload;
SetVal[6]=payload;
SetVal[7]=payload;
SetVal[8]=payload;
SetVal[9]=payload;
SetVal[10]=payload;
SetVal[11]=payload;
SetVal[12]=payload;
SetVal[13]=payload;
SetVal[14]=payload;
SetVal[15]=payload;
SetVal[16]=payload;
SetVal[17]=payload;
SetVal[18]=payload;
SetVal[19]=payload;

memcpy (msg->sample128_val,SetVal, 20);
ke_msg_send(msg);

return (KE_MSG_CONSUMED);
}

3) After taping on "listen for notification", you should see the new value every 5 seconds.

他希望这lp,

regards,

DIALOG TEAM.

fengmailx
Offline
Last seen:4 years 3 weeks ago
加入:2014-11-21 03:48
Hello Friends

Hello Friends
Now , I have the same problem, How do you solve?
I used gl_dialog's methods, but i not success,
I found in project of spotar, the patch_status , and smaple128 also have the NOTIFY characteristics ,I try change it in mem_info, but also failed,
How to do it?

mohit3112
Offline
Last seen:6 months 2 weeks ago
Expert
加入:2014-08-04 13:45
Hi fengmailx ,

Hi fengmailx ,
try implementing this function it worked for me

void update_value(uint8_t* packet_data)
{
attmdb_att_update_value((DIS_IDX_MANUFACTURER_NAME_VAL + diss_env.shdl), APP_DIS_MANUFACTURER_NAME_LEN,0,(uint8_t *)packet_data);

prf_server_send_event((prf_env_struct *)&diss_env, false,(DIS_IDX_MANUFACTURER_NAME_VAL + diss_env.shdl));
}

Mohit Maheshwari

fengmailx
Offline
Last seen:4 years 3 weeks ago
加入:2014-11-21 03:48
Dear Mohit

Dear Mohit
thanks for reply, I add a user profile and it work will.