Skip to content

Commit

Permalink
Fix adv data types
Browse files Browse the repository at this point in the history
Updated test to check that adv data is sent correctly
  • Loading branch information
vChavezB committed Apr 13, 2024
1 parent 5f3296d commit 9025c43
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/ble_utils/uuid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static constexpr bt_uuid_128 uuid128_init(uint32_t w32,uint16_t w1,uint16_t w2,u
const uint8_t b15 = static_cast<uint8_t>(w32 >> 24 & 0xFF);
bt_uuid_128 uuid
{
.uuid = BT_UUID_TYPE_128,
.uuid = {.type = BT_UUID_TYPE_128},
.val = {b0,b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15}
};
return uuid;
Expand Down
6 changes: 5 additions & 1 deletion samples/uptime/src/ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,17 +89,21 @@ bool register_svc_to_scan_rsp(const bt_uuid *uuid)
{
uint8_t data_len;
const uint8_t * p_data;
uint8_t adv_type;
switch(uuid->type){
case BT_UUID_TYPE_16:
data_len = 2;
adv_type = BT_DATA_UUID16_SOME;
p_data = (const uint8_t *)&((bt_uuid_16 *)uuid)->val;
break;
case BT_UUID_TYPE_32:
data_len = 4;
adv_type = BT_DATA_UUID32_SOME;
p_data = (const uint8_t *)&((bt_uuid_32 *)uuid)->val;
break;
case BT_UUID_TYPE_128:
data_len = 16;
adv_type = BT_DATA_UUID128_SOME;
p_data = (const uint8_t *)&((bt_uuid_128 *)uuid)->val[0];
break;
default:
Expand All @@ -108,7 +112,7 @@ bool register_svc_to_scan_rsp(const bt_uuid *uuid)

if (sd_cnt < MAX_SD_SIZE) {
bt_data data = {.
type = uuid->type,
type = adv_type,
.data_len = data_len,
.data = p_data
};
Expand Down
4 changes: 2 additions & 2 deletions tests/renode/ble_central/src/discovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ static void device_found_cb(const bt_addr_le_t *addr, int8_t rssi, uint8_t type,
//LOG_INF("[DEVICE]: %s, AD evt type %u, AD data len %u, RSSI %i",
// dev, type, ad->len, rssi);

/* We're only interested in connectable events */
if (type == BT_GAP_ADV_TYPE_ADV_IND ||
type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND) {
type == BT_GAP_ADV_TYPE_ADV_DIRECT_IND ||
type == BT_GAP_ADV_TYPE_SCAN_RSP) {
bt_data_parse(ad, adv_data_cb, (void *)addr);
}
}
Expand Down
7 changes: 5 additions & 2 deletions tests/renode/uptime_test.robot
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*** Copyright (c) 2024, Victor Chavez ***
*** SPDX-License-Identifier: Apache-2.0 ***
*** Comments ***
Copyright (c) 2024, Victor Chavez
SPDX-License-Identifier: Apache-2.0
*** Variables ***
${UART} sysbus.uart0
Expand Down Expand Up @@ -51,6 +53,7 @@ Uptime Demo
Wait For Line On Uart Booting Zephyr testerId=${per_uart}
Wait For Line On Uart Scanning successfully started testerId=${cen_uart}
Wait For Line On Uart Bluetooth initialized testerId=${per_uart}
Wait For Line On Uart Matched Uptime adv. UUID testerId=${cen_uart}
Wait For Line On Uart Connected testerId=${per_uart}
Wait For Line On Uart Connected testerId=${cen_uart}
Wait For Line On Uart Service found testerId=${cen_uart}
Expand Down

0 comments on commit 9025c43

Please sign in to comment.