nimble_scanlist.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
25 #ifndef NIMBLE_SCANLIST_H
26 #define NIMBLE_SCANLIST_H
27 
28 #include "clist.h"
29 #include "net/ble.h"
30 #include "nimble/ble.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 #ifndef NIMBLE_SCANLIST_SIZE
40 #define NIMBLE_SCANLIST_SIZE (20U)
41 #endif
42 
46 typedef struct {
48  ble_addr_t addr;
49  uint8_t ad[BLE_ADV_PDU_LEN];
50  uint8_t ad_len;
51  int8_t last_rssi;
52  uint32_t adv_msg_cnt;
53  uint32_t first_update;
54  uint32_t last_update;
55  uint8_t type;
57 
61 void nimble_scanlist_init(void);
62 
74 void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr, int8_t rssi,
75  const uint8_t *ad, size_t len);
76 
86 
97 
101 void nimble_scanlist_clear(void);
102 
106 void nimble_scanlist_print(void);
107 
114 
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* NIMBLE_SCANLIST_H */
121 
nimble_scanlist_update
void nimble_scanlist_update(uint8_t type, const ble_addr_t *addr, int8_t rssi, const uint8_t *ad, size_t len)
Add/update the entry for the a scanned node.
nimble_scanlist_entry_t::type
uint8_t type
advertising packet type
Definition: nimble_scanlist.h:55
nimble_scanlist_entry_t
Data structure for holding a single scanlist entry.
Definition: nimble_scanlist.h:46
BLE_ADV_PDU_LEN
#define BLE_ADV_PDU_LEN
max size of legacy ADV packets
Definition: ble.h:49
nimble_scanlist_entry_t::last_rssi
int8_t last_rssi
last RSSI of a scanned node
Definition: nimble_scanlist.h:51
nimble_scanlist_entry_t::node
clist_node_t node
list node
Definition: nimble_scanlist.h:47
nimble_scanlist_clear
void nimble_scanlist_clear(void)
Clear all entries in the list.
nimble_scanlist_get_by_pos
nimble_scanlist_entry_t * nimble_scanlist_get_by_pos(unsigned pos)
Get an entry of the scanlist by its position.
nimble_scanlist_entry_t::last_update
uint32_t last_update
last packet timestamp
Definition: nimble_scanlist.h:54
nimble_scanlist_print
void nimble_scanlist_print(void)
Dump the entire scanlist to STDIO using nimble_scanlist_print_entry()
ble.h
General BLE values as defined by the BT standard.
nimble_scanlist_entry_t::adv_msg_cnt
uint32_t adv_msg_cnt
number of adv packets by a node
Definition: nimble_scanlist.h:52
nimble_scanlist_entry_t::addr
ble_addr_t addr
a node's BLE address
Definition: nimble_scanlist.h:48
nimble_scanlist_init
void nimble_scanlist_init(void)
Initialize the scanlist.
nimble_scanlist_print_entry
void nimble_scanlist_print_entry(nimble_scanlist_entry_t *e)
Dump a single scanlist entry to STDIO.
clist.h
Circular linked list.
nimble_scanlist_entry_t::first_update
uint32_t first_update
first packet timestamp
Definition: nimble_scanlist.h:53
nimble_scanlist_get_next
nimble_scanlist_entry_t * nimble_scanlist_get_next(nimble_scanlist_entry_t *e)
Get the next entry from the list, pass NULL for getting the first entry.
nimble_scanlist_entry_t::ad_len
uint8_t ad_len
length of the advertising data
Definition: nimble_scanlist.h:50
list_node
List node structure.
Definition: list.h:40