Add reliable Android BLE ride recorder
This commit is contained in:
@@ -66,5 +66,42 @@ int main(void)
|
||||
sizeof(packet), 0, 8) != 0) {
|
||||
return fail(4, "invalid input rejection");
|
||||
}
|
||||
|
||||
const uint8_t begin[TRIKKE_BLE_BEGIN_SESSION_SIZE] = {
|
||||
'B', 'G', 'N', '1', 0x08, 0x07, 0x06, 0x05,
|
||||
0x04, 0x03, 0x02, 0x01,
|
||||
};
|
||||
uint64_t session_token = 0;
|
||||
if (!trikke_ble_decode_begin_session(
|
||||
begin, sizeof(begin), &session_token) ||
|
||||
session_token != UINT64_C(0x0102030405060708)) {
|
||||
return fail(5, "begin-session decoding");
|
||||
}
|
||||
uint8_t invalid_begin[TRIKKE_BLE_BEGIN_SESSION_SIZE] = {0};
|
||||
memcpy(invalid_begin, begin, sizeof(begin));
|
||||
invalid_begin[3] = '2';
|
||||
if (trikke_ble_decode_begin_session(
|
||||
invalid_begin, sizeof(invalid_begin), &session_token) ||
|
||||
trikke_ble_decode_begin_session(
|
||||
begin, sizeof(begin) - 1, &session_token)) {
|
||||
return fail(6, "invalid begin-session rejection");
|
||||
}
|
||||
|
||||
bool subscribed = false;
|
||||
if (trikke_ble_update_subscription(true, false, &subscribed) ||
|
||||
subscribed ||
|
||||
!trikke_ble_update_subscription(true, true, &subscribed) ||
|
||||
!subscribed) {
|
||||
return fail(7, "CCCD-before-control subscription ordering");
|
||||
}
|
||||
subscribed = false;
|
||||
if (trikke_ble_update_subscription(false, true, &subscribed) ||
|
||||
subscribed ||
|
||||
!trikke_ble_update_subscription(true, true, &subscribed) ||
|
||||
!subscribed ||
|
||||
!trikke_ble_update_subscription(false, true, &subscribed) ||
|
||||
subscribed) {
|
||||
return fail(8, "control-before-CCCD subscription ordering");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user