41 lines
3.0 KiB
C
41 lines
3.0 KiB
C
/* Внутренний платформенный контракт. Все вызовы/события в uasync, send/close не вызывают события синхронно.
|
|
* ACCEPTED send копирует значение и даёт ровно один sent, либо closed отменяет все операции соединения.
|
|
* DATA sent означает локальное завершение; INVITE/ACK используют 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_ACK_UUID "f61a9024-4abc-45ac-98e1-761df4c13811"
|
|
#define BLE_VALUE_MAX 512
|
|
/* Wire-каналы backend; ACK не является прикладным каналом ble_channel. */
|
|
enum ble_wire_channel { BLE_WIRE_DATA, BLE_WIRE_INVITE, BLE_WIRE_ACK, BLE_WIRE_COUNT };
|
|
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_wire_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_wire_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
|