This commit is contained in:
MX
2023-09-11 18:51:14 +03:00
parent d4cad7b8c6
commit 091210c003
3 changed files with 17 additions and 17 deletions

View File

@@ -14,7 +14,6 @@ void flipper_gatt_characteristic_init(
furi_assert(char_instance);
// Copy the descriptor to the instance, since it may point to stack memory
// TODO: only copy if really comes from stack
char_instance->characteristic = malloc(sizeof(FlipperGattCharacteristicParams));
memcpy(
(void*)char_instance->characteristic,

View File

@@ -23,6 +23,10 @@ typedef struct {
static_assert(sizeof(HidSvcReportId) == sizeof(uint16_t), "HidSvcReportId must be 2 bytes");
static const Service_UUID_t hid_svc_uuid = {
.Service_UUID_16 = HUMAN_INTERFACE_DEVICE_SERVICE_UUID,
};
static bool
hid_svc_char_desc_data_callback(const void* context, const uint8_t** data, uint16_t* data_len) {
const HidSvcReportId* report_id = context;
@@ -211,18 +215,15 @@ static SVCCTL_EvtAckStatus_t hid_svc_event_handler(void* event) {
void hid_svc_start() {
tBleStatus status;
hid_svc = malloc(sizeof(HIDSvc));
Service_UUID_t svc_uuid = {};
// Register event handler
SVCCTL_RegisterSvcHandler(hid_svc_event_handler);
// Add service
svc_uuid.Service_UUID_16 = HUMAN_INTERFACE_DEVICE_SERVICE_UUID;
/**
* Add Human Interface Device Service
*/
status = aci_gatt_add_service(
UUID_TYPE_16,
&svc_uuid,
&hid_svc_uuid,
PRIMARY_SERVICE,
2 + /* protocol mode */
(4 * HID_SVC_INPUT_REPORT_COUNT) + (3 * HID_SVC_OUTPUT_REPORT_COUNT) +

View File

@@ -10,24 +10,14 @@
#define TAG "BtSerialSvc"
typedef enum {
SerialSvcGattCharacteristicTx = 0,
SerialSvcGattCharacteristicRx,
SerialSvcGattCharacteristicRx = 0,
SerialSvcGattCharacteristicTx,
SerialSvcGattCharacteristicFlowCtrl,
SerialSvcGattCharacteristicStatus,
SerialSvcGattCharacteristicCount,
} SerialSvcGattCharacteristicId;
static const FlipperGattCharacteristicParams serial_svc_chars[SerialSvcGattCharacteristicCount] = {
[SerialSvcGattCharacteristicTx] =
{.name = "TX",
.data_prop_type = FlipperGattCharacteristicDataFixed,
.data.fixed.length = SERIAL_SVC_DATA_LEN_MAX,
.uuid.Char_UUID_128 = SERIAL_SVC_TX_CHAR_UUID,
.uuid_type = UUID_TYPE_128,
.char_properties = CHAR_PROP_READ | CHAR_PROP_INDICATE,
.security_permissions = ATTR_PERMISSION_AUTHEN_READ,
.gatt_evt_mask = GATT_DONT_NOTIFY_EVENTS,
.is_variable = CHAR_VALUE_LEN_VARIABLE},
[SerialSvcGattCharacteristicRx] =
{.name = "RX",
.data_prop_type = FlipperGattCharacteristicDataFixed,
@@ -38,6 +28,16 @@ static const FlipperGattCharacteristicParams serial_svc_chars[SerialSvcGattChara
.security_permissions = ATTR_PERMISSION_AUTHEN_READ | ATTR_PERMISSION_AUTHEN_WRITE,
.gatt_evt_mask = GATT_NOTIFY_ATTRIBUTE_WRITE,
.is_variable = CHAR_VALUE_LEN_VARIABLE},
[SerialSvcGattCharacteristicTx] =
{.name = "TX",
.data_prop_type = FlipperGattCharacteristicDataFixed,
.data.fixed.length = SERIAL_SVC_DATA_LEN_MAX,
.uuid.Char_UUID_128 = SERIAL_SVC_TX_CHAR_UUID,
.uuid_type = UUID_TYPE_128,
.char_properties = CHAR_PROP_READ | CHAR_PROP_INDICATE,
.security_permissions = ATTR_PERMISSION_AUTHEN_READ,
.gatt_evt_mask = GATT_DONT_NOTIFY_EVENTS,
.is_variable = CHAR_VALUE_LEN_VARIABLE},
[SerialSvcGattCharacteristicFlowCtrl] =
{.name = "Flow control",
.data_prop_type = FlipperGattCharacteristicDataFixed,