TI中文支持网
TI专业的中文技术问题搜集分享网站

GATT_WriteCharValue无返回值问题

我想通过主机UART给从机发消息,然后从机通过Uart 打印出来。我是通过FFF1 这个UUID去传输的。

如下是自己写的 发送函数

void Send_uartValue(uint8* value,uint8 len)
{
attWriteReq_t req;
uint8 status;
HwUARTPrintf("%s\n","aa");
req.pValue = GATT_bm_alloc(connHandle, ATT_WRITE_REQ, 1, NULL);
if ( req.pValue != NULL )
{
req.handle = charHdl+2;
HwUARTPrintf("%d\n", charHdl);
req.len = 1;
req.pValue[0] = 0x01;
req.sig = 0;
req.cmd = 0;
HwUARTPrintf("%s %d\n","bbb",connHandle);
status = GATT_WriteCharValue(connHandle, &req, selfEntity);
if ( status != SUCCESS )
{HwUARTPrintf("%s %d\n","error",status);
GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);
}
HwUARTPrintf("%s %d\n","ok",connHandle);
}
HwUARTPrintf("%s\n","ccc");
}

GATT_WriteCharValue 不起 作用,什么返回值都没有,走不到if判断那里。

请问这是什么原因呢?

Alvin Chen:

 status_t status;uint8_t charVals[4] = { 0x00, 0x55, 0xAA, 0xFF }; // Should be consistent with// those in scMenuGattWriteattWriteReq_t req;req.pValue = GATT_bm_alloc(scConnHandle, ATT_WRITE_REQ, 1, NULL);if ( req.pValue != NULL ){uint8_t connIndex = SimpleCentral_getConnIndex(scConnHandle);// connIndex cannot be equal to or greater than MAX_NUM_BLE_CONNSSIMPLECENTRAL_ASSERT(connIndex < MAX_NUM_BLE_CONNS);req.handle = connList[connIndex].charHandle;req.len = 1;charVal = charVals[index];req.pValue[0] = charVal;req.sig = 0;req.cmd = 0;status = GATT_WriteCharValue(scConnHandle, &req, selfEntity);if ( status != SUCCESS ){GATT_bm_free((gattMsg_t *)&req, ATT_WRITE_REQ);}}

参考一下这个,你检查一下req.handle对不对 

Viki Shi:

参考下这边的文档: www.jianshu.com/…/9cbda376b0e1

赞(0)
未经允许不得转载:TI中文支持网 » GATT_WriteCharValue无返回值问题
分享到: 更多 (0)