完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
大家好,
我在更新master上的某些值时遇到问题,我正在使用bluenrg-1我有一个设备作为主设备而另一个设备作为从设备。奴隶有一个按钮,我已连接,每次按下从属按钮时,调用函数aci_gatt_update_char_value()包含一个值,我在奴隶上有配置: aci_gatt_add_char(Service_Handle, UUID_TYPE_128, &安培; char_uuid, CHAR_VALUE_LENGTH, CHAR_PROP_READ | CHAR_PROP_NOtiFY, ATTR_PERMISSION_NONE, GATT_DONT_NOTIFY_EVENTS, ENCRYPTION_KEY_SIZE, ATT_HAS_FIXED_LENGTH, & CharHandle);主人正在发现奴隶的服务和特征。我需要做更多或不同的方式吗?将在主人上调用哪个事件函数? 我可以读取主设备每隔x次连接请求值的值,但是我想在按下按钮时接收主设备上的值。 谢谢 以上来自于谷歌翻译 以下为原文 Hello all, I am having a problems to update some values on the master, I am using bluenrg-1 I have one device working as a master and other as a slave. The slave has a button, I have both connected and every time I press the button on the slave the function aci_gatt_update_char_value() is called containing a value, I have on the slave that configuration: aci_gatt_add_char( Service_Handle, UUID_TYPE_128, &char_uuid, CHAR_VALUE_LENGTH, CHAR_PROP_READ|CHAR_PROP_NOTIFY, ATTR_PERMISSION_NONE, GATT_DONT_NOTIFY_EVENTS, ENCRYPTION_KEY_SIZE, ATT_HAS_FIXED_LENGTH, &CharHandle);the master is discovering the service and characteristic from the slave. Do I need to do something more or in a different manner? Which event function will be call on the master? I can read the values from the master requesting the value every x time once both are connected but I would like to received the value on the master just the button is pressed. Thank you |
|
相关推荐
16个回答
|
|
嗨,
如果我理解你的问题,你希望你的GATT客户端每次更新其特性时都会收到来自GATT服务器的通知,而不必在轮询模式下读取它。为了使其工作,您必须在GATT服务器上显式启用通知,以便它可以通知GATT客户端有关更改。要从GATT客户端(在您的情况下为主服务器)启用通知,您需要通过调用aci_gatt_write_char_desc()函数来编写您感兴趣的服务器特性的描述符。这样,每次服务器特性的值发生变化时,都会通知客户端。 有关工作示例,您可以参考“Project BLE_Examples BLE_Chat_Master_Slave”项目。 最好的祝福, 安东尼奥 以上来自于谷歌翻译 以下为原文 Hi, if I understood correctly your question, you want your GATT client o receive notifications from the GATT server each time its characteristic is updated, without having to read in it in polling mode. In order to make it work, you have to explicitly enable notifications on the GATT server, so that it can notify the GATT client about changes. To enable notifications, from the GATT client (the master in your case) you need to write the descriptor of the characteristic of the server that you are interested in, by calling the aci_gatt_write_char_desc() function. In this way, each time that the value of the characteristic of the server will change, the client will be notified. For a working example, you can refer to the 'ProjectBLE_ExamplesBLE_Chat_Master_Slave' project. Best regards, Antonio |
|
|
|
你好Antonio,
感谢您的回答,是的,正如您所说的,每次按下按钮时,都会从从站向主站发送不同的值。 我刚刚在主机上添加了特性后使用了aci_gatt_write_char_desc(),但是当我按下从机上的按钮时仍然没有在主机上接收任何内容。 在奴隶上通知( CHAR_PROP_NOTIFY) 在添加特征时定义,主节点在连接时将发现它。我认为当在从属按钮上按下按钮时会在主控器上调用一个函数,这样我就可以获得新的值。对它有什么帮助吗? 谢谢 以上来自于谷歌翻译 以下为原文 Hello Antonio, Thank you for your answer, yes as you said every time I press the button, a different value will be sent from the slave to the master. I have used aci_gatt_write_char_desc() just after adding the characteristic on the master but still not receiving anything on the master when I press the button on the slave. On the slave the notify ( CHAR_PROP_NOTIFY) is defined when adding the characteristic and the master will discover it when both are connected. I thought a function would be called on the master when the button is pressed on the slave so I can obtain the new value.Any help with it? Thank you |
|
|
|
我将尝试总结您需要执行的步骤:
1.在master上,在你发现奴隶的特性之后,你必须在与该特征相对应的属性句柄上调用aci_gatt_write_char_desc()函数(我在这里强调我们正在讨论的特征,而不是主)。请注意,您需要在基本手柄上添加2 ,因为这将让你写出你的特征的描述符(句柄+ 1是特征的值,而句柄+ 2是特征的描述符).2。在从站上按下按钮时,可以在要更新的特征上调用aci_gatt_update_char_value()。 3.只要特性值在从站上发生变化,在主站上就会看到aci_gatt_notification_event()回调将被触发。在这里,您可以添加在从属按钮上按下时要执行的代码(例如,读取值并相应地闪烁LED等) 以上来自于谷歌翻译 以下为原文 I'll try to summarize the steps you need to perform: 1. on the master, after you discover the characteristic of your slave, you must call the aci_gatt_write_char_desc() function on the attribute handle that corresponds to that characteristic (I emphasize here that we're talking about a characteristic of the , not of the master). Please notice that you need to add 2 to the base handle , as this will let you write the descriptor of your characteristic (handle + 1 is the value of the characteristic, while handle + 2 is the descriptor of the characteristic).2. When a button is pressed on the slave, you call aci_gatt_update_char_value() on the characteristic you want to update. 3. Whenever the value of the characteristic will change on the slave, on the master you will see that the aci_gatt_notification_event() callback will be fired. Here you can add the code that you want to be executed when the button is pressed on the slave (e.g. read the value and blink an LED accordingly, etc.) |
|
|
|
谢谢你的快速反应安东尼奥,
只是一个问题,以防我做错了什么。 假设我在从站上定义了特征'A',创建了Slave / Master之间的连接,并且Master发现了特性'A',然后在master上我应该调用aci_gatt_add_char()来添加特征'A'或者我不应该添加,只需调用函数aci_gatt_write_char_desc()。 谢谢 以上来自于谷歌翻译 以下为原文 Thank you for your fast response Antonio, Just a question in case I am doing something wrong. Lets say I have Characteristic 'A' defined on the slave, the connection between Slave/Master is created and Master discover Characteristic 'A', then on the master should I call aci_gatt_add_char() to add characteristic 'A' or I should not added, just call the function aci_gatt_write_char_desc(). Thank you |
|
|
|
我很高兴它现在有效!
您也可以在主服务器上添加此特性,但您必须手动同步该值。 以上来自于谷歌翻译 以下为原文 I'm glad it works now! You can add this characteristic also on your master, but you'll have to synchronize the value manually. |
|
|
|
您不必向主设备添加特征“A”,因为它是您的从设备的特征。在主服务器上,您只需要调用函数aci_gatt_write_char_desc()。在调用它时,请确保传递奴隶特征'A'的句柄,就像你在主人身上发现的那样,加上2.所以如果句柄是h,请使用(h + 2)作为参数。
以上来自于谷歌翻译 以下为原文 You don't have to add characteristic 'A' to the master, as it is a characteristic of your slave. On the master, you just need to call the function aci_gatt_write_char_desc(). When calling it, please make sure to pass the handle of characteristic 'A' of the slave, just as you discovered it on the master, plus 2. So if the handle is h, please use (h+2) as an argument. |
|
|
|
非常感谢你的帮助,现在正在努力。
我只是想知道在发现主人的特征'A'时是否有任何问题。由于主设备将作为主设备/从设备(slave(a)==> master / slave(b)==> master(c))所以我正在考虑使从站(a)到终端主站(c)。 谢谢 以上来自于谷歌翻译 以下为原文 Thank you so much for your help, now is working. I was just wondering if there is any problem on adding that characteristic 'A' on the master when it is discovered. As the master will be working as a master/slave ( slave(a) ==> master / slave(b) ==> master(c) ) so I was thinking about using the same characteristic to just populate the value from the slave(a) to the end master(c). Thank you |
|
|
|
嗨Antonio,
添加多个特征描述符时遇到问题。第一个添加但其他人给我一个错误(0x46 BLE_STATUS NOT_ALLOWED) 一旦连接建立,我正在调用函数aci_gatt_write_char_desc(),因为我需要连接句柄。 正如你告诉我的那样,我正在传递手柄+2。 我需要添加3个描述符,我正在做的是: aci_gatt_write_char_desc(Connectionhandle,handleA + 2,lengthA,Value); aci_gatt_write_char_desc(Connectionhandle,handleB + 2,lengthB,Value); aci_gatt_write_char_desc(Connectionhandle,handleC + 2,lengthC,Value); 其中value是Value = {0x01,0x00} 谢谢 以上来自于谷歌翻译 以下为原文 Hi Antonio, I am having a problem when adding more than one characteristic descriptor. The first one is added but the others are giving me an error (0x46 BLE_STATUS NOT_ALLOWED) I am calling the function aci_gatt_write_char_desc() once the connection is stablished as I need the Connection Handle. As you told me, I am passing the handle + 2. I need to add 3 descriptors, what I am doing is: aci_gatt_write_char_desc(Connectionhandle, handleA+2,lengthA,Value); aci_gatt_write_char_desc(Connectionhandle, handleB+2,lengthB,Value); aci_gatt_write_char_desc(Connectionhandle, handleC+2,lengthC,Value); Where value is Value ={0x01,0x00} Thank you |
|
|
|
要添加更多信息:
- 第一个句柄长度是1个字节。 - 第一个句柄长度是6个字节。 - 第一个句柄长度是16个字节。 它有什么问题吗? 谢谢 以上来自于谷歌翻译 以下为原文 To add more information: - first handle length is 1 byte. - first handle length is 6 bytes. - first handle length is 16 bytes. Is there any problem about it? Thank you |
|
|
|
嗨Jamp,
只是为了澄清,aci_gatt_write_char_desc()的参数是: - 长度:2个字节(给出命令的连接句柄) - 长度:2个字节(要写入的属性的句柄) - 长度:1个字节(要写入的值的长度) (要写的价值) 亲切的问候 安德里亚 以上来自于谷歌翻译 以下为原文 Hi Jamp, just to clarify, the arguments for the aci_gatt_write_char_desc() are: - Length: 2 bytes (Connection handle for which the command is given) - Length: 2 bytes (Handle of the attribute to be written) - Length: 1 byte (Length of the value to be written) (Value to be written) Kind regards Andrea |
|
|
|
你好Andrea,
是的,这些是我正在使用的论据。不确定AttrVal应该是什么。应该永远 AttrVal = {0x01,0x00} 我不知道是否有任何差异,因为我使用master作为协同进程 如果我只声明其中一个特性,那么无论哪个特性都没关系,每次更改值时,我都会收到主服务器上的更新。 谢谢 以上来自于谷歌翻译 以下为原文 Hello Andrea, Yes those are the arguments I am using. Not sure what the AttrVal should be. Should be always AttrVal = {0x01,0x00} I don't know if there is any difference as I am using the master as a coprocess If I just declare one of the characteristics, it does not matter which one, I will receive always an update on the master, every time the value is changed. Thank you |
|
|
|
做了更多测试,我可以看到接收到主设备的唯一特性是从设备上添加的第一个特性,首先添加特性并不重要,它是主设备上唯一接收的特性。
以上来自于谷歌翻译 以下为原文 Doing more tests, I can see that the only characteristic that is received to the master is the first characteristic added on the slave, it does not matter the characteristic is first added, it is the only one received on the master. |
|
|
|
你好,
当我调用函数时,我检查过: aci_gatt_write_char_desc( Connectionhandle,句柄+ 2,长度,值)长度不同于1我得到错误0x41(失败)一些想法为什么是那个错误。 谢谢 以上来自于谷歌翻译 以下为原文 Hello, I have checked that when I am calling the function with: aci_gatt_write_char_desc( Connectionhandle, handle+2, length, Value) with length different to 1 I get the error 0x41(Failed) some idea why is that error. Thank you |
|
|
|
嗨Jamp,
这很奇怪,因为长度应始终为0x02。它是否适用于任何炭? 问候 安德里亚 以上来自于谷歌翻译 以下为原文 Hi Jamp, It is strange, because the length should be always 0x02. Is it happening for any char? Regards Andrea |
|
|
|
嗨Jamp,
请注意,在打电话之前 继续aci_gatt_write_char_desc()后,您应该等待上一个操作完成(即,要生成aci_gatt_proc_complete_event事件)。 希望能有所帮助。 安德里亚 以上来自于谷歌翻译 以下为原文 Hi Jamp, please, note also that before calling succeeding aci_gatt_write_char_desc() you should wait for the previous action to complete (i.e., for the aci_gatt_proc_complete_event event to be generated). Hope that can help. Andrea |
|
|
|
是的我感谢它,我在调用函数之间添加了等待时间
以上来自于谷歌翻译 以下为原文 Yes I have it working thanks, I added a waiting time between the calling functions |
|
|
|
只有小组成员才能发言,加入小组>>
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
2783 浏览 1 评论
3252 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
1826 浏览 1 评论
3672 浏览 6 评论
6065 浏览 21 评论
1349浏览 4评论
对H747I-DISCO写程序时将CN2的st-link复用为usart1,再次烧录时无法检测到stlink怎么解决?
373浏览 2评论
STM32G474RE芯片只是串口发个数据就发烫严重是怎么回事?
470浏览 2评论
STM32处理增量式编码器Z信号如何判断中断是正转的还是反向转的?
294浏览 2评论
使用STM32F407VET6的USB2.0功能,发现ctl后芯片无数据返回,是什么原因可能导致的呢?
217浏览 2评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-1-13 12:27 , Processed in 1.331308 second(s), Total 76, Slave 70 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191 工商网监 湘ICP备2023018690号