1
0
forked from me/IronOS

Add validation ID to BLE

This commit is contained in:
Vladimir K
2023-04-15 14:58:57 -07:00
committed by Vladimir K
parent da18b9b60f
commit 2d824af836
3 changed files with 17 additions and 4 deletions

View File

@@ -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

View File

@@ -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;
@@ -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;
}

View File

@@ -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),