[FL-2244] Companion reboot fix (#988)

* bt: don't open rpc session if it is busy
* bq27220: fix incorrect checksum calculation

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
gornekich 2022-02-09 15:03:27 +03:00 committed by GitHub
parent 2876499c4f
commit 6b78a8ccfe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 9 deletions

View File

@ -199,13 +199,18 @@ static bool bt_on_gap_event_callback(GapEvent event, void* context) {
furi_check(osMessageQueuePut(bt->message_queue, &message, 0, osWaitForever) == osOK);
if(bt->profile == BtProfileSerial) {
// Open RPC session
FURI_LOG_I(TAG, "Open RPC connection");
bt->rpc_session = rpc_session_open(bt->rpc);
if(bt->rpc_session) {
FURI_LOG_I(TAG, "Open RPC connection");
rpc_session_set_send_bytes_callback(bt->rpc_session, bt_rpc_send_bytes_callback);
rpc_session_set_buffer_is_empty_callback(
bt->rpc_session, furi_hal_bt_serial_notify_buffer_is_empty);
rpc_session_set_context(bt->rpc_session, bt);
furi_hal_bt_serial_set_event_callback(RPC_BUFFER_SIZE, bt_serial_event_callback, bt);
furi_hal_bt_serial_set_event_callback(
RPC_BUFFER_SIZE, bt_serial_event_callback, bt);
} else {
FURI_LOG_W(TAG, "RPC is busy, failed to open new session");
}
}
// Update battery level
PowerInfo info;

View File

@ -47,7 +47,7 @@ FuriHalBtProfileConfig profile_config[FuriHalBtProfileNumber] = {
.conn_int_min = 0x08,
.conn_int_max = 0x18,
.slave_latency = 0,
.supervisor_timeout = 50,
.supervisor_timeout = 0,
},
},
},

View File

@ -47,7 +47,7 @@ FuriHalBtProfileConfig profile_config[FuriHalBtProfileNumber] = {
.conn_int_min = 0x08,
.conn_int_max = 0x18,
.slave_latency = 0,
.supervisor_timeout = 50,
.supervisor_timeout = 0,
},
},
},

View File

@ -44,7 +44,7 @@ bool bq27220_set_parameter_u16(FuriHalI2cBusHandle* handle, uint16_t address, ui
delay_us(10000);
uint8_t checksum = bq27220_get_checksum(&buffer[1], 4);
uint8_t checksum = bq27220_get_checksum(buffer, 4);
buffer[0] = checksum;
buffer[1] = 6;
ret = furi_hal_i2c_write_mem(