Contiki-NG
|
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... | |
#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.
Referenced by ble_advertising_init().
#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.
Referenced by ble_advertising_init().
void ble_advertising_init | ( | const char * | name | ) |
Initialize BLE advertising data.
name | Human readable device name that will be advertised |
Definition at line 126 of file ble-core.c.
References APP_ADV_ADV_INTERVAL, APP_ADV_TIMEOUT, and m_adv_params.
Referenced by platform_init_stage_two().
|
static |
SoftDevice BLE event callback.
[in] | p_ble_evt | Bluetooth stack event. |
Definition at line 222 of file ble-core.c.
References on_ble_evt().
Referenced by ble_stack_init().
void ble_gap_addr_print | ( | const ble_gap_addr_t * | addr | ) |
Print GAP address.
addr | a pointer to address |
Definition at line 181 of file ble-core.c.
Referenced by on_ble_evt().
void ble_get_mac | ( | uint8_t | addr[8] | ) |
Return device EUI64 MAC address.
addr | pointer to a buffer to store the address |
Definition at line 110 of file ble-core.c.
Referenced by platform_init_stage_three().
|
static |
Add IPSP connection to the interface table.
This function binds IPSP connection with peer address.
peer | a pointer to eui64 address |
handle | a pointer to IPSP handle |
a | pointer to an interface structure on success |
NULL | if interface table is full |
Definition at line 133 of file ble-mac.c.
References ble_event_interface_added, BLE_MAC_MAX_INTERFACE_NUM, and process_post().
Referenced by ble_mac_ipsp_evt_handler_irq().
|
static |
Remove interface from the interface table.
interface | a pointer to interface |
Definition at line 152 of file ble-mac.c.
References ble_event_interface_deleted, and process_post().
Referenced by ble_mac_ipsp_evt_handler_irq().
|
static |
Lookup interface by IPSP connection.
handle | a pointer to IPSP handle. |
a | pointer to interface structure |
NULL | if no interface has been found for a given handle |
Definition at line 109 of file ble-mac.c.
References BLE_MAC_MAX_INTERFACE_NUM.
Referenced by ble_mac_ipsp_evt_handler_irq().
|
static |
Callback registered with IPSP to receive asynchronous events from the module.
[in] | p_handle | Pointer to IPSP handle. |
[in] | p_evt | Pointer to specific event, generated by IPSP module. |
Definition at line 169 of file ble-mac.c.
References ble_mac_interface_add(), ble_mac_interface_delete(), ble_mac_interface_lookup(), busy_rx, busy_tx, linkaddr_node_addr, packetbuf_copyfrom(), PACKETBUF_SIZE, PROCESS_BEGIN, PROCESS_END, process_poll(), PROCESS_THREAD(), and PROCESS_WAIT_EVENT.
Referenced by send_to_peer().
|
static |
Lookup IPSP handle by peer address.
addr | a pointer to eui64 address. |
a | pointer to IPSP handle on success |
NULL | if an IPSP handle for given address haven't been found |
Definition at line 276 of file ble-mac.c.
References BLE_MAC_MAX_INTERFACE_NUM, and linkaddr_cmp().
Referenced by send_to_peer().
|
static |
Function for handling the Application's BLE Stack events.
[in] | p_ble_evt | Bluetooth stack event. |
Definition at line 196 of file ble-core.c.
References ble_advertising_start(), and ble_gap_addr_print().
Referenced by ble_evt_dispatch().
|
static |
Send packet on a given IPSP handle.
handle | a pointer to IPSP handle. |
Definition at line 294 of file ble-mac.c.
References ble_event_interface_added, ble_event_interface_deleted, ble_mac_ipsp_evt_handler_irq(), BLE_MAC_MAX_INTERFACE_NUM, busy_tx, find_handle(), network_driver::init, linkaddr_cmp(), linkaddr_null, MAC_TX_ERR, MAC_TX_OK, packetbuf_datalen(), packetbuf_dataptr(), process_alloc_event(), process_start(), send_packet(), and watchdog_periodic().
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.
Referenced by ble_mac_interface_add(), and send_to_peer().
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.
Referenced by ble_mac_interface_add(), and send_to_peer().
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.
Referenced by ble_mac_interface_delete(), and send_to_peer().
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.
Referenced by ble_mac_interface_delete(), and send_to_peer().
|
static |
Flag is set to 1 when there is a received packet pending.
Definition at line 88 of file ble-mac.c.
Referenced by ble_mac_ipsp_evt_handler_irq().
|
static |
Flag is set to 1 when the driver is busy transmitting a packet.
Definition at line 87 of file ble-mac.c.
Referenced by ble_mac_ipsp_evt_handler_irq(), and send_to_peer().
|
static |
Parameters to be passed to the stack when starting advertising.
Definition at line 66 of file ble-core.c.
Referenced by ble_advertising_init(), and ble_advertising_start().