新装的BLE-CC254x-1.4.0协议找,使用的SimpleBLEPeripheral工程,直接在simpleBLEPeripheral.c文件中添加函数如下:
static void sendData(void )
{
static uint16 counter=0;
uint8 burstData[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
burstData[0] = (counter & 0xFF00)>>8;
burstData[1] = (counter & 0xFF);
attHandleValueNoti_t nData;
nData.len = 20;
nData.handle = 20;
//skKeyPressed = *((uint8*)pValue);
osal_memcpy( &nData.value, &burstData, 20 );
// Send the Notification
if (GATT_Notification( 0, &nData, FALSE )==SUCCESS)
{
counter++;
}
if(counter >1000)
{
osal_stop_timerEx(simpleBLEPeripheral_TaskID,SBP_PERIODIC_EVT);
counter = 0;
}
}
周期循环调用该函数,但是主机无法收到数据