Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation ID to BLE #1666

Merged
merged 1 commit into from
Apr 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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