Merge branch 'flipperdevices:dev' into dev

This commit is contained in:
Eng1n33r
2022-04-14 17:52:45 +03:00
committed by GitHub
149 changed files with 2368 additions and 529 deletions
+3 -3
View File
@@ -1225,7 +1225,7 @@ osStatus_t osTimerStart (osTimerId_t timer_id, uint32_t ticks) {
stat = osErrorParameter;
}
else {
if (xTimerChangePeriod (hTimer, ticks, 0) == pdPASS) {
if (xTimerChangePeriod (hTimer, ticks, portMAX_DELAY) == pdPASS) {
stat = osOK;
} else {
stat = osErrorResource;
@@ -1254,7 +1254,7 @@ osStatus_t osTimerStop (osTimerId_t timer_id) {
stat = osErrorResource;
}
else {
if (xTimerStop (hTimer, 0) == pdPASS) {
if (xTimerStop (hTimer, portMAX_DELAY) == pdPASS) {
stat = osOK;
} else {
stat = osError;
@@ -1305,7 +1305,7 @@ osStatus_t osTimerDelete (osTimerId_t timer_id) {
callb = (TimerCallback_t *)pvTimerGetTimerID (hTimer);
#endif
if (xTimerDelete (hTimer, 0) == pdPASS) {
if (xTimerDelete (hTimer, portMAX_DELAY) == pdPASS) {
#if (configSUPPORT_DYNAMIC_ALLOCATION == 1)
if ((uint32_t)callb & 1U) {
/* Callback memory was allocated from dynamic pool, clear flag */
+5 -5
View File
@@ -56,12 +56,12 @@ uint16_t mf_ul_prepare_read(uint8_t* dest, uint8_t start_page) {
void mf_ul_parse_read_response(uint8_t* buff, uint16_t page_addr, MifareUlDevice* mf_ul_read) {
uint8_t pages_read = 4;
uint8_t page_read_count = mf_ul_read->pages_readed + pages_read;
uint8_t page_read_count = mf_ul_read->pages_read + pages_read;
if(page_read_count > mf_ul_read->pages_to_read) {
pages_read -= page_read_count - mf_ul_read->pages_to_read;
}
mf_ul_read->pages_readed += pages_read;
mf_ul_read->data.data_size = mf_ul_read->pages_readed * 4;
mf_ul_read->pages_read += pages_read;
mf_ul_read->data.data_size = mf_ul_read->pages_read * 4;
memcpy(&mf_ul_read->data.data[page_addr * 4], buff, pages_read * 4);
}
@@ -77,8 +77,8 @@ void mf_ul_parse_fast_read_response(
uint8_t start_page,
uint8_t end_page,
MifareUlDevice* mf_ul_read) {
mf_ul_read->pages_readed = end_page - start_page + 1;
mf_ul_read->data.data_size = mf_ul_read->pages_readed * 4;
mf_ul_read->pages_read = end_page - start_page + 1;
mf_ul_read->data.data_size = mf_ul_read->pages_read * 4;
memcpy(mf_ul_read->data.data, buff, mf_ul_read->data.data_size);
}
+1 -1
View File
@@ -74,7 +74,7 @@ typedef struct {
typedef struct {
uint8_t pages_to_read;
uint8_t pages_readed;
uint8_t pages_read;
bool support_fast_read;
bool data_changed;
MifareUlData data;
+2 -2
View File
@@ -71,10 +71,10 @@ static bool writer_write_TM2004(iButtonWriter* writer, iButtonKey* key) {
furi_hal_delay_us(600);
writer_write_one_bit(writer, 1, 50000);
// read writed key byte
// read written key byte
answer = onewire_host_read(writer->host);
// check that writed and readed are same
// check that written and read are same
if(ibutton_key_get_data_p(key)[i] != answer) {
result = false;
break;
+5 -5
View File
@@ -95,15 +95,15 @@ void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t durati
switch(instance->decoder.parser_step) {
case KIADecoderStepReset:
if((!level) && (DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
subghz_protocol_kia_const.te_delta)) {
if((level) && (DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
subghz_protocol_kia_const.te_delta)) {
instance->decoder.parser_step = KIADecoderStepCheckPreambula;
instance->decoder.te_last = duration;
instance->header_count = 0;
}
break;
case KIADecoderStepCheckPreambula:
if(!level) {
if(level) {
if((DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
subghz_protocol_kia_const.te_delta) ||
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_long) <
@@ -139,7 +139,7 @@ void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t durati
}
break;
case KIADecoderStepSaveDuration:
if(!level) {
if(level) {
if(duration >=
(subghz_protocol_kia_const.te_long + subghz_protocol_kia_const.te_delta * 2)) {
//Found stop bit
@@ -164,7 +164,7 @@ void subghz_protocol_decoder_kia_feed(void* context, bool level, uint32_t durati
}
break;
case KIADecoderStepCheckDuration:
if(level) {
if(!level) {
if((DURATION_DIFF(instance->decoder.te_last, subghz_protocol_kia_const.te_short) <
subghz_protocol_kia_const.te_delta) &&
(DURATION_DIFF(duration, subghz_protocol_kia_const.te_short) <
+1 -3
View File
@@ -15,7 +15,7 @@
#define SUBGHZ_DOWNLOAD_MAX_SIZE 512
static const SubGhzBlockConst subghz_protocol_raw_const = {
.te_short = 80,
.te_short = 50,
.te_long = 32700,
.te_delta = 0,
.min_count_bit_for_found = 0,
@@ -223,8 +223,6 @@ void subghz_protocol_decoder_raw_feed(void* context, bool level, uint32_t durati
if(instance->upload_raw != NULL) {
if(duration > subghz_protocol_raw_const.te_short) {
if(duration > subghz_protocol_raw_const.te_long)
duration = subghz_protocol_raw_const.te_long;
if(instance->last_level != level) {
instance->last_level = (level ? true : false);
instance->upload_raw[instance->ind_write++] = (level ? duration : -duration);
-20
View File
@@ -1,25 +1,5 @@
#include "registry.h"
#include "princeton.h"
#include "keeloq.h"
#include "star_line.h"
#include "nice_flo.h"
#include "came.h"
#include "faac_slh.h"
#include "nice_flor_s.h"
#include "came_twee.h"
#include "came_atomo.h"
#include "nero_sketch.h"
#include "ido.h"
#include "kia.h"
#include "hormann.h"
#include "nero_radio.h"
#include "somfy_telis.h"
#include "somfy_keytis.h"
#include "scher_khan.h"
#include "gate_tx.h"
#include "raw.h"
const SubGhzProtocol* subghz_protocol_registry[] = {
&subghz_protocol_princeton, &subghz_protocol_keeloq, &subghz_protocol_star_line,
&subghz_protocol_nice_flo, &subghz_protocol_came, &subghz_protocol_faac_slh,
+20
View File
@@ -2,6 +2,26 @@
#include "../types.h"
#include "princeton.h"
#include "keeloq.h"
#include "star_line.h"
#include "nice_flo.h"
#include "came.h"
#include "faac_slh.h"
#include "nice_flor_s.h"
#include "came_twee.h"
#include "came_atomo.h"
#include "nero_sketch.h"
#include "ido.h"
#include "kia.h"
#include "hormann.h"
#include "nero_radio.h"
#include "somfy_telis.h"
#include "somfy_keytis.h"
#include "scher_khan.h"
#include "gate_tx.h"
#include "raw.h"
/**
* Registration by name SubGhzProtocol.
* @param name Protocol name
+3 -3
View File
@@ -207,7 +207,7 @@ void subghz_protocol_decoder_scher_khan_feed(void* context, bool level, uint32_t
*/
static void subghz_protocol_scher_khan_check_remote_controller(
SubGhzBlockGeneric* instance,
const char* protocol_name) {
const char** protocol_name) {
/*
* MAGICAR 51 bit 00000001A99121DE83C3 MAGIC CODE, Dinamic
* 0E8C1619E830C -> 000011101000110000010110 0001 1001 1110 1000001100001100
@@ -222,7 +222,7 @@ static void subghz_protocol_scher_khan_check_remote_controller(
// instance->protocol_name = "MAGIC CODE, Static";
// break;
case 51: //MAGIC CODE, Dinamic
protocol_name = "MAGIC CODE, Dinamic";
*protocol_name = "MAGIC CODE, Dinamic";
instance->serial = ((instance->data >> 24) & 0xFFFFFF0) | ((instance->data >> 20) & 0x0F);
instance->btn = (instance->data >> 24) & 0x0F;
instance->cnt = instance->data & 0xFFFF;
@@ -268,7 +268,7 @@ void subghz_protocol_decoder_scher_khan_get_string(void* context, string_t outpu
SubGhzProtocolDecoderScherKhan* instance = context;
subghz_protocol_scher_khan_check_remote_controller(
&instance->generic, instance->protocol_name);
&instance->generic, &instance->protocol_name);
string_cat_printf(
output,
+39
View File
@@ -0,0 +1,39 @@
#include "value_index.h"
uint8_t value_index_uint32(const uint32_t value, const uint32_t values[], uint8_t values_count) {
int64_t last_value = INT64_MIN;
uint8_t index = 0;
for(uint8_t i = 0; i < values_count; i++) {
if((value >= last_value) && (value <= values[i])) {
index = i;
break;
}
last_value = values[i];
}
return index;
}
uint8_t value_index_float(const float value, const float values[], uint8_t values_count) {
const float epsilon = 0.01f;
float last_value = values[0];
uint8_t index = 0;
for(uint8_t i = 0; i < values_count; i++) {
if((value >= last_value - epsilon) && (value <= values[i] + epsilon)) {
index = i;
break;
}
last_value = values[i];
}
return index;
}
uint8_t value_index_bool(const bool value, const bool values[], uint8_t values_count) {
uint8_t index = 0;
for(uint8_t i = 0; i < values_count; i++) {
if(value == values[i]) {
index = i;
break;
}
}
return index;
}
+51
View File
@@ -0,0 +1,51 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
/** Get the index of a uint32_t array element which is closest to the given value.
*
* Returned index corresponds to the first element found.
* If no suitable elements were found, the function returns 0.
*
* @param value value to be searched.
* @param values pointer to the array to perform the search in.
* @param values_count array size.
*
* @return value's index.
*/
uint8_t value_index_uint32(const uint32_t value, const uint32_t values[], uint8_t values_count);
/** Get the index of a float array element which is closest to the given value.
*
* Returned index corresponds to the first element found.
* If no suitable elements were found, the function returns 0.
*
* @param value value to be searched.
* @param values pointer to the array to perform the search in.
* @param values_count array size.
*
* @return value's index.
*/
uint8_t value_index_float(const float value, const float values[], uint8_t values_count);
/** Get the index of a bool array element which is equal to the given value.
*
* Returned index corresponds to the first element found.
* If no suitable elements were found, the function returns 0.
*
* @param value value to be searched.
* @param values pointer to the array to perform the search in.
* @param values_count array size.
*
* @return value's index.
*/
uint8_t value_index_bool(const bool value, const bool values[], uint8_t values_count);
#ifdef __cplusplus
}
#endif