38 lines
2.8 KiB
C
38 lines
2.8 KiB
C
/* Внутренний платформенный контракт. Все вызовы/события в uasync, send/close не вызывают события синхронно.
|
|
* ACCEPTED send копирует значение и даёт ровно один sent, либо closed отменяет все операции соединения.
|
|
* DATA sent означает локальное завершение без ATT ACK, INVITE сохраняет Request/Indication.
|
|
* close/destroy отменяют callbacks; transport создаёт идентификаторы, backend не хранит указатели core-link.
|
|
* Реализации не создают неограниченных очередей: максимум одна операция send на link. */
|
|
#ifndef VIBECHAT_BLE_BACKEND_H
|
|
#define VIBECHAT_BLE_BACKEND_H
|
|
#include "ble_transport.h"
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
#define BLE_SERVICE_UUID "f61a9020-4abc-45ac-98e1-761df4c13811"
|
|
#define BLE_RX_UUID "f61a9021-4abc-45ac-98e1-761df4c13811"
|
|
#define BLE_TX_UUID "f61a9022-4abc-45ac-98e1-761df4c13811"
|
|
#define BLE_INVITE_UUID "f61a9023-4abc-45ac-98e1-761df4c13811"
|
|
#define BLE_VALUE_MAX 512
|
|
struct ble_backend;
|
|
struct ble_backend* ble_backend_create(struct ble_transport* owner, struct UASYNC* ua, const struct ble_config* config);
|
|
void ble_backend_destroy(struct ble_backend* backend);
|
|
int ble_backend_advertise(struct ble_backend* backend, const uint8_t* data, size_t len);
|
|
int ble_backend_connect(struct ble_backend* backend, ble_link_id id, const struct ble_endpoint* endpoint);
|
|
void ble_backend_close(struct ble_backend* backend, ble_link_id id);
|
|
int ble_backend_send(struct ble_backend* backend, ble_link_id id, enum ble_channel channel, const uint8_t* data, size_t len);
|
|
/* События backend. incoming вызывается до любых других событий нового входящего link; 0 = лимит/отказ. */
|
|
ble_link_id ble_backend_incoming(struct ble_transport* owner, const struct ble_endpoint* endpoint);
|
|
void ble_backend_status(struct ble_transport* owner, int ready, const char* reason);
|
|
void ble_backend_advertising(struct ble_transport* owner, enum ble_state state, const char* reason);
|
|
void ble_backend_broadcast(struct ble_transport* owner, const struct ble_endpoint* endpoint,
|
|
const uint8_t* data, size_t len, int rssi);
|
|
void ble_backend_opened(struct ble_transport* owner, ble_link_id id, unsigned int mtu);
|
|
void ble_backend_received(struct ble_transport* owner, ble_link_id id, enum ble_channel channel, const uint8_t* data, size_t len);
|
|
void ble_backend_sent(struct ble_transport* owner, ble_link_id id, int success);
|
|
void ble_backend_closed(struct ble_transport* owner, ble_link_id id, const char* reason);
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
#endif
|