Hello I'm developing my own custom profile for DA14580, following the guide (AN-B-029). There are a few parts which I'm not sure about, so I need some clarifications from you guys.
1. In part 7.2.4 of the doc, while we are modifying "struct sample128_val_ind" (and also for parts until the end of 7.2.4), we are changing all the data types related to characteristic 1. Is it related to the WRITE property? What if there are several characteristics with the WRITE properties? Shall I do the same for all those with WRITE properties? And when we need the "sample128_send_val" method, how shall I modify it? Should I define one for each characteristic with WRITE property, or should I change the parameters? Sorry I'm quite new to this area, so can you give me some advice on how to do it?
2. In part 7.3.6 of the doc, is this part related to NOTIFY property? Shall I do this for all the characteristics with NOTIFY properties?
Thank you!
Hi richardejiang,
When a writting is performed at a characteristic the handler gattc_write_cmd_ind_handler() is called, from there, depending on the characteristic, the corresponding function is called that issues the writting indication. So yes you have to do the same for all the characteristics that can be written and declare new messages for every indication you want and new functions that send the indication messages. And yes section from 7.3 adds a characteristic with a notify property.
Thanks MT_dialog
Hello,
Thank you for the reply, that does help a lot. However, I still got a few doubts regarding the code (for gattc_write_cmd_ind_handler()). I've changed sample128_val_send(uint8_t) to this: sample128_val_send(simple_char_1,simple_char_3,simple_char_7) (I got three characteristics with WRITE properties), then at gattc_write_cmd_ind_handler, I changed the checking condition to this: if(char_code == SAMPLE128_CHAR_1 || char_code == SAMPLE128_CHAR_3 || char_code == SAMPLE128_CHAR_7), after this is it correct to do this:
if(char_code == SAMPLE128_CHAR_1) attmdb_att_set_value(param->handle, sizeof(simple_char_1), (uint8_t *)¶m->value[0]);
else if (char_code == SAMPLE128_CHAR_3) attmdb_att_set_value(param->handle, sizeof(simple_char_3), (uint8_t *)¶m->value[0]);
else attmdb_att_set_value(param->handle, sizeof(simple_char_7), (uint8_t *)¶m->value[0]);
Then how should I use sample128_send_val() (right after the above 3 statements, under if(param->last))? I set the number of parameters to 3, but I don't know what should I put as the parameters as sample128_send_val() here.
Thank you!
Hi richardejiang,
From function sample128_val_send you send the indication that the first characteristic has been written. You have to declare different message indications for every different characteristic and send different indication messages, the same thing you did in order to add the messages for the third characteristic from the tutorial. Please advice other reference projects as an example.
Thanks MT_dialog
Hello:
Can you be a little bit more specific on which project I can refer to as the example? I think I get the idea: I'll have to define a whole set of functions and structures for every characteristic with WRITE property (example: in sample128_task.h, a samle128_val_ind_1 for char 1 with WRITE property, a sample128_val_ind_2 for char 2 with WRITE property...... another example in sample128.c: sample128_send_val_1 for char 1, sample128_send_val_2 for char 2...) Am I understanding it correctly?
Thank you!
Hi richardejiang,
I don't have a particular project in mind, but you got the point.
Then in sample128_task.c in the gattc_write_cmd_ind_handler you can use something like this.
如果(char_code = = SAMPLE128_1_CHAR)
{
//Save value in DB
attmdb_att_set_value(param->handle, sizeof(uint8_t), (uint8_t *)¶m->value[0]);
if(param->last)
{
sample128_send_val(param->value[0]);
}
status = PRF_ERR_OK;
}
else if ( char_code == SAMPLE128_2_CHAR)
{
attmdb_att_set_value(param->handle, sizeof(uint8_t), (uint8_t *)¶m->value[0]);
if(param->last)
sample128_send_val_2(param->value[0]);
status = PRF_ERR_OK;
}
else if (char_code == SAMPLE128_3_CHAR)
{
attmdb_att_set_value(param->handle, sizeof(uint8_t), (uint8_t *)¶m->value[0]);
if(param->last)
sample128_send_val_3(param->value[0]);
status = PRF_ERR_OK;
}
Thanks MT_dialog