mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
pkg/nimble/scanlist: adapt to scanner changes
This commit is contained in:
parent
586ba70c5b
commit
4520fc67a5
@ -28,6 +28,7 @@
|
||||
#include "clist.h"
|
||||
#include "net/ble.h"
|
||||
#include "nimble/ble.h"
|
||||
#include "nimble_scanner.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -53,6 +54,8 @@ typedef struct {
|
||||
uint32_t first_update; /**< first packet timestamp */
|
||||
uint32_t last_update; /**< last packet timestamp */
|
||||
uint8_t type; /**< advertising packet type */
|
||||
uint8_t phy_pri; /**< primary PHY used */
|
||||
uint8_t phy_sec; /**< secondary PHY advertised */
|
||||
} nimble_scanlist_entry_t;
|
||||
|
||||
/**
|
||||
@ -67,11 +70,12 @@ void nimble_scanlist_init(void);
|
||||
*
|
||||
* @param[in] type type of the advertising packet received
|
||||
* @param[in] addr BLE address of the scanned node
|
||||
* @param[in] rssi RSSI of the received advertising packet
|
||||
* @param[in] info Additional information on received advertising event
|
||||
* @param[in] ad the payload of the advertising packet
|
||||
* @param[in] len length of @p ad
|
||||
*/
|
||||
void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr, int8_t rssi,
|
||||
void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr,
|
||||
const nimble_scanner_info_t *info,
|
||||
const uint8_t *ad, size_t len);
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,8 @@ nimble_scanlist_entry_t *nimble_scanlist_get_by_pos(unsigned pos)
|
||||
return e;
|
||||
}
|
||||
|
||||
void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr, int8_t rssi,
|
||||
void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr,
|
||||
const nimble_scanner_info_t *info,
|
||||
const uint8_t *ad, size_t len)
|
||||
{
|
||||
assert(addr);
|
||||
@ -86,10 +87,12 @@ void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr, int8_t rssi,
|
||||
memcpy(e->ad, ad, len);
|
||||
}
|
||||
e->ad_len = len;
|
||||
e->last_rssi = rssi;
|
||||
e->last_rssi = info->rssi;
|
||||
e->first_update = now;
|
||||
e->adv_msg_cnt = 1;
|
||||
e->type = type;
|
||||
e->phy_pri = info->phy_pri;
|
||||
e->phy_sec = info->phy_sec;
|
||||
clist_rpush(&_list, (clist_node_t *)e);
|
||||
}
|
||||
else {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2019 Freie Universität Berlin
|
||||
* Copyright (C) 2019-2021 Freie Universität Berlin
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU Lesser
|
||||
* General Public License v2.1. See the file LICENSE in the top level
|
||||
@ -27,8 +27,30 @@
|
||||
#include "nimble_scanlist.h"
|
||||
#include "nimble/hci_common.h"
|
||||
|
||||
static const char *_phys[] = { "N/A", "1M", "2M", "CODED" };
|
||||
|
||||
static void _print_type(uint8_t type)
|
||||
{
|
||||
#if MYNEWT_VAL_BLE_EXT_ADV
|
||||
if (type & NIMBLE_SCANNER_EXT_ADV) {
|
||||
printf(" [EXT");
|
||||
if (type & BLE_HCI_ADV_CONN_MASK) {
|
||||
printf("-CONN");
|
||||
}
|
||||
if (type & BLE_HCI_ADV_SCAN_MASK) {
|
||||
printf("-SCAN");
|
||||
}
|
||||
if (type & BLE_HCI_ADV_DIRECT_MASK) {
|
||||
printf("-DIR");
|
||||
}
|
||||
if (type & BLE_HCI_ADV_SCAN_RSP_MASK) {
|
||||
printf("-SCANRSP");
|
||||
}
|
||||
printf("]");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
switch (type) {
|
||||
case BLE_HCI_ADV_RPT_EVTYPE_ADV_IND:
|
||||
printf(" [IND]");
|
||||
@ -80,6 +102,7 @@ void nimble_scanlist_print_entry(nimble_scanlist_entry_t *e)
|
||||
|
||||
nimble_addr_print(&e->addr);
|
||||
_print_type(e->type);
|
||||
printf(" phy:%s-%s", _phys[e->phy_pri], _phys[e->phy_sec]);
|
||||
unsigned adv_int = ((e->last_update - e->first_update) / e->adv_msg_cnt);
|
||||
printf(" \"%s\", adv_msg_cnt: %u, adv_int: %uus, last_rssi: %i\n",
|
||||
name, (unsigned)e->adv_msg_cnt, adv_int, (int)e->last_rssi);
|
||||
|
Loading…
Reference in New Issue
Block a user