Helper module to simplify the usage of NimBLE in scanning mode. More...

Detailed Description

Helper module to simplify the usage of NimBLE in scanning mode.

Files

file  nimble_scanner.h
 Scanner abstraction for NimBLE.
 

Typedefs

typedef void(* nimble_scanner_cb) (uint8_t type, const ble_addr_t *addr, int8_t rssi, const uint8_t *ad, size_t ad_len)
 Callback signature triggered by this module for each discovered advertising packet. More...
 

Enumerations

enum  { NIMBLE_SCANNER_OK = 0, NIMBLE_SCANNER_SCANNING = 1, NIMBLE_SCANNER_STOPPED = 2, NIMBLE_SCANNER_ERR = -1 }
 Return values used by this submodule.
 

Functions

int nimble_scanner_init (const struct ble_gap_disc_params *params, nimble_scanner_cb disc_cb)
 Initialize the scanner module. More...
 
int nimble_scanner_start (void)
 Start scanning using timing parameters configured on initialization.
 
void nimble_scanner_stop (void)
 Stop scanning.
 
int nimble_scanner_status (void)
 Get the current scanning status. More...
 

Typedef Documentation

◆ nimble_scanner_cb

typedef void(* nimble_scanner_cb) (uint8_t type, const ble_addr_t *addr, int8_t rssi, const uint8_t *ad, size_t ad_len)

Callback signature triggered by this module for each discovered advertising packet.

Parameters
[in]typetype of advertising packet, e.g BLE_HCI_ADV_TYPE_ADV_IND
[in]addradvertising address of the source node
[in]rssiRSSI value for the received packet
[in]adadvertising data
[in]ad_lenlength of ad in bytes

Definition at line 52 of file nimble_scanner.h.

Function Documentation

◆ nimble_scanner_init()

int nimble_scanner_init ( const struct ble_gap_disc_params *  params,
nimble_scanner_cb  disc_cb 
)

Initialize the scanner module.

Parameters
[in]paramsscan parameters to use, pass NULL to use NimBLE's default parameters
[in]disc_cbcallback triggered of each received advertising packet
Returns
NIMBLE_SCANNER_OK on success
NIMBLE_SCANNER_ERR if putting NimBLE into discovery mode failed

◆ nimble_scanner_status()

int nimble_scanner_status ( void  )

Get the current scanning status.

Returns
NIMBLE_SCANNER_SCANNING if currently scanning
NIMBLE_SCANNER_STOPPED if the scanner is stopped