How to change value while a central tries to read a specific characteristic?

⚠️
Hi there.. thanks for coming to the forums. Exciting news! we’re now in the process of moving to our new forum platform that will offer better functionality and is contained within the main Dialog website. All posts and accounts have been migrated. We’re now accepting traffic on the new forum only - please POST any new threads at//www.xmece.com/support. We’ll be fixing bugs / optimising the searching and tagging over the coming days.
8个帖子/ 0新
Last post
Offline
Last seen:7 months 4 weeks ago
加入:2018-04-19 13:53
How to change value while a central tries to read a specific characteristic?

嗨对话框,我需要更新值,而中央尝试读取特定特性的值,我已经在user_custs1_def.c文件中的数据库定义中应用了RI选项:
// Time Characteristic Value
[svc1_idx_time_val] = {
SVC1_TIME_UUID_128, ATT_UUID_128_LEN, PERM(RD,ENABLE)|PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE),
perm(ri,启用)| def_svc1_time_char_len
},
But i still not catch the msg on gattc_read_req_ind_handler() function in cust1_task.c file.
此外,我发现如果我应用RI选项,我不能写入值成功。

设备:
PM_Dialog
Offline
Last seen:6小时21分钟前
Staff
加入:2018-02-08 11:03
嗨HM,

嗨HM,

您能否在论坛上查看以下上一篇之前的帖子?

https://support.dialog-semiconductor.com/forums/post/dialog-smartbond-bluetooth-low-energy-%E2%80%93-software/changing-value-database-dinamically

我遵循该帖子,我添加了perm(ri,启用)到ADC1特征的值。通过这样做,我能够在尝试读取ADC值1特征时触发CUST1_TASK.h的GATTC_READ_REQ_IND_HANDLER()函数。我建议您检查使用类似选项的普通配置文件的实现,也可以在读取倾斜的特性时触发vist_task.h的gattc_read_req_ind_handler()函数。

Thanks, PM_Dialog

Offline
Last seen:7 months 4 weeks ago
加入:2018-04-19 13:53
Hi Dialog:

Hi Dialog:
我有一个进一步的研究,我发现我是否添加了烫发(RI,启用),问题是我只能得到一旦触发gattc_read_req_ind_handler()函数,如果我再次读取,则不会触发。更重要的问题是,如果我试图execattmdb_att_set_value(...)function , it will return a status of 0x06 (ATT_ERR_REQUEST_NOT_SUPPORTED). It means that if my charactoristic apply write permission like this:PERM(RD,ENABLE)|PERM(WR, ENABLE) | PERM(WRITE_REQ, ENABLE), I can not set the charactoristic value.

PM_Dialog
Offline
Last seen:6小时21分钟前
Staff
加入:2018-02-08 11:03
嗨HM,

嗨HM,

在我的设置和修改ADC值特征上并添加了您提到的额外权限,我没有看到帖子中提到的内容。Just to be clear on that, there is no implementation on the SDK side that will handle this kind of transaction, that means that you will have to take care of the code in the gattc_read_req_ind_handler() since the SDK profile doesn’t convey any message towards the application in order to be aware that somebody read from that specific characteristic. So, regarding the fact that the callback occurs only once, how you are able to determine this ? Are you using breakpoints ? In case the break point hits once, then the link will be lost, and the central on the other side will delay as long as the supervision timeout until it realizes that he is not able to find the slave and issue a disconnection. In the case that the gattc_read_req_ind_handler() didn’t occur after one read the device would be disconnected after 30 seconds (which I don’t think is the case on your side), the reason for the disconnection would be that the confirmation message from the slave wouldn’t be sent. In the case of the SDK this is not the case since when you have the RI feature enabled you always get a slave response even if this is an error due to the incomplete custom profile for handling the RI case. So I trust that the callback occurs, tested that on my side. Regarding the attmdb_att_set_value(), you won’t need this, I suppose that what you would like to implement is that every time you get a read indication you would like to send a different value to the master, so in order to do that you will have to implement it on the gattc_read_req_ind_handler() callback, that means that as soon as the gattc_read_req_ind_handler() is triggered you should perform whatever tasks you would like to compute the value and then allocate and send a GATTC_READ_CFM message that will contain the value that you would like to send to the master (the value should be copied to the cfm->value struct). Please check the example below.

cfm = ke_msg_alloc_dyn(gattc_read_cfm,src_id,dest_id,gattc_read_cfm,长度);

cfm->handle = param->handle;

cfm->status = GAP_ERR_NO_ERROR;

CFM->长度= 2;

if (status == GAP_ERR_NO_ERROR)

{

test++;

Memcpy(CFM->值,和测试,2);

}

ke_msg_send(cfm);

测试是每次读取特定特性时应该增加的全局变量。

Thanks, PM_Dialog

Offline
Last seen:7 months 4 weeks ago
加入:2018-04-19 13:53
嗨,对话框:

嗨,对话框:
We test as your code and find that just update client characteristic configuration value (test at lightblue.) and the attribute value always "No value".
并且通过Gattc_Read_Req_ind_Handler(Custs1_Task)的代码,更新的值来自custs1_get_ccc_value(conidx,att_idx),它的长度始终为2,但长度
attribute value can as long as 20.Is there something wrong ?
Some code of gattc_read_req_ind_handler:
//如果已找到属性,则状态为GAP_ERR_NO_ERROR
if (status == GAP_ERR_NO_ERROR)
{
const struct cust_prf_func_callbacks *callbacks = custs_get_func_callbacks(TASK_ID_CUSTS1);

if(回调 - > att_db [att_idx] .uuid_size == att_uuid_16_len &&
*(uint16_t *)callbacks->att_db[att_idx].uuid == ATT_DESC_CLIENT_CHAR_CFG)
{
ccc_val = custs1_get_ccc_value (conidx,att_idx);
length = 2;
}
else
{
status = PRF_APP_ERROR;
}
}
//发送读取响应
cfm = ke_msg_alloc_dyn(gattc_read_cfm,src_id,dest_id,gattc_read_cfm,长度);
cfm->handle = param->handle;
cfm->status = status;
CFM->长度=长度;

if (status == GAP_ERR_NO_ERROR)
{
memcpy(cfm->value, &ccc_val, length);
}
ke_msg_send(cfm);

PM_Dialog
Offline
Last seen:6小时21分钟前
Staff
加入:2018-02-08 11:03
嗨HM,

嗨HM,

Let me try to check and replicate your issue and I will let you know as soon as possible.

Thanks, PM_Dialog

PM_Dialog
Offline
Last seen:6小时21分钟前
Staff
加入:2018-02-08 11:03
嗨HM,

嗨HM,

The Client Characteristic Configuration length is 2 bytes, and they used for enabling either notifications or indications. I am not able to understand what you mean that the attribute always has “No value”. In case of attribute value characteristics, the max length is 20 bytes (23 - 3 =20bytes) without MTU exchange. There isn’t something wrong, but be aware that the attribute value is 20 because you are not using the MTU exchange.

Thanks, PM_Dialog

Offline
Last seen:7 months 4 weeks ago
加入:2018-04-19 13:53
Hi ,Dialog:

Hi ,Dialog:
我的意思是我使用LightBlue来读取一个Charostory,如果我为CharoSorativer(Attmdb_att_set_value(...)设置)设置了一个十六进制值,否则它将返回'没有值',然后如果我按读取再次按钮,它将再次读取遥控器,现在它将再次返回值,但值等于第一个值。我想要设置或更改返回值,而浅蓝色读取每次的Charostory值。