Contiki-NG
Files | Macros | Functions | Variables
Bluetooth Low Energy drivers

Files

file  ble-core.c
 Basic BLE functions.
 
file  ble-core.h
 Basic BLE functions.
 
file  ble-mac.c
 A MAC protocol implementation that uses nRF52 IPSP implementation as a link layer.
 
file  ble-mac.h
 A MAC protocol implementation that uses nRF52 IPSP implementation as a link layer.
 

Macros

#define APP_ADV_TIMEOUT   0
 Time for which the device must be advertising in non-connectable mode (in seconds). More...
 
#define APP_ADV_ADV_INTERVAL   MSEC_TO_UNITS(333, UNIT_0_625_MS)
 The advertising interval. More...
 
#define BLE_MAC_MAX_INTERFACE_NUM   1
 Maximum number of interfaces, i.e., connection to master devices.
 

Functions

static void ble_evt_dispatch (ble_evt_t *p_ble_evt)
 SoftDevice BLE event callback. More...
 
void ble_stack_init (void)
 Initialize and enable the BLE stack.
 
void ble_get_mac (uint8_t addr[8])
 Return device EUI64 MAC address. More...
 
void ble_advertising_init (const char *name)
 Initialize BLE advertising data. More...
 
void ble_advertising_start (void)
 Start BLE advertising.
 
void ble_gap_addr_print (const ble_gap_addr_t *addr)
 Print GAP address. More...
 
static void on_ble_evt (ble_evt_t *p_ble_evt)
 Function for handling the Application's BLE Stack events. More...
 
static ble_mac_interface_t * ble_mac_interface_lookup (ble_ipsp_handle_t *handle)
 Lookup interface by IPSP connection. More...
 
static ble_mac_interface_t * ble_mac_interface_add (eui64_t *peer, ble_ipsp_handle_t *handle)
 Add IPSP connection to the interface table. More...
 
static void ble_mac_interface_delete (ble_mac_interface_t *interface)
 Remove interface from the interface table. More...
 
static uint32_t ble_mac_ipsp_evt_handler_irq (ble_ipsp_handle_t *p_handle, ble_ipsp_evt_t *p_evt)
 Callback registered with IPSP to receive asynchronous events from the module. More...
 
static ble_ipsp_handle_t * find_handle (const linkaddr_t *addr)
 Lookup IPSP handle by peer address. More...
 
static int send_to_peer (ble_ipsp_handle_t *handle)
 Send packet on a given IPSP handle. More...
 

Variables

static ble_gap_adv_params_t m_adv_params
 Parameters to be passed to the stack when starting advertising. More...
 
process_event_t ble_event_interface_added
 This event is broadcast when BLE connection is established. More...
 
process_event_t ble_event_interface_deleted
 This event is broadcast when BLE connection is destroyed. More...
 
static volatile int busy_tx
 Flag is set to 1 when the driver is busy transmitting a packet. More...
 
static volatile int busy_rx
 Flag is set to 1 when there is a received packet pending. More...
 
const struct mac_driver ble_ipsp_mac_driver
 BLE over IPSP MAC driver structure.
 
const struct mac_driver ble_ipsp_mac_driver
 BLE over IPSP MAC driver structure.
 
process_event_t ble_event_interface_added
 This event is broadcast when a new IPSP connection is established. More...
 
process_event_t ble_event_interface_deleted
 This event is broadcast when a IPSP connection is deleted. More...
 

Detailed Description

Macro Definition Documentation

◆ APP_ADV_ADV_INTERVAL

#define APP_ADV_ADV_INTERVAL   MSEC_TO_UNITS(333, UNIT_0_625_MS)

The advertising interval.

This value can vary between 100ms to 10.24s).

Definition at line 64 of file ble-core.c.

◆ APP_ADV_TIMEOUT

#define APP_ADV_TIMEOUT   0

Time for which the device must be advertising in non-connectable mode (in seconds).

0 disables timeout.

Definition at line 63 of file ble-core.c.

Function Documentation

◆ ble_advertising_init()

void ble_advertising_init ( const char *  name)

Initialize BLE advertising data.

Parameters
nameHuman readable device name that will be advertised

Definition at line 126 of file ble-core.c.

◆ ble_evt_dispatch()

static void ble_evt_dispatch ( ble_evt_t *  p_ble_evt)
static

SoftDevice BLE event callback.

Parameters
[in]p_ble_evtBluetooth stack event.

Definition at line 222 of file ble-core.c.

References on_ble_evt().

◆ ble_gap_addr_print()

