mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-03 23:47:08 +00:00
btstack_util: add btstack_next_cid_ignoring_zero
This commit is contained in:
parent
98f6d969a9
commit
a73d0b9d3c
@ -479,3 +479,13 @@ uint8_t btstack_crc8_calc(uint8_t *data, uint16_t len){
|
||||
/* Ones complement */
|
||||
return 0xFFu - crc8(data, len);
|
||||
}
|
||||
|
||||
uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid){
|
||||
uint16_t next_cid;
|
||||
if (current_cid == 0xffff) {
|
||||
next_cid = 1;
|
||||
} else {
|
||||
next_cid = current_cid + 1;
|
||||
}
|
||||
return next_cid;
|
||||
}
|
||||
|
@ -279,12 +279,29 @@ int string_len_for_uint32(uint32_t i);
|
||||
int count_set_bits_uint32(uint32_t x);
|
||||
|
||||
/**
|
||||
* CRC8 functions using ETSI TS 101 369 V6.3.0.
|
||||
* Only used by RFCOMM
|
||||
* @brief Check CRC8 using ETSI TS 101 369 V6.3.0.
|
||||
* @note Only used by RFCOMM
|
||||
* @param data
|
||||
* @param len
|
||||
* @param check_sum
|
||||
*/
|
||||
uint8_t btstack_crc8_check(uint8_t * data, uint16_t len, uint8_t check_sum);
|
||||
|
||||
/**
|
||||
* @brief Calculate CRC8 using ETSI TS 101 369 V6.3.0.
|
||||
* @note Only used by RFCOMM
|
||||
* @param data
|
||||
* @param len
|
||||
*/
|
||||
uint8_t btstack_crc8_calc(uint8_t * data, uint16_t len);
|
||||
|
||||
/**
|
||||
* @brief Get next cid
|
||||
* @param current_cid
|
||||
* @return next cid skiping 0
|
||||
*/
|
||||
uint16_t btstack_next_cid_ignoring_zero(uint16_t current_cid);
|
||||
|
||||
/* API_END */
|
||||
|
||||
#if defined __cplusplus
|
||||
|
@ -230,6 +230,12 @@ TEST_GROUP(BTstackUtil){
|
||||
}
|
||||
};
|
||||
|
||||
TEST(BTstackUtil, btstack_next_cid_ignoring_zero){
|
||||
CHECK_EQUAL(1, btstack_next_cid_ignoring_zero(0));
|
||||
CHECK_EQUAL(5, btstack_next_cid_ignoring_zero(4));
|
||||
CHECK_EQUAL(1, btstack_next_cid_ignoring_zero(0xFFFF));
|
||||
}
|
||||
|
||||
TEST(BTstackUtil, bd_addr_cmp){
|
||||
bd_addr_t a = {0};
|
||||
bd_addr_t b = {0};
|
||||
@ -241,7 +247,6 @@ TEST(BTstackUtil, bd_addr_cmp){
|
||||
|
||||
bd_addr_t a3 = {0xBC, 0xEC, 0x5D, 0xE6, 0x15, 0x03};
|
||||
bd_addr_t b3 = {0xCB, 0xEC, 0x5D, 0xE6, 0x15, 0x03};
|
||||
CHECK(0 != bd_addr_cmp(a3, b3));
|
||||
}
|
||||
|
||||
TEST(BTstackUtil, bd_addr_copy){
|
||||
|
Loading…
Reference in New Issue
Block a user