-
Notifications
You must be signed in to change notification settings - Fork 2
Add channel index handling to NimBLEAdvertisedDevice and related structures #2
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
base: master
Are you sure you want to change the base?
Changes from all commits
7c7068d
0a1e1be
9afabc8
9a828ac
0b6ddee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Build Arduino examples | ||
|
|
||
| on: | ||
| push: | ||
| paths: | ||
| - 'src/**' | ||
| - 'examples/**' | ||
| - 'library.properties' | ||
| - '.github/workflows/platformio-examples.yml' | ||
| pull_request: | ||
| paths: | ||
| - 'src/**' | ||
| - 'examples/**' | ||
| - 'library.properties' | ||
| - '.github/workflows/platformio-examples.yml' | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.11' | ||
|
|
||
| - name: Cache PlatformIO | ||
| uses: actions/cache@v4 | ||
| with: | ||
| path: ~/.platformio | ||
| key: platformio-${{ runner.os }}-${{ hashFiles('library.properties') }} | ||
| restore-keys: | | ||
| platformio-${{ runner.os }}- | ||
|
|
||
| - name: Install PlatformIO Core | ||
| run: pip install --upgrade platformio | ||
|
|
||
| - name: Build examples | ||
| shell: bash | ||
| run: | | ||
| set -euo pipefail | ||
| shopt -s nullglob | ||
| sketches=(examples/*/*.ino) | ||
|
|
||
| if [ ${#sketches[@]} -eq 0 ]; then | ||
| echo "No examples found" | ||
| exit 1 | ||
| fi | ||
|
|
||
| for sketch in "${sketches[@]}"; do | ||
| sketch_dir=$(dirname "$sketch") | ||
| sketch_name=$(basename "$sketch_dir") | ||
| echo "::group::Building ${sketch_name}" | ||
| pio ci \ | ||
| --board esp32dev \ | ||
| --lib="." \ | ||
| "$sketch" | ||
| echo "::endgroup::" | ||
| done |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -465,7 +465,7 @@ ble_hs_hci_evt_le_adv_rpt_first_pass(const void *data, unsigned int len) | |
| rpt = data; | ||
|
|
||
| len -= sizeof(*rpt) + 1; | ||
| data += sizeof(rpt) + 1; | ||
| data += sizeof(*rpt) + 1; | ||
|
|
||
| if (rpt->data_len > len) { | ||
| return BLE_HS_ECONTROLLER; | ||
|
|
@@ -501,18 +501,23 @@ ble_hs_hci_evt_le_adv_rpt(uint8_t subevent, const void *data, unsigned int len) | |
| data += sizeof(*ev); | ||
|
|
||
| desc.direct_addr = *BLE_ADDR_ANY; | ||
| desc.channel_index = 0xFF; | ||
|
|
||
| for (i = 0; i < ev->num_reports; i++) { | ||
| rpt = data; | ||
|
|
||
| data += sizeof(rpt) + rpt->data_len + 1; | ||
| data += sizeof(*rpt) + rpt->data_len + 1; | ||
|
|
||
| desc.event_type = rpt->type; | ||
| desc.addr.type = rpt->addr_type; | ||
| memcpy(desc.addr.val, rpt->addr, BLE_DEV_ADDR_LEN); | ||
| desc.length_data = rpt->data_len; | ||
| desc.data = rpt->data; | ||
| desc.rssi = rpt->data[rpt->data_len]; | ||
| /* Channel index follows RSSI if available */ | ||
| if ((const uint8_t*)data - (const uint8_t*)rpt > sizeof(*rpt) + rpt->data_len + 1) { | ||
| desc.channel_index = rpt->data[rpt->data_len + 1]; | ||
| } | ||
|
|
||
| ble_gap_rx_adv_report(&desc); | ||
| } | ||
|
|
@@ -535,6 +540,7 @@ ble_hs_hci_evt_le_dir_adv_rpt(uint8_t subevent, const void *data, unsigned int l | |
| /* Data fields not present in a direct advertising report. */ | ||
| desc.data = NULL; | ||
| desc.length_data = 0; | ||
| desc.channel_index = 0xFF; | ||
|
|
||
| for (i = 0; i < ev->num_reports; i++) { | ||
| desc.event_type = ev->reports[i].type; | ||
|
|
@@ -612,6 +618,7 @@ ble_hs_hci_evt_le_ext_adv_rpt(uint8_t subevent, const void *data, | |
| report = &ev->reports[0]; | ||
| for (i = 0; i < ev->num_reports; i++) { | ||
| memset(&desc, 0, sizeof(desc)); | ||
| desc.channel_index = 0xFF; | ||
|
|
||
| desc.props = (report->evt_type) & 0x1F; | ||
| if (desc.props & BLE_HCI_ADV_LEGACY_MASK) { | ||
|
|
@@ -649,6 +656,14 @@ ble_hs_hci_evt_le_ext_adv_rpt(uint8_t subevent, const void *data, | |
| desc.prim_phy = report->pri_phy; | ||
| desc.sec_phy = report->sec_phy; | ||
| desc.periodic_adv_itvl = report->periodic_itvl; | ||
| /* Channel index may follow the data if available */ | ||
| if (report->data_len < 255) { | ||
| const uint8_t *channel_ptr = &report->data[report->data_len]; | ||
| /* Verify we're not reading past the event data */ | ||
| if ((const uint8_t*)channel_ptr < (const uint8_t*)data + len) { | ||
| desc.channel_index = *channel_ptr; | ||
| } | ||
| } | ||
|
|
||
| ble_gap_rx_ext_adv_report(&desc); | ||
|
|
||
|
Comment on lines
668
to
669
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
After reading Useful? React with 👍 / 👎. |
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.