void ble_gap_addr_print ( const ble_gap_addr_t *  addr)

Print GAP address.

Parameters
addra pointer to address

Definition at line 181 of file ble-core.c.

◆ ble_get_mac()

void ble_get_mac ( uint8_t  addr[8])

Return device EUI64 MAC address.

Parameters
addrpointer to a buffer to store the address

Definition at line 110 of file ble-core.c.

Referenced by platform_init_stage_three().

◆ ble_mac_interface_add()

static ble_mac_interface_t* ble_mac_interface_add ( eui64_t *  peer,
ble_ipsp_handle_t *  handle 
)
static

Add IPSP connection to the interface table.

This function binds IPSP connection with peer address.

Parameters
peera pointer to eui64 address
handlea pointer to IPSP handle
Return values
apointer to an interface structure on success
NULLif interface table is full

Definition at line 133 of file ble-mac.c.

◆ ble_mac_interface_delete()

static void ble_mac_interface_delete ( ble_mac_interface_t *  interface)
static

Remove interface from the interface table.

Parameters
interfacea pointer to interface

Definition at line 152 of file ble-mac.c.

◆ ble_mac_interface_lookup()

static ble_mac_interface_t* ble_mac_interface_lookup ( ble_ipsp_handle_t *  handle)
static

Lookup interface by IPSP connection.

Parameters
handlea pointer to IPSP handle.
Return values
apointer to interface structure
NULLif no interface has been found for a given handle

Definition at line 109 of file ble-mac.c.

◆ ble_mac_ipsp_evt_handler_irq()

static uint32_t ble_mac_ipsp_evt_handler_irq ( ble_ipsp_handle_t *  p_handle,
ble_ipsp_evt_t *  p_evt 
)
static

Callback registered with IPSP to receive asynchronous events from the module.

Note
This function is called from SoftDevice interrupt context.
Parameters
[in]p_handlePointer to IPSP handle.
[in]p_evtPointer to specific event, generated by IPSP module.
Returns
NRF_SUCCESS on success, otherwise NRF_ERROR_NO_MEM error.

Definition at line 169 of file ble-mac.c.

◆ find_handle()

static ble_ipsp_handle_t* find_handle ( const linkaddr_t *  addr)
static

Lookup IPSP handle by peer address.

Parameters
addra pointer to eui64 address.
Return values
apointer to IPSP handle on success
NULLif an IPSP handle for given address haven't been found

Definition at line 276 of file ble-mac.c.

◆ on_ble_evt()

static void on_ble_evt ( ble_evt_t *  p_ble_evt)
static

Function for handling the Application's BLE Stack events.

Parameters
[in]p_ble_evtBluetooth stack event.

Definition at line 196 of file ble-core.c.

Referenced by ble_evt_dispatch().

◆ send_to_peer()

static int send_to_peer ( ble_ipsp_handle_t *  handle)
static

Send packet on a given IPSP handle.

Parameters
handlea pointer to IPSP handle.
Returns
1 on success, 0 otherwise

Definition at line 294 of file ble-mac.c.

Variable Documentation

◆ ble_event_interface_added [1/2]

process_event_t ble_event_interface_added

This event is broadcast when a new IPSP connection is established.

This event is broadcast when a new IPSP connection is established.

Definition at line 70 of file ble-mac.c.

◆ ble_event_interface_added [2/2]

process_event_t ble_event_interface_added

This event is broadcast when BLE connection is established.

This event is broadcast when a new IPSP connection is established.

Definition at line 70 of file ble-mac.c.

◆ ble_event_interface_deleted [1/2]

process_event_t ble_event_interface_deleted

This event is broadcast when a IPSP connection is deleted.

This event is broadcast when a IPSP connection is deleted.

Definition at line 71 of file ble-mac.c.

◆ ble_event_interface_deleted [2/2]

process_event_t ble_event_interface_deleted

This event is broadcast when BLE connection is destroyed.

This event is broadcast when a IPSP connection is deleted.

Definition at line 71 of file ble-mac.c.

◆ busy_rx

volatile int busy_rx
static

Flag is set to 1 when there is a received packet pending.

Definition at line 88 of file ble-mac.c.

◆ busy_tx

volatile int busy_tx
static

Flag is set to 1 when the driver is busy transmitting a packet.

Definition at line 87 of file ble-mac.c.

◆ m_adv_params

ble_gap_adv_params_t m_adv_params
static

Parameters to be passed to the stack when starting advertising.

Definition at line 66 of file ble-core.c.

Referenced by ble_advertising_start().