51 lines
1.3 KiB
C

/**
* @file app_ble.h
* @brief BLE application layer: stack init, advertising, custom link service,
* FreeRTOS schedule task and the uplink/downlink data interface.
*/
#ifndef __APP_BLE_H__
#define __APP_BLE_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
/**
* @brief Initialize the BLE stack, GAP/security/advertising parameters and
* the CLS profile, start advertising, and create the FreeRTOS task
* that runs rwip_schedule(). Must be called before the scheduler runs.
*/
void app_ble_init(void);
/**
* @brief Send one notification packet to the connected peer.
* @return 0 if queued, -1 if not connected / notify not enabled / busy.
* The caller is responsible for retrying or queueing on -1.
*/
int app_ble_notify_send(const uint8_t *data, uint16_t len);
/**
* @brief Register the callback for downlink data (peer writes the write
* characteristic). The callback runs in the BLE schedule task context.
*/
void app_ble_set_rx_callback(void (*cb)(const uint8_t*, uint16_t));
/**
* @brief BLE connection state (1 = connected).
*/
uint8_t app_ble_is_connected(void);
/**
* @brief Max payload bytes per BLE notification packet (att_mtu-3).
* Returns 17 (20-3, default MTU) while not connected.
*/
uint16_t app_ble_max_payload(void);
#ifdef __cplusplus
}
#endif
#endif /* __APP_BLE_H__ */