蓝牙一主两从连接好以后,其中一个从节点断开,主节点发送0x0c告知另外一个从节点,代码如下
case GAP_LINK_TERMINATED_EVENT:{simpleBLEState = BLE_STATE_IDLE;uint8 connectionhandle[2] = {pEvent->linkTerminate.connectionHandle >> 8, pEvent->linkTerminate.connectionHandle};simpleBLEConnHandle[connectionhandle[1]] = GAP_CONNHANDLE_INIT;simpleBLERssi = FALSE;simpleBLEDiscState = BLE_DISC_STATE_IDLE;simpleBLECharHdl = 0;simpleBLEProcedureInProgress = FALSE;LCD_WRITE_STRING( "Disconnected", HAL_LCD_LINE_1 );LCD_WRITE_STRING_VALUE( "Reason:", pEvent->linkTerminate.reason,10, HAL_LCD_LINE_2 );attWriteReq_t req;req.handle = 0x0035;req.len = 1;//req.offset = 0;req.sig = 0;req.cmd = 0;//osal_memcpy(req.value,ValueBuf,SIMPLEPROFILE_CHAR6_LEN);req.value[0] = 0x0C;//HalUARTWrite(0,&req.value[0],1);GATT_WriteCharValue( ShangweiConnectHandle, &req, simpleBLETaskId );//uint8 success = GATT_WriteCharValue( ShangweiConnectHandle, &req, simpleBLETaskId );//HalUARTWrite(0,&success,8);}break;
想在这个事件里面通知另外一个从节点,但是貌似发不出去,应该怎么通知呢?
Yan:
chi zhang5,
很有意思的想法。
你的 ShangweiConnectHandle 有没有设置正确?
chi zhang5:
回复 Yan:
连接好以后我就把两个节点的connectedhandle存起来了,发数据都是没问题的。如果一个从节点断掉后,另一个从节点的handle会变吗?
chi zhang5:
回复 Yan:
我刚才测了一下,handle是正确的,也不会变,但是发不出去。。。疑惑ing