File ns_ble.c
FileList > neuralSPOT > neuralspot > ns-ble > src > ns_ble.c
Go to the source code of this file
Generic BLE Wrapper. More...
#include "ns_ble.h"
Public Attributes
Type | Name |
---|---|
ns_ble_control_t | g_ns_ble_control |
const ns_core_api_t | ns_ble_V0_0_1 |
Public Static Attributes
Type | Name |
---|---|
appAdvCfg_t | ns_ble_default_AdvCfg = = { |
{60000, 0, 0}, | |
{96, 96, 0} | |
} |
|
appSecCfg_t | ns_ble_default_SecCfg = = { |
DM_AUTH_BOND_FLAG | DM_AUTH_SC_FLAG, |
0,
DM\_KEY\_DIST\_LTK,
FALSE,
FALSE
}
|
| appSlaveCfg_t | ns_ble_default_SlaveCfg = = {
NS_BLE_CONN_MAX,
}
|
| smpCfg_t | ns_ble_default_SmpCfg = = {
3200,
SMP\_IO\_NO\_IN\_NO\_OUT,
7,
16,
3,
0,
}
|
| appUpdateCfg_t | ns_ble_default_UpdateCfg = = {
3100,
8,
18,
0,
600,
5
}
|
| const uint8_t | ns_ble_generic_data_disc
|
| const uint8_t | ns_ble_generic_scan_data_disc
|
Public Functions
Type | Name |
---|---|
void | am_cooper_irq_isr (void) |
void | am_uart_isr (void) |
int | ns_ble_add_characteristic (ns_ble_service_t * s, ns_ble_characteristic_t * c) Add a characteristic to a service. This function should be called after all characteristics have been defined using ns_ble_create_characteristic. |
int | ns_ble_char2uuid (const char uuidString, ns_ble_uuid128_t * uuid128) Helper function to convert a 16-byte UUID string to a 128-bit UUID byte array. UUID string must be exactly 16 characters long and only contain hex characters. |
int | ns_ble_create_characteristic (ns_ble_characteristic_t * c, char const * uuidString, void * applicationValue, uint16_t valueLength, uint16_t properties, ns_ble_characteristic_read_handler_t readHandlerCb, ns_ble_characteristic_write_handler_t writeHandlerCb, ns_ble_characteristic_notify_handler_t notifyHandlerCb, uint16_t periodMs, uint8_t async, uint16_t * attributeCount) Define a characteristic for subsequent addition to a service. |
int | ns_ble_create_service (ns_ble_service_t * s) Create a BLE service based on the given configuration. |
void | ns_ble_generic_handler (wsfEventMask_t event, wsfMsgHdr_t * pMsg) |
void | ns_ble_generic_handlerInit (wsfHandlerId_t handlerId, ns_ble_service_control_t * cfg) |
void | ns_ble_generic_init (bool useDefault, ns_ble_control_t * generic_cfg, ns_ble_service_control_t * service_cfg) |
uint8_t | ns_ble_generic_read_cback (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, attsAttr_t * pAttr) |
uint8_t | ns_ble_generic_write_cback (dmConnId_t connId, uint16_t handle, uint8_t operation, uint16_t offset, uint16_t len, uint8_t * pValue, attsAttr_t * pAttr) |
uint16_t | ns_ble_get_next_handle_id (ns_ble_service_t * service) |
void | ns_ble_new_handler (wsfEventMask_t event, wsfMsgHdr_t * pMsg) |
void | ns_ble_new_handler_init (wsfHandlerId_t handlerId) |
bool | ns_ble_new_proc_msg (ns_ble_msg_t * pMsg) |
void | ns_ble_pre_init (void) Call this function from the setup_task, prior to creating the RadioTask All this does is set up NVIC priorities. |
void | ns_ble_send_value (ns_ble_characteristic_t * c, attEvt_t * pMsg) |
int | ns_ble_set_tx_power (txPowerLevel_t power) Function to set the BLE TX power. |
int | ns_ble_start_service (ns_ble_service_t * s) Invoked by RadioTask to start the service. This function should be called after all characteristics have been added. |
Public Static Functions
Type | Name |
---|---|
void | ns_ble_generic_AttCback (attEvt_t * pEvt) |
void | ns_ble_generic_CccCback (attsCccEvt_t * pEvt) |
void | ns_ble_generic_DmCback (dmEvt_t * pDmEvt) |
void | ns_ble_generic_advSetup (ns_ble_msg_t * pMsg) |
void | ns_ble_generic_conn_open (dmEvt_t * pMsg) |
void | ns_ble_generic_conn_update (dmEvt_t * pMsg) |
void | ns_ble_generic_new_handle_cnf (attEvt_t * pMsg) |
void | ns_ble_generic_procMsg (ns_ble_msg_t * pMsg) |
bool | ns_ble_handle_indication_timer_expired (ns_ble_msg_t * pMsg) |
void | ns_ble_process_ccc_state (attsCccEvt_t * pMsg) |
Detailed Description
Author:
Ambiq Team
Version:
0.1
Date:
2023-06-08
Copyright:
Copyright (c) 2023
Public Attributes Documentation
variable g_ns_ble_control
ns_ble_control_t g_ns_ble_control;
variable ns_ble_V0_0_1
const ns_core_api_t ns_ble_V0_0_1;
Public Static Attributes Documentation
variable ns_ble_default_AdvCfg
appAdvCfg_t ns_ble_default_AdvCfg;
configurable parameters for advertising
variable ns_ble_default_SecCfg
appSecCfg_t ns_ble_default_SecCfg;
configurable parameters for security
variable ns_ble_default_SlaveCfg
appSlaveCfg_t ns_ble_default_SlaveCfg;
configurable parameters for slave
variable ns_ble_default_SmpCfg
smpCfg_t ns_ble_default_SmpCfg;
SMP security parameter configuration
variable ns_ble_default_UpdateCfg
appUpdateCfg_t ns_ble_default_UpdateCfg;
configurable parameters for connection parameter update
variable ns_ble_generic_data_disc
const uint8_t ns_ble_generic_data_disc[];
advertising data, discoverable mode
variable ns_ble_generic_scan_data_disc
const uint8_t ns_ble_generic_scan_data_disc[];
scan data, discoverable mode
Public Functions Documentation
function am_cooper_irq_isr
void am_cooper_irq_isr (
void
)
function am_uart_isr
void am_uart_isr (
void
)
function ns_ble_add_characteristic
Add a characteristic to a service. This function should be called after all characteristics have been defined using ns_ble_create_characteristic.
int ns_ble_add_characteristic (
ns_ble_service_t * s,
ns_ble_characteristic_t * c
)
Parameters:
s
- a pointer to the service to which the characteristic should be addedc
- a pointer to the characteristic to be added
Returns:
int
function ns_ble_char2uuid
Helper function to convert a 16-byte UUID string to a 128-bit UUID byte array. UUID string must be exactly 16 characters long and only contain hex characters.
int ns_ble_char2uuid (
const char uuidString,
ns_ble_uuid128_t * uuid128
)
Parameters:
uuidString
- a 16-byte UUID stringuuid128
- a pointer to a 128-bit UUID byte array (uuid128.array)
Returns:
int
function ns_ble_create_characteristic
Define a characteristic for subsequent addition to a service.
int ns_ble_create_characteristic (
ns_ble_characteristic_t * c,
char const * uuidString,
void * applicationValue,
uint16_t valueLength,
uint16_t properties,
ns_ble_characteristic_read_handler_t readHandlerCb,
ns_ble_characteristic_write_handler_t writeHandlerCb,
ns_ble_characteristic_notify_handler_t notifyHandlerCb,
uint16_t periodMs,
uint8_t async,
uint16_t * attributeCount
)
Parameters:
c
- config struct, populated by this functionuuidString
- a 16-byte UUID stringapplicationValue
- a pointer to the application's value storevalueLength
- the length of the value store, in bytesproperties
- a bitmask of properties for the characteristic, from the enum abovereadHandlerCb
- a callback function for read requests if the characteristic is readablewriteHandlerCb
- a callback function for write requests if the characteristic is writablenotifyHandlerCb
- a callback function for notify requests if the characteristic is "subscribe-able"periodMs
- the period of the notify timer, in millisecondsattributeCount
- a pointer to the service's attribute count. This is incremented by the function.
Returns:
int
function ns_ble_create_service
Create a BLE service based on the given configuration.
int ns_ble_create_service (
ns_ble_service_t * s
)
Parameters:
s
- a pointer to a service configuration struct. Relevant fields are:- uuid128: a 128-bit UUID for the service
- name: a string name for the service, up to 31 characters
- nameLen: the length of the name string
- baseHandle: the first handle ID of the service. This is used by BLE to identify attributes of the service
- numAttributes: keeps track of the number of attributes in the service. Initialize to 0.
- poolConfig: a pointer to a WSF pool configuration struct.
Returns:
int
function ns_ble_generic_handler
void ns_ble_generic_handler (
wsfEventMask_t event,
wsfMsgHdr_t * pMsg
)
function ns_ble_generic_handlerInit
void ns_ble_generic_handlerInit (
wsfHandlerId_t handlerId,
ns_ble_service_control_t * cfg
)
function ns_ble_generic_init
void ns_ble_generic_init (
bool useDefault,
ns_ble_control_t * generic_cfg,
ns_ble_service_control_t * service_cfg
)
function ns_ble_generic_read_cback
uint8_t ns_ble_generic_read_cback (
dmConnId_t connId,
uint16_t handle,
uint8_t operation,
uint16_t offset,
attsAttr_t * pAttr
)
function ns_ble_generic_write_cback
uint8_t ns_ble_generic_write_cback (
dmConnId_t connId,
uint16_t handle,
uint8_t operation,
uint16_t offset,
uint16_t len,
uint8_t * pValue,
attsAttr_t * pAttr
)
function ns_ble_get_next_handle_id
uint16_t ns_ble_get_next_handle_id (
ns_ble_service_t * service
)
function ns_ble_new_handler
void ns_ble_new_handler (
wsfEventMask_t event,
wsfMsgHdr_t * pMsg
)
function ns_ble_new_handler_init
void ns_ble_new_handler_init (
wsfHandlerId_t handlerId
)
function ns_ble_new_proc_msg
bool ns_ble_new_proc_msg (
ns_ble_msg_t * pMsg
)
function ns_ble_pre_init
void ns_ble_pre_init (
void
)
function ns_ble_send_value
void ns_ble_send_value (
ns_ble_characteristic_t * c,
attEvt_t * pMsg
)
function ns_ble_set_tx_power
Function to set the BLE TX power.
int ns_ble_set_tx_power (
txPowerLevel_t power
)
Parameters:
power
- tx power level in dBm.
Returns:
bool
function ns_ble_start_service
Invoked by RadioTask to start the service. This function should be called after all characteristics have been added.
int ns_ble_start_service (
ns_ble_service_t * s
)
Parameters:
s
- a pointer to the service to be started
Returns:
int
Public Static Functions Documentation
function ns_ble_generic_AttCback
static void ns_ble_generic_AttCback (
attEvt_t * pEvt
)
function ns_ble_generic_CccCback
static void ns_ble_generic_CccCback (
attsCccEvt_t * pEvt
)
function ns_ble_generic_DmCback
static void ns_ble_generic_DmCback (
dmEvt_t * pDmEvt
)
function ns_ble_generic_advSetup
static void ns_ble_generic_advSetup (
ns_ble_msg_t * pMsg
)
function ns_ble_generic_conn_open
static void ns_ble_generic_conn_open (
dmEvt_t * pMsg
)
function ns_ble_generic_conn_update
static void ns_ble_generic_conn_update (
dmEvt_t * pMsg
)
function ns_ble_generic_new_handle_cnf
static void ns_ble_generic_new_handle_cnf (
attEvt_t * pMsg
)
function ns_ble_generic_procMsg
static void ns_ble_generic_procMsg (
ns_ble_msg_t * pMsg
)
function ns_ble_handle_indication_timer_expired
static bool ns_ble_handle_indication_timer_expired (
ns_ble_msg_t * pMsg
)
function ns_ble_process_ccc_state
static void ns_ble_process_ccc_state (
attsCccEvt_t * pMsg
)
The documentation for this class was generated from the following file neuralSPOT/neuralspot/ns-ble/src/ns_ble.c