Skip to content

Commit

Permalink
Change to 128bit UUID's (#1608)
Browse files Browse the repository at this point in the history
* Change to 128bit UUID's

* Make attrs const for BLE

* Forcefully set docker project name

* Cleaner UUIDS

* Cant use const attrs

* Adjust ram sections

* Update UUID decode

* Settings uuids

* Fix missed decoder for writing

---------

Co-authored-by: discip <[email protected]>
  • Loading branch information
Ralim and discip authored Mar 29, 2023
1 parent f937c8d commit e13f118
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ OUTPUT_ARCH( "riscv" )
/* configure the entry point */
ENTRY(_enter)

StackSize = 0x1000; /* 4KB */
HeapSize = 0x1000; /* 4KB */
StackSize = 0x800; /* 2KB */
HeapSize = 0x800; /* 2KB */
__EM_SIZE = DEFINED(ble_controller_init) ? 8K : 0K;

MEMORY
{
xip_memory (rx) : ORIGIN = 0x23000000, LENGTH = 1022K
itcm_memory (rx) : ORIGIN = 0x22014000, LENGTH = 16K
dtcm_memory (rx) : ORIGIN = 0x42018000, LENGTH = 32K
ram_memory (!rx) : ORIGIN = 0x42020000, LENGTH = 32K
dtcm_memory (rx) : ORIGIN = 0x42017000, LENGTH = 4K
ram_memory (!rx) : ORIGIN = 0x42018000, LENGTH = 64K
rsvd_memory (!rx) : ORIGIN = 0x42028000, LENGTH = 1K
ram2_memory (!rx) : ORIGIN = 0x42028400, LENGTH = (31K - __EM_SIZE)
hbn_memory (rx) : ORIGIN = 0x40010000, LENGTH = 0xE00 /* hbn ram 4K used 3.5K*/
Expand Down
125 changes: 62 additions & 63 deletions source/Core/BSP/Pinecilv2/ble_characteristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,74 @@
*/

// d85efab4-168e-4a71-affd-33e27f9bc533
#define BT_UUID_SVC_LIVE_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85efab4, 0x168e, 0x4a71, 0xaffd, 0x33e27f9bc533))
#define BT_UUID_SVC_LIVE_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef000, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
// f6d75f91-5a10-4eba-a233-47d3f26a907f
#define BT_UUID_SVC_SETTINGS_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d75f91, 0x5a10, 0x4eba, 0xa233, 0x47d3f26a907f))
#define BT_UUID_SVC_SETTINGS_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d80000, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
// 9eae1adb-9d0d-48c5-a6e7-ae93f0ea37b0
#define BT_UUID_SVC_BULK_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1adb, 0x9d0d, 0x48c5, 0xa6e7, 0xae93f0ea37b0))
#define BT_UUID_SVC_BULK_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1000, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))

#define BT_UUID_CHAR_BLE_LIVE_LIVE_TEMP BT_UUID_DECLARE_16(0x0001)
#define BT_UUID_CHAR_BLE_LIVE_SETPOINT_TEMP BT_UUID_DECLARE_16(0x0002)
#define BT_UUID_CHAR_BLE_LIVE_DC_INPUT BT_UUID_DECLARE_16(0x0003)
#define BT_UUID_CHAR_BLE_LIVE_HANDLE_TEMP BT_UUID_DECLARE_16(0x0004)
#define BT_UUID_CHAR_BLE_LIVE_POWER_LEVEL BT_UUID_DECLARE_16(0x0005)
#define BT_UUID_CHAR_BLE_LIVE_POWER_SRC BT_UUID_DECLARE_16(0x0006)
#define BT_UUID_CHAR_BLE_LIVE_TIP_RES BT_UUID_DECLARE_16(0x0007)
#define BT_UUID_CHAR_BLE_LIVE_UPTIME BT_UUID_DECLARE_16(0x0008)
#define BT_UUID_CHAR_BLE_LIVE_MOVEMENT BT_UUID_DECLARE_16(0x0009)
#define BT_UUID_CHAR_BLE_LIVE_MAX_TEMP BT_UUID_DECLARE_16(0x000A)
#define BT_UUID_CHAR_BLE_LIVE_RAW_TIP BT_UUID_DECLARE_16(0x000B)
#define BT_UUID_CHAR_BLE_LIVE_HALL_SENSOR BT_UUID_DECLARE_16(0x000C)
#define BT_UUID_CHAR_BLE_LIVE_OP_MODE BT_UUID_DECLARE_16(0x000D)
#define BT_UUID_CHAR_BLE_LIVE_EST_WATTS BT_UUID_DECLARE_16(0x000E)
#define BT_UUID_CHAR_BLE_LIVE_LIVE_TEMP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef001, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_SETPOINT_TEMP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef002, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_DC_INPUT BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef003, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_HANDLE_TEMP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef004, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_POWER_LEVEL BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef005, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_POWER_SRC BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef006, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_TIP_RES BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef007, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_UPTIME BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef008, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_MOVEMENT BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef009, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_MAX_TEMP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef00A, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_RAW_TIP BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef00B, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_HALL_SENSOR BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef00C, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_OP_MODE BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef00D, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_EST_WATTS BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xd85ef00E, 0x168e, 0x4a71, 0xAA55, 0x33e27f9bc533))

// Bulk data that returns non-fixed sized objects
#define BT_UUID_CHAR_BLE_LIVE_BULK_LIVE_DATA BT_UUID_DECLARE_16(0x0001)
#define BT_UUID_CHAR_BLE_LIVE_ACCEL_NAME BT_UUID_DECLARE_16(0x0002)
#define BT_UUID_CHAR_BLE_LIVE_BUILD BT_UUID_DECLARE_16(0x0003)
#define BT_UUID_CHAR_BLE_LIVE_DEV_ID BT_UUID_DECLARE_16(0x0004)
#define BT_UUID_CHAR_BLE_LIVE_BULK_LIVE_DATA BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1001, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_ACCEL_NAME BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1002, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_BUILD BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1003, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_DEV_ID BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1004, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))

// Settings

#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_SAVE BT_UUID_DECLARE_16(0xFFFF)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_RESET BT_UUID_DECLARE_16(0xFFFE)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_0 BT_UUID_DECLARE_16(0)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_1 BT_UUID_DECLARE_16(1)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_2 BT_UUID_DECLARE_16(2)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_3 BT_UUID_DECLARE_16(3)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_4 BT_UUID_DECLARE_16(4)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_5 BT_UUID_DECLARE_16(5)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_6 BT_UUID_DECLARE_16(6)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_7 BT_UUID_DECLARE_16(7)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_8 BT_UUID_DECLARE_16(8)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_9 BT_UUID_DECLARE_16(9)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_10 BT_UUID_DECLARE_16(10)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_11 BT_UUID_DECLARE_16(11)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_12 BT_UUID_DECLARE_16(12)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_13 BT_UUID_DECLARE_16(13)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_14 BT_UUID_DECLARE_16(14)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_15 BT_UUID_DECLARE_16(15)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_16 BT_UUID_DECLARE_16(16)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_17 BT_UUID_DECLARE_16(17)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_18 BT_UUID_DECLARE_16(18)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_19 BT_UUID_DECLARE_16(19)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_20 BT_UUID_DECLARE_16(20)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_21 BT_UUID_DECLARE_16(21)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_22 BT_UUID_DECLARE_16(22)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_23 BT_UUID_DECLARE_16(23)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_24 BT_UUID_DECLARE_16(24)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_25 BT_UUID_DECLARE_16(25)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_26 BT_UUID_DECLARE_16(26)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_27 BT_UUID_DECLARE_16(27)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_28 BT_UUID_DECLARE_16(28)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_29 BT_UUID_DECLARE_16(29)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_30 BT_UUID_DECLARE_16(30)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_31 BT_UUID_DECLARE_16(31)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_32 BT_UUID_DECLARE_16(32)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_33 BT_UUID_DECLARE_16(33)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_34 BT_UUID_DECLARE_16(34)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_35 BT_UUID_DECLARE_16(35)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_36 BT_UUID_DECLARE_16(36)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_37 BT_UUID_DECLARE_16(37)
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_38 BT_UUID_DECLARE_16(38)

#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_SAVE BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7FFFF, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_RESET BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7FFFE, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_0 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70000, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_1 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70001, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_2 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70002, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_3 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70003, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_4 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70004, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_5 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70005, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_6 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70006, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_7 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70007, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_8 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70008, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_9 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70009, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_10 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000a, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_11 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000b, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_12 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000c, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_13 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000d, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_14 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000e, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_15 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7000f, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_16 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70010, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_17 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70011, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_18 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70012, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_19 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70013, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_20 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70014, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_21 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70015, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_22 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70016, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_23 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70017, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_24 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70018, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_25 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70019, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_26 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001a, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_27 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001b, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_28 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001c, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_29 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001d, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_30 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001e, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_31 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d7001f, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_32 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70020, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_33 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70021, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_34 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70022, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_35 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70023, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_36 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70024, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_37 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70025, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_SETTINGS_VALUE_38 BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0xf6d70026, 0x5a10, 0x4eba, 0xAA55, 0x33e27f9bc533))
#endif
24 changes: 14 additions & 10 deletions source/Core/BSP/Pinecilv2/ble_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@
#include "log.h"
#include "uuid.h"

#include "OperatingModes.h"
#include "../../version.h"
#include "OLED.hpp"
#include "OperatingModes.h"
#include "USBPD.h"
#include "ble_characteristics.h"
#include "ble_handlers.h"
#include "pd.h"
#include "power.hpp"
#include "../../version.h"
#if POW_PD
#include "USBPD.h"
#include "pd.h"
Expand All @@ -40,7 +40,9 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
if (attr == NULL || attr->uuid == NULL) {
return 0;
}
uint16_t uuid_value = ((struct bt_uuid_16 *)attr->uuid)->val;
// Decode the uuid
// Byte 12 has the lowest part of the first UUID chunk
uint16_t uuid_value = ((struct bt_uuid_128 *)attr->uuid)->val[12];
uint32_t temp = 0;
switch (uuid_value) {
case 1: // Live temp
Expand Down Expand Up @@ -138,7 +140,8 @@ int ble_char_read_bulk_value_callback(struct bt_conn *conn, const struct bt_gatt
if (attr == NULL || attr->uuid == NULL) {
return 0;
}
uint16_t uuid_value = ((struct bt_uuid_16 *)attr->uuid)->val;
// Byte 12 has the lowest part of the first UUID chunk
uint16_t uuid_value = ((struct bt_uuid_128 *)attr->uuid)->val[12];
// Bulk is the non-const size service
switch (uuid_value) {
case 1:
Expand Down Expand Up @@ -195,7 +198,8 @@ int ble_char_read_setting_value_callback(struct bt_conn *conn, const struct bt_g
if (attr == NULL || attr->uuid == NULL) {
return 0;
}
uint16_t uuid_value = ((struct bt_uuid_16 *)attr->uuid)->val;
// Byte 12 has the lowest part of the first UUID chunk
uint16_t uuid_value = ((struct bt_uuid_128 *)attr->uuid)->val[12];
uint16_t temp = 0xFFFF;
if (uuid_value <= SettingsOptions::SettingsOptionsLength) {
temp = getSettingValue((SettingsOptions)(uuid_value));
Expand Down Expand Up @@ -228,16 +232,16 @@ int ble_char_write_setting_value_callback(struct bt_conn *conn, const struct bt_
// Use write request / execute write data.
BT_WARN((char *)"recv write request / exce write\n");
}
uint16_t uuid_value = ((struct bt_uuid_16 *)attr->uuid)->val;
uint8_t uuid_value = ((struct bt_uuid_128 *)attr->uuid)->val[12];
if (len == 2) {
uint16_t new_value = 0;
memcpy(&new_value, buf, sizeof(new_value));
if (uuid_value == 0xFFFF) {
if (uuid_value == 0xFF) {
if (new_value == 1) {
saveSettings();
return len;
}
} else if (uuid_value == 0xFFFE) {
} else if (uuid_value == 0xFE) {
if (new_value == 1) {
resetSettings();
return len;
Expand All @@ -248,10 +252,10 @@ int ble_char_write_setting_value_callback(struct bt_conn *conn, const struct bt_
if (uuid_value == SettingsOptions::OLEDInversion) {
OLED::setInverseDisplay(getSettingValue(SettingsOptions::OLEDInversion));
}
if (uuid_value == SettingsOptions::OLEDBrightness){
if (uuid_value == SettingsOptions::OLEDBrightness) {
OLED::setBrightness(getSettingValue(SettingsOptions::OLEDBrightness));
}
if (uuid_value == SettingsOptions::OrientationMode){
if (uuid_value == SettingsOptions::OrientationMode) {
OLED::setRotation(getSettingValue(SettingsOptions::OrientationMode) & 1);
}
return len;
Expand Down
6 changes: 3 additions & 3 deletions source/Core/BSP/Pinecilv2/ble_peripheral.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static void ble_tp_ind_ccc_changed(const struct bt_gatt_attr *attr, u16_t value)
/*************************************************************************
* DEFINE : attrs
*/
static struct bt_gatt_attr attrs[] = {
static struct bt_gatt_attr ble_attrs_declaration[] = {
BT_GATT_PRIMARY_SERVICE(BT_UUID_SVC_LIVE_DATA),

BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_LIVE_TEMP, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_status_callback, NULL, NULL),
Expand Down Expand Up @@ -257,9 +257,9 @@ static struct bt_gatt_attr attrs[] = {
NAME
get_attr
*/
struct bt_gatt_attr *get_attr(u8_t index) { return &attrs[index]; }
struct bt_gatt_attr *get_attr(u8_t index) { return &ble_attrs_declaration[index]; }

static struct bt_gatt_service ble_tp_server = BT_GATT_SERVICE(attrs);
static struct bt_gatt_service ble_tp_server = BT_GATT_SERVICE(ble_attrs_declaration);

// Start advertising with expected default values
int ble_start_adv(void) {
Expand Down

0 comments on commit e13f118

Please sign in to comment.