Skip to content

Commit

Permalink
Merge pull request #1666 from ew1abz/1609-ble-sn-id
Browse files Browse the repository at this point in the history
Add validation ID to BLE
  • Loading branch information
discip authored Apr 16, 2023
2 parents da18b9b + 2d824af commit 546ac3a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion source/Core/BSP/Pinecilv2/ble_characteristics.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
#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))
#define BT_UUID_CHAR_BLE_LIVE_DEV_SN BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1004, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))
#define BT_UUID_CHAR_BLE_LIVE_DEV_ID BT_UUID_DECLARE_128(BT_UUID_128_ENCODE(0x9eae1005, 0x9d0d, 0x48c5, 0xAA55, 0x33e27f9bc533))

// Settings

Expand Down
17 changes: 14 additions & 3 deletions source/Core/BSP/Pinecilv2/ble_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ int ble_char_read_status_callback(struct bt_conn *conn, const struct bt_gatt_att
MSG((char *)"Unhandled attr read %d | %d\n", (uint32_t)attr->uuid, uuid_value);
return 0;
}

int ble_char_read_bulk_value_callback(struct bt_conn *conn, const struct bt_gatt_attr *attr, void *buf, u16_t len, u16_t offset) {
if (attr == NULL || attr->uuid == NULL) {
return 0;
Expand Down Expand Up @@ -184,13 +185,23 @@ int ble_char_read_bulk_value_callback(struct bt_conn *conn, const struct bt_gatt
memcpy(buf, &BUILD_VERSION, sizeof(BUILD_VERSION) - 1);
return sizeof(BUILD_VERSION) - 1;
case 4:
// Device unique id
// Device serial number.
// Serial number is the ID burned by manufacturer.
// In case of Pinecil V2, device SN = device MAC.
{
uint64_t id = getDeviceID();
uint64_t sn = getDeviceID();
memcpy(buf, &sn, sizeof(sn));
return sizeof(sn);
}
break;
case 5:
// Device ID [https://github.com/Ralim/IronOS/issues/1609].
// ID is a unique key Pine burns at the factory and records in their db.
{
uint32_t id = getDeviceValidation();
memcpy(buf, &id, sizeof(id));
return sizeof(id);
}
break;
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions source/Core/BSP/Pinecilv2/ble_peripheral.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ static struct bt_gatt_attr ble_attrs_declaration[] = {
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_BULK_LIVE_DATA, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_bulk_value_callback, NULL, NULL),
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_ACCEL_NAME, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_bulk_value_callback, NULL, NULL),
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_BUILD, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_bulk_value_callback, NULL, NULL),
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_DEV_SN, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_bulk_value_callback, NULL, NULL),
BT_GATT_CHARACTERISTIC(BT_UUID_CHAR_BLE_LIVE_DEV_ID, BT_GATT_CHRC_READ, BT_GATT_PERM_READ, ble_char_read_bulk_value_callback, NULL, NULL),

BT_GATT_PRIMARY_SERVICE(BT_UUID_SVC_SETTINGS_DATA),
Expand Down

0 comments on commit 546ac3a

Please sign in to comment.