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 "clist.h"
|
||||||
#include "net/ble.h"
|
#include "net/ble.h"
|
||||||
#include "nimble/ble.h"
|
#include "nimble/ble.h"
|
||||||
|
#include "nimble_scanner.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@ -53,6 +54,8 @@ typedef struct {
|
|||||||
uint32_t first_update; /**< first packet timestamp */
|
uint32_t first_update; /**< first packet timestamp */
|
||||||
uint32_t last_update; /**< last packet timestamp */
|
uint32_t last_update; /**< last packet timestamp */
|
||||||
uint8_t type; /**< advertising packet type */
|
uint8_t type; /**< advertising packet type */
|
||||||
|
uint8_t phy_pri; /**< primary PHY used */
|
||||||
|
uint8_t phy_sec; /**< secondary PHY advertised */
|
||||||
} nimble_scanlist_entry_t;
|
} nimble_scanlist_entry_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -67,11 +70,12 @@ void nimble_scanlist_init(void);
|
|||||||
*
|
*
|
||||||
* @param[in] type type of the advertising packet received
|
* @param[in] type type of the advertising packet received
|
||||||
* @param[in] addr BLE address of the scanned node
|
* @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] ad the payload of the advertising packet
|
||||||
* @param[in] len length of @p ad
|
* @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);
|
const uint8_t *ad, size_t len);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +66,8 @@ nimble_scanlist_entry_t *nimble_scanlist_get_by_pos(unsigned pos)
|
|||||||
return e;
|
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)
|
const uint8_t *ad, size_t len)
|
||||||
{
|
{
|
||||||
assert(addr);
|
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);
|
memcpy(e->ad, ad, len);
|
||||||
}
|
}
|
||||||
e->ad_len = len;
|
e->ad_len = len;
|
||||||
e->last_rssi = rssi;
|
e->last_rssi = info->rssi;
|
||||||
e->first_update = now;
|
e->first_update = now;
|
||||||
e->adv_msg_cnt = 1;
|
e->adv_msg_cnt = 1;
|
||||||
e->type = type;
|
e->type = type;
|
||||||
|
e->phy_pri = info->phy_pri;
|
||||||
|
e->phy_sec = info->phy_sec;
|
||||||
clist_rpush(&_list, (clist_node_t *)e);
|
clist_rpush(&_list, (clist_node_t *)e);
|
||||||
}
|
}
|
||||||
else {
|
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
|
* 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
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
@ -27,8 +27,30 @@
|
|||||||
#include "nimble_scanlist.h"
|
#include "nimble_scanlist.h"
|
||||||
#include "nimble/hci_common.h"
|
#include "nimble/hci_common.h"
|
||||||
|
|
||||||
|
static const char *_phys[] = { "N/A", "1M", "2M", "CODED" };
|
||||||
|
|
||||||
static void _print_type(uint8_t type)
|
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) {
|
switch (type) {
|
||||||
case BLE_HCI_ADV_RPT_EVTYPE_ADV_IND:
|
case BLE_HCI_ADV_RPT_EVTYPE_ADV_IND:
|
||||||
printf(" [IND]");
|
printf(" [IND]");
|
||||||
@ -80,6 +102,7 @@ void nimble_scanlist_print_entry(nimble_scanlist_entry_t *e)
|
|||||||
|
|
||||||
nimble_addr_print(&e->addr);
|
nimble_addr_print(&e->addr);
|
||||||
_print_type(e->type);
|
_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);
|
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",
|
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);
|
name, (unsigned)e->adv_msg_cnt, adv_int, (int)e->last_rssi);
|
||||||
|
Loading…
Reference in New Issue
Block a user