summaryrefslogtreecommitdiff
path: root/src/Components/Ble/NimbleController.h
diff options
context:
space:
mode:
authorJF <jf@codingfield.com>2020-04-22 18:19:36 (GMT)
committerJF <jf@codingfield.com>2020-04-22 18:19:36 (GMT)
commita9254ee90e835b6a187d1fcd6f8850decca5bc89 (patch)
treeab6e63c48c0b9efe1dd8f2e8d5ba1137211df207 /src/Components/Ble/NimbleController.h
parent2c9ce1cfc7d4c733b1b35f51a1f6f5da332cf3fa (diff)
NimbleController : support CTS
Diffstat (limited to 'src/Components/Ble/NimbleController.h')
-rw-r--r--src/Components/Ble/NimbleController.h29
1 files changed, 28 insertions, 1 deletions
diff --git a/src/Components/Ble/NimbleController.h b/src/Components/Ble/NimbleController.h
index 1901b14..f44f26d 100644
--- a/src/Components/Ble/NimbleController.h
+++ b/src/Components/Ble/NimbleController.h
@@ -5,15 +5,42 @@
namespace Pinetime {
namespace Controllers {
-
+ class DateTime;
class NimbleController {
public:
+ NimbleController(DateTime& dateTimeController);
void Init();
void StartAdvertising();
int OnGAPEvent(ble_gap_event *event);
+ int OnDiscoveryEvent(uint16_t connectionHandle, const ble_gatt_error *error, const ble_gatt_svc *service);
+ int
+ OnCharacteristicDiscoveryEvent(uint16_t conn_handle, const ble_gatt_error *error,
+ const ble_gatt_chr *characteristic);
+ int OnCurrentTimeReadResult(uint16_t conn_handle, const ble_gatt_error *error, const ble_gatt_attr *attribute);
private:
static constexpr char* deviceName = "Pinetime-JF";
+ static constexpr uint16_t BleGatServiceCts = 0x1805;
+
+ typedef struct __attribute__((packed)) {
+ uint16_t year;
+ uint8_t month;
+ uint8_t dayofmonth;
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t millis;
+ uint8_t reason;
+ } CtsData;
+
+ DateTime& dateTimeController;
+
+ ble_uuid16_t ctsUuid;
+
+ static constexpr uint16_t bleGattCharacteristicCurrentTime = 0x2a2b;
+ ble_uuid16_t ctsCurrentTimeUuid;
+
uint8_t addrType;
+ uint16_t connectionHandle;
};
}
}