RPC: Add Virtual Display & Unify log tags (#814)

* RPC: Update protobuf sources
* RPC: Add Virtual Display
* Unify log tags
* RPC: Virtual Display placeholder
* Rpc: clear frame buffer callback before confirm.
* Firmware: full assert for hal, move fatfs initialization to furi hal.
* FuriHal: VCP optimizations, thread safe console. Rpc: adjust buffer sizes.

Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
This commit is contained in:
Anna Prosvetova
2021-11-12 16:04:35 +03:00
committed by GitHub
parent b564e8eb38
commit 558fa5670b
123 changed files with 1050 additions and 694 deletions

View File

@@ -4,7 +4,7 @@
#include <furi.h>
#define BATTERY_SERVICE_TAG "battery service"
#define TAG "BtBatterySvc"
typedef struct {
uint16_t svc_handle;
@@ -23,7 +23,7 @@ void battery_svc_start() {
// Add Battery service
status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&service_uuid, PRIMARY_SERVICE, 4, &battery_svc->svc_handle);
if(status) {
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery service: %d", status);
FURI_LOG_E(TAG, "Failed to add Battery service: %d", status);
}
// Add Battery level characteristic
status = aci_gatt_add_char(battery_svc->svc_handle,
@@ -37,7 +37,7 @@ void battery_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&battery_svc->char_level_handle);
if(status) {
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to add Battery level characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to add Battery level characteristic: %d", status);
}
}
@@ -47,12 +47,12 @@ void battery_svc_stop() {
// Delete Battery level characteristic
status = aci_gatt_del_char(battery_svc->svc_handle, battery_svc->char_level_handle);
if(status) {
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery level characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to delete Battery level characteristic: %d", status);
}
// Delete Battery service
status = aci_gatt_del_service(battery_svc->svc_handle);
if(status) {
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed to delete Battery service: %d", status);
FURI_LOG_E(TAG, "Failed to delete Battery service: %d", status);
}
free(battery_svc);
battery_svc = NULL;
@@ -65,14 +65,14 @@ bool battery_svc_update_level(uint8_t battery_charge) {
return false;
}
// Update battery level characteristic
FURI_LOG_I(BATTERY_SERVICE_TAG, "Updating battery level characteristic");
FURI_LOG_I(TAG, "Updating battery level characteristic");
tBleStatus result = aci_gatt_update_char_value(battery_svc->svc_handle,
battery_svc->char_level_handle,
0,
1,
&battery_charge);
if(result) {
FURI_LOG_E(BATTERY_SERVICE_TAG, "Failed updating RX characteristic: %d", result);
FURI_LOG_E(TAG, "Failed updating RX characteristic: %d", result);
}
return result != BLE_STATUS_SUCCESS;
}

View File

@@ -8,7 +8,7 @@
#include <furi-hal.h>
#define BLE_APP_TAG "ble app"
#define TAG "Bt"
PLACE_IN_SECTION("MB_MEM1") ALIGN(4) static TL_CmdPacket_t ble_app_cmd_buffer;
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint32_t ble_app_nvm[BLE_NVM_SRAM_SIZE];
@@ -53,7 +53,7 @@ bool ble_app_init() {
};
status = SHCI_C2_Config(&config_param);
if(status) {
FURI_LOG_E(BLE_APP_TAG, "Failed to configure 2nd core: %d", status);
FURI_LOG_E(TAG, "Failed to configure 2nd core: %d", status);
}
// Start ble stack on 2nd core
@@ -82,7 +82,7 @@ bool ble_app_init() {
};
status = SHCI_C2_BLE_Init(&ble_init_cmd_packet);
if(status) {
FURI_LOG_E(BLE_APP_TAG, "Failed to start ble stack: %d", status);
FURI_LOG_E(TAG, "Failed to start ble stack: %d", status);
}
return status == SHCI_Success;
}

View File

