如何在中央尝试读取特定特征时更改值?

了解更多常见问题解答教程

8个职位/0个新职位
最后一篇
HM.
离线
最后一次露面:6个月1周前
加入:2018-04-19 13:53
如何在中央尝试读取特定特征时更改值?

您好,对话框,我需要更新值当中心尝试读取特定特征的值时,我已经在user\u custs1\u def.c文件的数据库定义中应用了RI选项,如下所示:
//时间特征值
[SVC1\u IDX\u TIME\u VAL]={
svc1_time_uuid_128,att_uuid_128_len,perm(rd,启用)| perm(wr,启用)|perm(write_req,启用),
PERM(RI,ENABLE)| DEF|u SVC1|u TIME|u CHAR|LEN
},
但我仍然没有在cust1_task.c文件中捕获gattc_read_req_ind_handler()函数上的msg。
此外,我发现如果我应用RI选项,我就不能成功地写值。

设备:
PM_DIALOG.
离线
最后一次露面:18分钟46秒前
职员
加入:2018-02-08 11:03
嗨,嗯,

嗨,嗯,

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

https://support.dialog-semicondiondiondimicon.com/forums/post/dialog-smartbond-bluetooth-low-energy-%2%80%93-software/changing-value-database-dinamamly

我跟随那篇文章,在ADC1特性的值中添加PERM(RI,ENABLE)。通过这样做,我能够在尝试读取ADC值1特征时触发cust1\u task.h的gattc\u read\u req\u ind\u handler()函数。我建议您检查DISS配置文件的实现,该配置文件使用类似的选项,并且在读取DISS特性时是否触发DISS\U task.h的gattc\u read\u req\u ind\u handler()函数。

谢谢,PM_DIALOG.

HM.
离线
最后一次露面:6个月1周前
加入:2018-04-19 13:53
嗨对话框:

嗨对话框:
我有进一步的研究,我发现如果我加上PERM(RI,ENABLE),问题是我只能一旦触发gattc\u read\u req\u ind\u handler()函数,如果我再次读取,它不会触发。更重要的问题是如果我试图执行attmdb_att_set_value(...)函数,它将返回0x06的状态(att_err_request_not_supported.)。这意味着,如果我的CharoStory应用程序写入权限如此:PERM(RD,ENABLE)| PERM(WR,ENABLE)|perm(write_req,启用),我无法设置charodoratival值。

PM_DIALOG.
离线
最后一次露面:18分钟46秒前
职员
加入:2018-02-08 11:03
嗨,嗯,

嗨,嗯,

在我的设置和修改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\u MSG\u ALLOC\u DYN(GATTC\u READ\u cfm,src\u id,dest\u id,GATTC\u READ\u cfm,length);

cfm-> handle = param->手柄;

cfm-> status = gap_err_no_error;

cfm->长度=2;

if(status == gap_err_no_error)

{

测试++;

memcpy(cfm->value,&test,2);

}

KE_MSG_SEND(CFM);

测试是一个全局变量,每次读取特定特征时都应增加该变量。

谢谢,PM_DIALOG.

HM.
离线
最后一次露面:6个月1周前
加入:2018-04-19 13:53
嗨,对话:

嗨,对话:
我们测试为您的代码,并发现只需更新客户端特征配置值(在LightBlue时测试)和属性值始终“无值”。
根据gattc\u read\u req\u ind\u handler(custs1\u task)中的代码,要更新的值来自custs1\u get\u ccc\u value(conidx,att\u idx),它的长度总是2,但是
属性值可以只要20.IS有问题?
gattc_read_req_ind_handler的一些代码:
//如果找到属性,则状态为GAP\u ERR\u NO\u 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 *)回调 - > ATT_DB [ATT_IDX] .uuuid == ATT_DESC_CLIENT_CHAR_CHAR_CHAR_CHAR)
{
ccc_val = custs1_get_ccc_value(conidx,att_idx);
长度= 2;
}
别的
{
status = prf_app_error;
}
}
//发送读取响应
cfm=KE\u MSG\u ALLOC\u DYN(GATTC\u READ\u cfm,src\u id,dest\u id,GATTC\u READ\u cfm,length);
cfm-> handle = param->手柄;
cfm-> status = status;
cfm->长度=长度;

if(status == gap_err_no_error)
{
Memcpy(CFM->值,&CCC_Val,长度);
}
KE_MSG_SEND(CFM);

PM_DIALOG.
离线
最后一次露面:18分钟46秒前
职员
加入:2018-02-08 11:03
嗨,嗯,

嗨,嗯,

让我试着检查并复制你的问题,我会尽快通知你。

谢谢,PM_DIALOG.

PM_DIALOG.
离线
最后一次露面:18分钟46秒前
职员
加入:2018-02-08 11:03
嗨,嗯,

嗨,嗯,

客户端特性配置长度为2个字节,它们用于启用通知或指示。我无法理解你的意思是该属性总是有“没有价值”。如果属性值特性,最大长度为20字节(23 - 3 = 20bytes),没有MTU交换。没有问题,但请注意,属性值为20,因为您不使用MTU Exchange。

谢谢,PM_DIALOG.

HM.
离线
最后一次露面:6个月1周前
加入:2018-04-19 13:53
嗨,对话框:

嗨,对话框:
我的意思是,我用浅蓝色来读取字符,如果我为字符设置一个值(attmdb\u att\u set\u value(…)),我将得到一个十六进制值,否则它将返回“No value”,然后如果我按read again按钮,它将再次读取遥控器,现在它将再次返回一个值,但是这个值等于第一个值,我想设置或更改返回值,而浅蓝色每次都读取字符值。