List for storing and printing BLE scan results. More...

Detailed Description

List for storing and printing BLE scan results.

Note
This scanlist implementation is not thread safe. So calling nimble_scanlist_update() in between nimble_scanlist_get*() calls is not a good idea.

Files

file  nimble_scanlist.h
 List for keeping scanned BLE devices.
 

Data Structures

struct  nimble_scanlist_entry_t
 Data structure for holding a single scanlist entry. More...
 

Macros

#define NIMBLE_SCANLIST_SIZE   (20U)
 Default number of list entries that are allocated in RAM.
 

Functions

void nimble_scanlist_init (void)
 Initialize the scanlist.
 
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. More...
 
nimble_scanlist_entry_tnimble_scanlist_get_by_pos (unsigned pos)
 Get an entry of the scanlist by its position. More...
 
nimble_scanlist_entry_tnimble_scanlist_get_next (nimble_scanlist_entry_t *e)
 Get the next entry from the list, pass NULL for getting the first entry. More...
 
void nimble_scanlist_clear (void)
 Clear all entries in the list.
 
void nimble_scanlist_print (void)
 Dump the entire scanlist to STDIO using nimble_scanlist_print_entry()
 
void nimble_scanlist_print_entry (nimble_scanlist_entry_t *e)
 Dump a single scanlist entry to STDIO. More...
 

Function Documentation

◆ 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.

Parameters
[in]posposition in the list
Returns
the scanlist entry at position pos
NULL if there is no entry a the given position

◆ 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.

Parameters
[in]eany entry in the list
Returns
the entry following e
NULL if e was the last entry

◆ nimble_scanlist_print_entry()

void nimble_scanlist_print_entry ( nimble_scanlist_entry_t e)

Dump a single scanlist entry to STDIO.

Parameters
[in]eentry to dump

◆ 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.

If the list is already full, the scanned node is simply ignored.

Parameters
[in]typetype of the advertising packet received
[in]addrBLE address of the scanned node
[in]rssiRSSI of the received advertising packet
[in]adthe payload of the advertising packet
[in]lenlength of ad