@@ -10,6 +10,8 @@
#include "app_debug.h"
#include <furi-hal.h>
#define TAG "Core2"
#define POOL_SIZE (CFG_TLBLE_EVT_QUEUE_LENGTH*4U*DIVC(( sizeof(TL_PacketHeader_t) + TL_BLE_EVENT_FRAME_SIZE ), 4U))
PLACE_IN_SECTION("MB_MEM2") ALIGN(4) static uint8_t ble_glue_event_pool[POOL_SIZE];
@@ -125,20 +127,20 @@ static void ble_glue_sys_user_event_callback( void * pPayload ) {
if(p_sys_event->subevtcode == SHCI_SUB_EVT_CODE_READY) {
if(ble_app_init()) {
FURI_LOG_I("Core2", "BLE stack started");
FURI_LOG_I(TAG, "BLE stack started");
ble_glue->status = BleGlueStatusStarted;
if(SHCI_C2_SetFlashActivityControl(FLASH_ACTIVITY_CONTROL_SEM7) == SHCI_Success) {
FURI_LOG_I("Core2", "Flash activity control switched to SEM7");
FURI_LOG_I(TAG, "Flash activity control switched to SEM7");
} else {
FURI_LOG_E("Core2", "Failed to switch flash activity control to SEM7");
FURI_LOG_E(TAG, "Failed to switch flash activity control to SEM7");
}
} else {
FURI_LOG_E("Core2", "BLE stack startup failed");
FURI_LOG_E(TAG, "BLE stack startup failed");
ble_glue->status = BleGlueStatusBleStackMissing;
}
furi_hal_power_insomnia_exit();
} else if(p_sys_event->subevtcode == SHCI_SUB_EVT_ERROR_NOTIF) {
FURI_LOG_E("Core2", "Error during initialization");
FURI_LOG_E(TAG, "Error during initialization");
furi_hal_power_insomnia_exit();
} else if(p_sys_event->subevtcode == SHCI_SUB_EVT_BLE_NVM_RAM_UPDATE) {
SHCI_C2_BleNvmRamUpdate_Evt_t* p_sys_ble_nvm_ram_update_event = (SHCI_C2_BleNvmRamUpdate_Evt_t*)p_sys_event->payload;

View File

@@ -4,7 +4,7 @@
#include <furi.h>
#define DEV_INFO_SVC_TAG "dev info service"
#define TAG "BtDevInfoSvc"
typedef struct {
uint16_t service_handle;
@@ -29,7 +29,7 @@ void dev_info_svc_start() {
uint16_t uuid = DEVICE_INFORMATION_SERVICE_UUID;
status = aci_gatt_add_service(UUID_TYPE_16, (Service_UUID_t*)&uuid, PRIMARY_SERVICE, 9, &dev_info_svc->service_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add Device Information Service: %d", status);
FURI_LOG_E(TAG, "Failed to add Device Information Service: %d", status);
}
// Add characteristics
@@ -45,7 +45,7 @@ void dev_info_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&dev_info_svc->man_name_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add manufacturer name char: %d", status);
FURI_LOG_E(TAG, "Failed to add manufacturer name char: %d", status);
}
uuid = SERIAL_NUMBER_UUID;
status = aci_gatt_add_char(dev_info_svc->service_handle,
@@ -59,7 +59,7 @@ void dev_info_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&dev_info_svc->serial_num_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add serial number char: %d", status);
FURI_LOG_E(TAG, "Failed to add serial number char: %d", status);
}
uuid = FIRMWARE_REVISION_UUID;
status = aci_gatt_add_char(dev_info_svc->service_handle,
@@ -73,7 +73,7 @@ void dev_info_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&dev_info_svc->firmware_rev_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add firmware revision char: %d", status);
FURI_LOG_E(TAG, "Failed to add firmware revision char: %d", status);
}
uuid = SOFTWARE_REVISION_UUID;
status = aci_gatt_add_char(dev_info_svc->service_handle,
@@ -87,7 +87,7 @@ void dev_info_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&dev_info_svc->software_rev_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to add software revision char: %d", status);
FURI_LOG_E(TAG, "Failed to add software revision char: %d", status);
}
// Update characteristics
@@ -97,7 +97,7 @@ void dev_info_svc_start() {
strlen(dev_info_man_name),
(uint8_t*)dev_info_man_name);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update manufacturer name char: %d", status);
FURI_LOG_E(TAG, "Failed to update manufacturer name char: %d", status);
}
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
dev_info_svc->serial_num_char_handle,
@@ -105,7 +105,7 @@ void dev_info_svc_start() {
strlen(dev_info_serial_num),
(uint8_t*)dev_info_serial_num);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update serial number char: %d", status);
FURI_LOG_E(TAG, "Failed to update serial number char: %d", status);
}
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
dev_info_svc->firmware_rev_char_handle,
@@ -113,7 +113,7 @@ void dev_info_svc_start() {
strlen(dev_info_firmware_rev_num),
(uint8_t*)dev_info_firmware_rev_num);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update firmware revision char: %d", status);
FURI_LOG_E(TAG, "Failed to update firmware revision char: %d", status);
}
status = aci_gatt_update_char_value(dev_info_svc->service_handle,
dev_info_svc->software_rev_char_handle,
@@ -121,7 +121,7 @@ void dev_info_svc_start() {
strlen(dev_info_software_rev_num),
(uint8_t*)dev_info_software_rev_num);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to update software revision char: %d", status);
FURI_LOG_E(TAG, "Failed to update software revision char: %d", status);
}
}
@@ -131,24 +131,24 @@ void dev_info_svc_stop() {
// Delete service characteristics
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->man_name_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete manufacturer name char: %d", status);
FURI_LOG_E(TAG, "Failed to delete manufacturer name char: %d", status);
}
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->serial_num_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete serial number char: %d", status);
FURI_LOG_E(TAG, "Failed to delete serial number char: %d", status);
}
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->firmware_rev_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete firmware revision char: %d", status);
FURI_LOG_E(TAG, "Failed to delete firmware revision char: %d", status);
}
status = aci_gatt_del_char(dev_info_svc->service_handle, dev_info_svc->software_rev_char_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete software revision char: %d", status);
FURI_LOG_E(TAG, "Failed to delete software revision char: %d", status);
}
// Delete service
status = aci_gatt_del_service(dev_info_svc->service_handle);
if(status) {
FURI_LOG_E(DEV_INFO_SVC_TAG, "Failed to delete device info service: %d", status);
FURI_LOG_E(TAG, "Failed to delete device info service: %d", status);
}
free(dev_info_svc);
dev_info_svc = NULL;

