ble/stack/peripheral.h header reference
[Bluetooth Low Energy library module]
The source code of this header can be browsed online.
Description [link]
this header contains definitions for a Peripheral context stack utility.
Members [link]
Types [link]
- struct ble_peripheral_handler_s
- enum ble_peripheral_mode_e
- struct ble_peripheral_params_s
- struct ble_peripheral_s
- enum ble_peripheral_state_e
Functions [link]
- void ble_peripheral_cleanup(struct ble_peripheral_s *peri)
- struct ble_peripheral_handler_s * ble_peripheral_handler_s_from_base(void *x)
- error_t ble_peripheral_init(struct ble_peripheral_s *peri, const struct ble_peripheral_params_s *params, const struct ble_peripheral_handler_s *handler, struct ble_stack_context_s *context)
- void ble_peripheral_mode_set(struct ble_peripheral_s *peri, uint8_t mode)
- struct ble_peripheral_s * ble_peripheral_s_from_conn(void *x)
Members detail [link]
#define BLE_STACK_PERIPHERAL_H [link]
This macro is declared in ble/stack/peripheral.h source file, line 30.
void ble_peripheral_cleanup(struct ble_peripheral_s *peri) [link]
This function is declared in ble/stack/peripheral.h source file, line 154.
struct ble_peripheral_handler_s [link]
This struct is declared in ble/stack/peripheral.h source file, line 80.
this struct defines the set of functions a peripheral context can call back. They allow the peripheral context to meet caller's expectations.
Field | Description |
---|---|
struct ble_stack_connection_handler_s base; | Connection-specific callbacks |
bool_t (*connection_requested)(struct ble_peripheral_s *peri, const struct ble_addr_s *addr) ; | this variable asks the handler whether connection request from address addr should be accepted. |
void (*state_changed)(struct ble_peripheral_s *peri, enum ble_peripheral_state_e state) ; | this variable notifies the handler of new peripheral state. This will typically change on accepted connection request, connection drop, or mode change. |
struct ble_peripheral_handler_s * ble_peripheral_handler_s_from_base(void *x) [link]
This function is declared in ble/stack/peripheral.h source file, line 102.
error_t ble_peripheral_init(struct ble_peripheral_s *peri, const struct ble_peripheral_params_s *params, const struct ble_peripheral_handler_s *handler, struct ble_stack_context_s *context) [link]
This function is declared in ble/stack/peripheral.h source file, line 146.
this function initializes a peripheral stack context.
enum ble_peripheral_mode_e [link]
This enum is declared in ble/stack/peripheral.h source file, line 65.
this enum is a or-mask of device supported actions. Mode should be updated through calls to ble_peripheral_mode_set.
Identifier | Description |
---|---|
BLE_PERIPHERAL_DISCOVERABLE | Peripheral will advertise |
BLE_PERIPHERAL_PAIRABLE | Accept connections from any host, even not in whitelist |
BLE_PERIPHERAL_CONNECTABLE | Peripheral will accept connections |
void ble_peripheral_mode_set(struct ble_peripheral_s *peri, uint8_t mode) [link]
This function is declared in ble/stack/peripheral.h source file, line 152.
this function sets peripheral mode. If passed mode implies connection is not possible, current connection gets dropped, if any.
struct ble_peripheral_params_s [link]
This struct is declared in ble/stack/peripheral.h source file, line 108.
this struct is peripheral parameters.
Field | Description |
---|---|
enum ble_phy_mode_e phy; | |
uint32_t adv_interval_ms; | Interval in milliseconds between two advertising events. |
struct ble_peripheral_s [link]
This struct is declared in ble/stack/peripheral.h source file, line 126.
this struct is an utility for easy declaration of a typical Peripheral role. This utility uses a stack context as data source, advertises for device properties, and waits for a connection request.
Upon connection request, if handler accepts the connection, advertising stops util connection closes. To this extent, this utility handles only one concurrent connection.
Field | Description |
---|---|
struct ble_stack_context_s * context; | |
const struct ble_peripheral_handler_s * handler; | |
struct ble_stack_connection_s conn; | |
struct net_layer_s * adv; | |
struct ble_addr_s addr; | |
enum ble_peripheral_state_e last_state:8; | |
uint8_t mode; | |
struct ble_peripheral_params_s params; |
struct ble_peripheral_s * ble_peripheral_s_from_conn(void *x) [link]
This function is declared in ble/stack/peripheral.h source file, line 137.
enum ble_peripheral_state_e [link]
This enum is declared in ble/stack/peripheral.h source file, line 48.
this enum is a list of states a peripheral may be in.
Identifier | Description |
---|---|
BLE_PERIPHERAL_IDLE | Peripheral is not connected, not advertising |
BLE_PERIPHERAL_RECONNECTING | Peripheral is not connected, fast advertising |
BLE_PERIPHERAL_ADVERTISING | Peripheral is not connected, normally advertising |
BLE_PERIPHERAL_PAIRING | Peripheral is connected to a non-paired device |
BLE_PERIPHERAL_CONNECTED | Peripheral is connected to a paired device |