完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
主机通过GATT_WriteCharValue写,只能写一个字节。在从机程序里面怎么设置特征值可以写多个字节???
|
|
相关推荐
5 个讨论
|
|
|
uint8 buffer[VSERIAL_BLOCK_SIZE];
attWriteReq_t req = [NULL]; req.handle = charHandle; req.len = VSERIAL_BLOCK_SIZE; req.cmd = 1; if(enableAES == TRUE) [ AES_Init(curDevice->aesKey); AES_Encrypt(buffer, pValue); osal_memcpy(&req.value, buffer, AES_BLOCK_SIZE); ] else [ osal_memcpy(&req.value, pValue, AES_BLOCK_SIZE); ] return ( GATT_WriteNoRsp( conHandle, &req ) ); 其中charHandle是特征值的handle,conHandle是连接的handle,aes加密是可选,我自己实现的。 |
|
|
|
|
|
|
|
|
这个问题解决了,原来是要修改simpleGATTprofile.c中的simpleProfile_WriteAttrCB函数,这里面规定了特征值字节数为1 if ( len != 1 ) [ status = ATT_ERR_INVALID_VALUE_SIZE; ] 但是又出现了新的问题,写5个字节内的数据都没问题,但写6个字节以上的数据就直接Discconected,原因是0x08 #define LL_STATUS_ERROR_CONNECTION_TIMEOUT 0x08 // Connection Timeou 这是为什么?什么地方规定了只能5字节,不是最大为20字节吗? #define ATT_MTU_SIZE L2CAP_MTU_SIZE #define L2CAP_MTU_SIZE 23 typedef struct [ uint16 handle; //!< Handle of the attribute to be written (must be first field) uint8 len; //!< Length of value uint8 value[ATT_MTU_SIZE-3]; //!< Value of the attribute to be written uint8 sig; //!< Authentication Signature status (not included (0), valid (1), invalid (2)) uint8 cmd; //!< Command Flag ] attWriteReq_t; typedef struct [ uint8 len; //!< Length of value uint8 value[ATT_MTU_SIZE-1]; //!< Value of the attribute with the handle given ] attReadRsp_t; typedef struct [ uint16 handle; //!< Handle of the attribute to be written (must be first field) uint16 offset; //!< Offset of the first octet to be written uint8 len; //!< Length of value uint8 value[ATT_MTU_SIZE-5]; //!< Part of the value of the attribute to be written ] attPrepareWriteReq_t; 第二个问题,这三个飘红的地方为什么规定的长度不一样? 恳请TI的工程师和高手来帮帮我!!!!谢谢 |
|
|
|
|
|
|
|
只有小组成员才能发言,加入小组>>
549 浏览 0 评论
1613 浏览 0 评论
2047 浏览 0 评论
为啥BQ7693003DBTR芯片在和BQ769X0盒子通讯时收不到信号?
1513 浏览 0 评论
DSP 28027F 开发板 XDS100v2调试探针诊断日志显示了 Error -150 (SC_ERR_FTDI_FAIL)如何解决
1337 浏览 0 评论
AT32F407在USART2 DMA发送数据时,接包接到了要发送的数据,程序还是处于等待传输完成的标识判断中,为什么?
1756浏览 29评论
2781浏览 23评论
请问下tpa3220实际测试引脚功能和官方资料不符,哪位大佬可以帮忙解答下
1723浏览 20评论
请教下关于TAS5825PEVM评估模块原理图中不太明白的地方,寻求答疑
1634浏览 14评论
两个TMP117传感器一个可以正常读取温度值,一个读取的值一直是0,为什么?
1645浏览 13评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-1 19:56 , Processed in 1.052904 second(s), Total 56, Slave 45 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
1299