View File

@@ -10,7 +10,7 @@
#include <furi-hal.h>
#define GAP_TAG "BLE"
#define TAG "BtGap"
#define FAST_ADV_TIMEOUT 30000
#define INITIAL_ADV_TIMEOUT 60000
@@ -80,7 +80,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
if (disconnection_complete_event->Connection_Handle == gap->gap_svc.connection_handle) {
gap->gap_svc.connection_handle = 0;
gap->state = GapStateIdle;
FURI_LOG_I(GAP_TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason);
FURI_LOG_I(TAG, "Disconnect from client. Reason: %d", disconnection_complete_event->Reason);
}
if(gap->enable_adv) {
// Restart advertising
@@ -96,28 +96,28 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
meta_evt = (evt_le_meta_event*) event_pckt->data;
switch (meta_evt->subevent) {
case EVT_LE_CONN_UPDATE_COMPLETE:
FURI_LOG_D(GAP_TAG, "Connection update event");
FURI_LOG_D(TAG, "Connection update event");
break;
case EVT_LE_PHY_UPDATE_COMPLETE:
evt_le_phy_update_complete = (hci_le_phy_update_complete_event_rp0*)meta_evt->data;
if(evt_le_phy_update_complete->Status) {
FURI_LOG_E(GAP_TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status);
FURI_LOG_E(TAG, "Update PHY failed, status %d", evt_le_phy_update_complete->Status);
} else {
FURI_LOG_I(GAP_TAG, "Update PHY succeed");
FURI_LOG_I(TAG, "Update PHY succeed");
}
ret = hci_le_read_phy(gap->gap_svc.connection_handle,&tx_phy,&rx_phy);
if(ret) {
FURI_LOG_E(GAP_TAG, "Read PHY failed, status: %d", ret);
FURI_LOG_E(TAG, "Read PHY failed, status: %d", ret);
} else {
FURI_LOG_I(GAP_TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy);
FURI_LOG_I(TAG, "PHY Params TX = %d, RX = %d ", tx_phy, rx_phy);
}
break;
case EVT_LE_CONN_COMPLETE:
furi_hal_power_insomnia_enter();
hci_le_connection_complete_event_rp0* connection_complete_event = (hci_le_connection_complete_event_rp0 *) meta_evt->data;
FURI_LOG_I(GAP_TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle);
FURI_LOG_I(TAG, "Connection complete for connection handle 0x%x", connection_complete_event->Connection_Handle);
// Stop advertising as connection completed
osTimerStop(gap->advertise_timer);
@@ -141,7 +141,7 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
aci_gap_pairing_complete_event_rp0 *pairing_complete;
case EVT_BLUE_GAP_LIMITED_DISCOVERABLE:
FURI_LOG_I(GAP_TAG, "Limited discoverable event");
FURI_LOG_I(TAG, "Limited discoverable event");
break;
case EVT_BLUE_GAP_PASS_KEY_REQUEST:
@@ -149,39 +149,39 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
// Generate random PIN code
uint32_t pin = rand() % 999999;
aci_gap_pass_key_resp(gap->gap_svc.connection_handle, pin);
FURI_LOG_I(GAP_TAG, "Pass key request event. Pin: %d", pin);
FURI_LOG_I(TAG, "Pass key request event. Pin: %d", pin);
BleEvent event = {.type = BleEventTypePinCodeShow, .data.pin_code = pin};
gap->on_event_cb(event, gap->context);
}
break;
case EVT_BLUE_GAP_AUTHORIZATION_REQUEST:
FURI_LOG_I(GAP_TAG, "Authorization request event");
FURI_LOG_I(TAG, "Authorization request event");
break;
case EVT_BLUE_GAP_SLAVE_SECURITY_INITIATED:
FURI_LOG_I(GAP_TAG, "Slave security initiated");
FURI_LOG_I(TAG, "Slave security initiated");
break;
case EVT_BLUE_GAP_BOND_LOST:
FURI_LOG_I(GAP_TAG, "Bond lost event. Start rebonding");
FURI_LOG_I(TAG, "Bond lost event. Start rebonding");
aci_gap_allow_rebond(gap->gap_svc.connection_handle);
break;
case EVT_BLUE_GAP_DEVICE_FOUND:
FURI_LOG_I(GAP_TAG, "Device found event");
FURI_LOG_I(TAG, "Device found event");
break;
case EVT_BLUE_GAP_ADDR_NOT_RESOLVED:
FURI_LOG_I(GAP_TAG, "Address not resolved event");
FURI_LOG_I(TAG, "Address not resolved event");
break;
case EVT_BLUE_GAP_KEYPRESS_NOTIFICATION:
FURI_LOG_I(GAP_TAG, "Key press notification event");
FURI_LOG_I(TAG, "Key press notification event");
break;
case EVT_BLUE_GAP_NUMERIC_COMPARISON_VALUE:
FURI_LOG_I(GAP_TAG, "Hex_value = %lx",
FURI_LOG_I(TAG, "Hex_value = %lx",
((aci_gap_numeric_comparison_value_event_rp0 *)(blue_evt->data))->Numeric_Value);
aci_gap_numeric_comparison_value_confirm_yesno(gap->gap_svc.connection_handle, 1);
break;
@@ -189,17 +189,17 @@ SVCCTL_UserEvtFlowStatus_t SVCCTL_App_Notification( void *pckt )
case EVT_BLUE_GAP_PAIRING_CMPLT:
pairing_complete = (aci_gap_pairing_complete_event_rp0*)blue_evt->data;
if (pairing_complete->Status) {
FURI_LOG_E(GAP_TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status);
FURI_LOG_E(TAG, "Pairing failed with status: %d. Terminating connection", pairing_complete->Status);
aci_gap_terminate(gap->gap_svc.connection_handle, 5);
} else {
FURI_LOG_I(GAP_TAG, "Pairing complete");
FURI_LOG_I(TAG, "Pairing complete");
BleEvent event = {.type = BleEventTypeConnected};
gap->on_event_cb(event, gap->context);
}
break;
case EVT_BLUE_GAP_PROCEDURE_COMPLETE:
FURI_LOG_I(GAP_TAG, "Procedure complete event");
FURI_LOG_I(TAG, "Procedure complete event");
break;
}
default:
@@ -286,11 +286,11 @@ static void gap_init_svc(Gap* gap) {
// Set GAP characteristics
status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.dev_name_char_handle, 0, strlen(name), (uint8_t *) name);
if (status) {
FURI_LOG_E(GAP_TAG, "Failed updating name characteristic: %d", status);
FURI_LOG_E(TAG, "Failed updating name characteristic: %d", status);
}
status = aci_gatt_update_char_value(gap->gap_svc.gap_svc_handle, gap->gap_svc.appearance_char_handle, 0, 2, gap_appearence_char_uuid);
if(status) {
FURI_LOG_E(GAP_TAG, "Failed updating appearence characteristic: %d", status);
FURI_LOG_E(TAG, "Failed updating appearence characteristic: %d", status);
}
// Set default PHY
hci_le_set_default_phy(ALL_PHYS_PREFERENCE, TX_2M_PREFERRED, RX_2M_PREFERRED);
@@ -322,7 +322,7 @@ static void gap_advertise_start(GapState new_state)
// Stop advertising
status = aci_gap_set_non_discoverable();
if (status) {
FURI_LOG_E(GAP_TAG, "Stop Advertising Failed, result: %d", status);
FURI_LOG_E(TAG, "Stop Advertising Failed, result: %d", status);
}
}
// Configure advertising
@@ -331,7 +331,7 @@ static void gap_advertise_start(GapState new_state)
strlen(name), (uint8_t*)name,
gap->gap_svc.adv_svc_uuid_len, gap->gap_svc.adv_svc_uuid, 0, 0);
if(status) {
FURI_LOG_E(GAP_TAG, "Set discoverable err: %d", status);
FURI_LOG_E(TAG, "Set discoverable err: %d", status);
}
gap->state = new_state;
BleEvent event = {.type = BleEventTypeStartAdvertising};
@@ -355,14 +355,14 @@ static void gap_advertise_stop() {
}
void gap_start_advertising() {
FURI_LOG_I(GAP_TAG, "Start advertising");
FURI_LOG_I(TAG, "Start advertising");
gap->enable_adv = true;
GapCommand command = GapCommandAdvFast;
furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK);
}
void gap_stop_advertising() {
FURI_LOG_I(GAP_TAG, "Stop advertising");
FURI_LOG_I(TAG, "Stop advertising");
gap->enable_adv = false;
GapCommand command = GapCommandAdvStop;
furi_check(osMessageQueuePut(gap->command_queue, &command, 0, 0) == osOK);

View File

@@ -4,7 +4,7 @@
#include <furi.h>
#define SERIAL_SERVICE_TAG "serial service"
#define TAG "BtSerialSvc"
typedef struct {
uint16_t svc_handle;
@@ -37,26 +37,26 @@ static SVCCTL_EvtAckStatus_t serial_svc_event_handler(void *event) {
if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 2) {
// Descriptor handle
ret = SVCCTL_EvtAckFlowEnable;
FURI_LOG_D(SERIAL_SERVICE_TAG, "RX descriptor event");
FURI_LOG_D(TAG, "RX descriptor event");
} else if(attribute_modified->Attr_Handle == serial_svc->rx_char_handle + 1) {
FURI_LOG_D(SERIAL_SERVICE_TAG, "Received %d bytes", attribute_modified->Attr_Data_Length);
FURI_LOG_D(TAG, "Received %d bytes", attribute_modified->Attr_Data_Length);
if(serial_svc->on_received_cb) {
furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK);
if(attribute_modified->Attr_Data_Length > serial_svc->bytes_ready_to_receive) {
FURI_LOG_W(
SERIAL_SERVICE_TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!",
TAG, "Received %d, while was ready to receive %d bytes. Can lead to buffer overflow!",
attribute_modified->Attr_Data_Length, serial_svc->bytes_ready_to_receive);
}
serial_svc->bytes_ready_to_receive -= MIN(serial_svc->bytes_ready_to_receive, attribute_modified->Attr_Data_Length);
uint32_t buff_free_size =
serial_svc->on_received_cb(attribute_modified->Attr_Data, attribute_modified->Attr_Data_Length, serial_svc->context);
FURI_LOG_D(SERIAL_SERVICE_TAG, "Available buff size: %d", buff_free_size);
FURI_LOG_D(TAG, "Available buff size: %d", buff_free_size);
furi_check(osMutexRelease(serial_svc->buff_size_mtx) == osOK);
}
ret = SVCCTL_EvtAckFlowEnable;
}
} else if(blecore_evt->ecode == ACI_GATT_SERVER_CONFIRMATION_VSEVT_CODE) {
FURI_LOG_D(SERIAL_SERVICE_TAG, "Ack received", blecore_evt->ecode);
FURI_LOG_D(TAG, "Ack received", blecore_evt->ecode);
if(serial_svc->on_sent_cb) {
serial_svc->on_sent_cb(serial_svc->context);
}
@@ -75,7 +75,7 @@ void serial_svc_start() {
// Add service
status = aci_gatt_add_service(UUID_TYPE_128, (Service_UUID_t *)service_uuid, PRIMARY_SERVICE, 10, &serial_svc->svc_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Serial service: %d", status);
FURI_LOG_E(TAG, "Failed to add Serial service: %d", status);
}
// Add RX characteristics
@@ -88,7 +88,7 @@ void serial_svc_start() {
CHAR_VALUE_LEN_VARIABLE,
&serial_svc->rx_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add RX characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to add RX characteristic: %d", status);
}
// Add TX characteristic
@@ -101,7 +101,7 @@ void serial_svc_start() {
CHAR_VALUE_LEN_VARIABLE,
&serial_svc->tx_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add TX characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to add TX characteristic: %d", status);
}
// Add Flow Control characteristic
status = aci_gatt_add_char(serial_svc->svc_handle, UUID_TYPE_128, (const Char_UUID_t*)flow_ctrl_uuid,
@@ -113,7 +113,7 @@ void serial_svc_start() {
CHAR_VALUE_LEN_CONSTANT,
&serial_svc->flow_ctrl_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to add Flow Control characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to add Flow Control characteristic: %d", status);
}
// Allocate buffer size mutex
serial_svc->buff_size_mtx = osMutexNew(NULL);
@@ -136,7 +136,7 @@ void serial_svc_notify_buffer_is_empty() {
furi_check(osMutexAcquire(serial_svc->buff_size_mtx, osWaitForever) == osOK);
if(serial_svc->bytes_ready_to_receive == 0) {
FURI_LOG_D(SERIAL_SERVICE_TAG, "Buffer is empty. Notifying client");
FURI_LOG_D(TAG, "Buffer is empty. Notifying client");
serial_svc->bytes_ready_to_receive = serial_svc->buff_size;
uint32_t buff_size_reversed = REVERSE_BYTES_U32(serial_svc->buff_size);
aci_gatt_update_char_value(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle, 0, sizeof(uint32_t), (uint8_t*)&buff_size_reversed);
@@ -150,20 +150,20 @@ void serial_svc_stop() {
// Delete characteristics
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->tx_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete TX characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to delete TX characteristic: %d", status);
}
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->rx_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete RX characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to delete RX characteristic: %d", status);
}
status = aci_gatt_del_char(serial_svc->svc_handle, serial_svc->flow_ctrl_char_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Flow Control characteristic: %d", status);
FURI_LOG_E(TAG, "Failed to delete Flow Control characteristic: %d", status);
}
// Delete service
status = aci_gatt_del_service(serial_svc->svc_handle);
if(status) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed to delete Serial service: %d", status);
FURI_LOG_E(TAG, "Failed to delete Serial service: %d", status);
}
// Delete buffer size mutex
osMutexDelete(serial_svc->buff_size_mtx);
@@ -182,7 +182,7 @@ bool serial_svc_update_tx(uint8_t* data, uint8_t data_len) {
data_len,
data);
if(result) {
FURI_LOG_E(SERIAL_SERVICE_TAG, "Failed updating TX characteristic: %d", result);
FURI_LOG_E(TAG, "Failed updating TX characteristic: %d", result);
}
return result != BLE_STATUS_SUCCESS;
}