From 0cb04a5fdb75aaa1edc6ae322e49c8636ca0bcb7 Mon Sep 17 00:00:00 2001 From: YiChin2018 Date: Sat, 10 Aug 2019 18:48:43 +0800 Subject: [PATCH] indicate need modified --- .../host_test/cc26xx/app/host_test_app.c | 3 ++ .../cc26xx/app/headstage/basic_structure.puml | 10 +++++++ .../cc26xx/app/headstage/headstage_indicate.h | 29 +++++++++++++++---- .../cc26xx/app/headstage/headstage_notify.h | 2 +- .../cc26xx/app/headstage/headstage_uni.h | 3 +- .../cc26xx/app/simple_peripheral.c | 2 ++ .../cc26xx/simple_gatt_profile.c | 2 +- .../simple_profile/simple_gatt_profile.h | 2 ++ 8 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/basic_structure.puml diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/host_test/cc26xx/app/host_test_app.c b/simplelink/ble_sdk_2_02_02_25/src/examples/host_test/cc26xx/app/host_test_app.c index 966207f8e..146a6aeda 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/host_test/cc26xx/app/host_test_app.c +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/host_test/cc26xx/app/host_test_app.c @@ -368,6 +368,9 @@ static void HostTestApp_processAttEvent(gattMsgEvent_t *message) { } else if (method == ATT_HANDLE_VALUE_NOTI) { attHandleValueNoti_t *att_notify = (attHandleValueNoti_t *)(&message->msg); master_handle_notify(att_notify->len, att_notify->pValue); + } else if (method == ATT_HANDLE_VALUE_IND) { + attHandleValueInd_t *att_indicate = (attHandleValueInd_t *)(&message->msg); + master_handle_notify(att_indicate->len, att_indicate->pValue); } // Free message. Needed only for ATT Protocol messages diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/basic_structure.puml b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/basic_structure.puml new file mode 100644 index 000000000..cc991d0fb --- /dev/null +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/basic_structure.puml @@ -0,0 +1,10 @@ +@startuml +(*) --> "check input" +If "input is verbose" then +--> [Yes] "turn on verbosity" +--> "run command" +else +--> "run command" +Endif +-->(*) +@enduml \ No newline at end of file diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_indicate.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_indicate.h index 9943e002d..c08dc6f6e 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_indicate.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_indicate.h @@ -11,6 +11,13 @@ root: glucose.c glucserive.c +code need modifying: + headstage_indicate.h + simple_gatt_profile.c : WriteAtterCB -> add case "indication" to support indicate + + sipmle_peripheral.c : find another service callback + + use this website to construct software structure : http://plantuml.com/zh/ */ @@ -29,12 +36,25 @@ static uint8_t headstage_indicate_buffer[BLE_NOT_BUFF_SIZE] = {0}; /* * send indicate + * connHandle -> where to assign this parameter */ -static bStatus_t headstage_indicate (uint16_t connHandle, attHandleValueInd_t *pInd, uint8_t taskId) { +static bStatus_t headstage_indicate(uint16_t connHandle, attHandleValueInd_t *pInd, uint8_t taskId) { uint16_t value = GATTServApp_ReadCharCfg(connHandle, simpleProfileChar4Config); + + if (value & GATT_CLIENT_CFG_INDICATE) + { + // char4 handle access + pInd->handle = simpleProfileAttrTbl[CHAR4_CFG_POS].handle; + + // send the indication. + return GATT_Indication(CONNECT_HANDLE, pInd, FALSE, taskId); + } + // check the meaning of this return value + return bleNotReady; } + static void headstage_indicate_send() { uint16_t buffer_size = BLE_NOT_BUFF_SIZE; attHandleValueInd_t ind_dataRsp; @@ -42,12 +62,11 @@ static void headstage_indicate_send() { if (ind_dataRsp.pValue != NULL) { - memcpy(ind_dataRsp.value, headstage_notify_buffer, buffer_size); - if(headstage_indicate(connHandle, &ind_dataRsp, self)) { + memcpy(ind_dataRsp.pValue, headstage_notify_buffer, buffer_size); + if(headstage_indicate(CONNECT_HANDLE, &ind_dataRsp, self) != SUCCESS) { GATT_bm_free((gattMsg_t *)&ind_dataRsp, ATT_HANDLE_VALUE_IND); } - } } -#endif \ No newline at end of file +#endif diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_notify.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_notify.h index 51af57ade..8a5954799 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_notify.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_notify.h @@ -66,7 +66,7 @@ static void headstage_notify_send() { } #else - SimpleProfile_SetParameter(BLE_NOT_BUFF_CHAR, BLE_NOT_BUFF_SIZE, headstage_notify_buffer); + SimpleProfile_SetParameter(BLE_NOT_BUFF_CHAR, BLE_NOT_BUFF_SIZE, headstage_notify_buffer) ; #endif } diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_uni.h b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_uni.h index cffff2ede..4fc4e7d67 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_uni.h +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/headstage/headstage_uni.h @@ -29,12 +29,11 @@ #include "population.h" #include "headstage_arm.h" -#include "headstage_notify.h" #include "headstage_debug.h" #include "headstage_pin.h" #include "headstage_led.h" -#include "headstage_arm.h" #include "headstage_watchdog.h" +#include "headstage_notify.h" #include "tni/headstage_notify.h" #include "uni/headstage_spi.h" #include "uni/headstage_pwm.h" diff --git a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c index 3f77f6255..1a7a4f400 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c +++ b/simplelink/ble_sdk_2_02_02_25/src/examples/simple_peripheral/cc26xx/app/simple_peripheral.c @@ -680,6 +680,8 @@ static uint8_t SimpleBLEPeripheral_processGATTMsg(gattMsgEvent_t *message) { headstage_debug_buffer[10] = 0xff; headstage_set_debug_information(); // headstage_data_length_extension(); + } else if (message->method == ATT_HANDLE_VALUE_CFM) { + headstage_led_spi_color(COLOR_WHITE); } // Free message payload. Needed only for ATT Protocol messages diff --git a/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx/simple_gatt_profile.c b/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx/simple_gatt_profile.c index 5a74566df..757d5e651 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx/simple_gatt_profile.c +++ b/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/cc26xx/simple_gatt_profile.c @@ -542,7 +542,7 @@ static bStatus_t simpleProfile_WriteAttrCB(uint16_t connHandle, // break; case GATT_CLIENT_CHAR_CFG_UUID: - status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY); + status = GATTServApp_ProcessCCCWriteReq(connHandle, pAttr, pValue, len, offset, GATT_CLIENT_CFG_NOTIFY | GATT_CLIENT_CFG_INDICATE); break; default: diff --git a/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/simple_gatt_profile.h b/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/simple_gatt_profile.h index 81c18eba0..a69fd50d8 100644 --- a/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/simple_gatt_profile.h +++ b/simplelink/ble_sdk_2_02_02_25/src/profiles/simple_profile/simple_gatt_profile.h @@ -67,6 +67,8 @@ extern "C" { #define SIMPLEPROFILE_CHAR4 3 // RW uint8 - Profile Characteristic 4 value #define SIMPLEPROFILE_CHAR5 4 // RW uint8 - Profile Characteristic 4 value + + // Simple Profile Service UUID #define SIMPLEPROFILE_SERV_UUID 0xFFF0