找到了这个例子是点灯。
- static void BleService_UDF01SLink0Handler(uint8_t hostId, uint8_t cmdAccess, uint8_t *data, uint16_t length)
- {
- switch (cmdAccess)
- {
- case BLESERVICE_UDF01S_UDATRW01_WRITE_EVENT:
- {
- if (data[0] == '1') //user write '1'
- {
- PF15 = 0; //turn on LED.
- }
- else
- {
- PF15 = 1; //turn off LED
- }
- }
- break;
- case BLESERVICE_UDF01S_UDATRW01_READ_EVENT:
- {
- //send read rsp with const read data to client
- uint8_t readData[] = "UDATRW01 data";
- setBLEGATT_GeneralReadRsp(hostId, bleProfile_link0_info.serviceUDF01S_info_s.handles.hdl_udatrw01, (uint8_t *)readData, (SIZE_STRING(readData)));
- }
- break;
- default:
- break;
- }
- }
如果收到的数据是1就点亮,其他字符就熄灭。
|