[FL-1104] Fix NFC crash and missing NfcMessageTypeDeviceNotFound event (#400)

* Remove asserts from platformProtectST25RComm, fix issue with concurrent access.
* NFC Worker: fix bug in nfc_worker_poll causing worker to skip sending ofNfcMessageTypeDeviceNotFound event
* Fix python linter: stick to old beta
This commit is contained in:
あく 2021-04-04 13:45:55 +03:00 committed by GitHub
parent 78ff0c9fca
commit 0c3a0a3312
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 4 deletions

View File

@ -12,4 +12,4 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/setup-python@v2 - uses: actions/setup-python@v2
- uses: psf/black@stable - uses: psf/black@20.8b1

View File

@ -84,7 +84,7 @@ void nfc_worker_poll(NfcWorker* nfc_worker, uint8_t cycles) {
is_found |= nfc_worker_nfcf_poll(nfc_worker); is_found |= nfc_worker_nfcf_poll(nfc_worker);
is_found |= nfc_worker_nfcv_poll(nfc_worker); is_found |= nfc_worker_nfcv_poll(nfc_worker);
rfalFieldOff(); rfalFieldOff();
cycles--; if(cycles > 0) cycles--;
if((!is_found) && (!cycles)) { if((!is_found) && (!cycles)) {
NfcMessage message; NfcMessage message;
message.type = NfcMessageTypeDeviceNotFound; message.type = NfcMessageTypeDeviceNotFound;

View File

@ -37,6 +37,7 @@ void platformSetIrqCallback(PlatformIrqCallback callback) {
} }
HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) { HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t len) {
furi_assert(platform_st25r3916);
bool ret = false; bool ret = false;
if (txBuf && rxBuf) { if (txBuf && rxBuf) {
ret = api_hal_spi_bus_trx(platform_st25r3916->bus, (uint8_t*)txBuf, rxBuf, len, 1000); ret = api_hal_spi_bus_trx(platform_st25r3916->bus, (uint8_t*)txBuf, rxBuf, len, 1000);
@ -55,12 +56,10 @@ HAL_StatusTypeDef platformSpiTxRx(const uint8_t *txBuf, uint8_t *rxBuf, uint16_t
} }
void platformProtectST25RComm() { void platformProtectST25RComm() {
furi_assert(platform_st25r3916 == NULL);
platform_st25r3916 = (ApiHalSpiDevice*)api_hal_spi_device_get(ApiHalSpiDeviceIdNfc); platform_st25r3916 = (ApiHalSpiDevice*)api_hal_spi_device_get(ApiHalSpiDeviceIdNfc);
} }
void platformUnprotectST25RComm() { void platformUnprotectST25RComm() {
furi_assert(platform_st25r3916); furi_assert(platform_st25r3916);
api_hal_spi_device_return(platform_st25r3916); api_hal_spi_device_return(platform_st25r3916);
platform_st25r3916 = NULL;
} }