mirror of
https://github.com/DarkFlippers/unleashed-firmware.git
synced 2025-12-12 12:42:30 +04:00
@@ -100,7 +100,7 @@ void* subghz_protocol_encoder_nice_flor_s_alloc(SubGhzEnvironment* environment)
|
|||||||
TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name);
|
TAG, "Loading rainbow table from %s", instance->nice_flor_s_rainbow_table_file_name);
|
||||||
}
|
}
|
||||||
instance->encoder.repeat = 10;
|
instance->encoder.repeat = 10;
|
||||||
instance->encoder.size_upload = 1728; //wrong!! upload 186*16 = 2976 - actual size about 1728
|
instance->encoder.size_upload = 2400; //wrong!! upload 186*16 = 2976 - actual size about 1728
|
||||||
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
instance->encoder.upload = malloc(instance->encoder.size_upload * sizeof(LevelDuration));
|
||||||
instance->encoder.is_running = false;
|
instance->encoder.is_running = false;
|
||||||
return instance;
|
return instance;
|
||||||
@@ -113,6 +113,8 @@ void subghz_protocol_encoder_nice_flor_s_free(void* context) {
|
|||||||
free(instance);
|
free(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generating an upload from data.
|
* Generating an upload from data.
|
||||||
* @param instance Pointer to a SubGhzProtocolEncoderNiceFlorS instance
|
* @param instance Pointer to a SubGhzProtocolEncoderNiceFlorS instance
|
||||||
@@ -160,8 +162,8 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
level_duration_make(false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||||
|
|
||||||
//Send key data
|
//Send key data
|
||||||
for(uint8_t i = instance->generic.data_count_bit; i > 0; i--) {
|
for(uint8_t j = 52; j > 0; j--) {
|
||||||
if(bit_read(instance->generic.data, i - 1)) {
|
if(bit_read(instance->generic.data, j - 1)) {
|
||||||
//send bit 1
|
//send bit 1
|
||||||
instance->encoder.upload[index++] =
|
instance->encoder.upload[index++] =
|
||||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||||
@@ -175,6 +177,35 @@ static void subghz_protocol_encoder_nice_flor_s_get_upload(
|
|||||||
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(instance->generic.data_count_bit == NICE_ONE_COUNT_BIT) {
|
||||||
|
uint8_t add_data[10] = {0};
|
||||||
|
for(size_t i = 0; i < 7; i++) {
|
||||||
|
add_data[i] = (instance->generic.data >> (48 - i * 8)) & 0xFF;
|
||||||
|
}
|
||||||
|
subghz_protocol_nice_one_get_data(add_data, loops[i], loops[i]);
|
||||||
|
instance->generic.data_2 = 0;
|
||||||
|
for(size_t j = 7; j < 10; j++) {
|
||||||
|
instance->generic.data_2 <<= 8;
|
||||||
|
instance->generic.data_2 += add_data[j];
|
||||||
|
}
|
||||||
|
|
||||||
|
//Send key data
|
||||||
|
for(uint8_t j = 24; j > 4; j--) {
|
||||||
|
if(bit_read(instance->generic.data_2, j - 1)) {
|
||||||
|
//send bit 1
|
||||||
|
instance->encoder.upload[index++] = level_duration_make(
|
||||||
|
true, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||||
|
instance->encoder.upload[index++] = level_duration_make(
|
||||||
|
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||||
|
} else {
|
||||||
|
//send bit 0
|
||||||
|
instance->encoder.upload[index++] = level_duration_make(
|
||||||
|
true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short);
|
||||||
|
instance->encoder.upload[index++] = level_duration_make(
|
||||||
|
false, (uint32_t)subghz_protocol_nice_flor_s_const.te_long);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//Send stop bit
|
//Send stop bit
|
||||||
instance->encoder.upload[index++] =
|
instance->encoder.upload[index++] =
|
||||||
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
level_duration_make(true, (uint32_t)subghz_protocol_nice_flor_s_const.te_short * 3);
|
||||||
@@ -197,6 +228,8 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma
|
|||||||
//optional parameter parameter
|
//optional parameter parameter
|
||||||
flipper_format_read_uint32(
|
flipper_format_read_uint32(
|
||||||
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
flipper_format, "Repeat", (uint32_t*)&instance->encoder.repeat, 1);
|
||||||
|
// flipper_format_read_uint32(
|
||||||
|
// flipper_format, "Data", (uint32_t*)&instance->generic.data_2, 1);
|
||||||
|
|
||||||
subghz_protocol_nice_flor_s_remote_controller(
|
subghz_protocol_nice_flor_s_remote_controller(
|
||||||
&instance->generic, instance->nice_flor_s_rainbow_table_file_name);
|
&instance->generic, instance->nice_flor_s_rainbow_table_file_name);
|
||||||
@@ -216,6 +249,17 @@ bool subghz_protocol_encoder_nice_flor_s_deserialize(void* context, FlipperForma
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(instance->generic.data_count_bit == NICE_ONE_COUNT_BIT) {
|
||||||
|
if(!flipper_format_rewind(flipper_format)) {
|
||||||
|
FURI_LOG_E(TAG, "Rewind error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
uint32_t temp = (instance->generic.data_2 >> 4) & 0xFFFFF;
|
||||||
|
if(!flipper_format_update_uint32(flipper_format, "Data", &temp, 1)) {
|
||||||
|
FURI_LOG_E(TAG, "Unable to add Data");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
instance->encoder.is_running = true;
|
instance->encoder.is_running = true;
|
||||||
|
|
||||||
res = true;
|
res = true;
|
||||||
@@ -247,63 +291,63 @@ LevelDuration subghz_protocol_encoder_nice_flor_s_yield(void* context) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Read bytes from rainbow table
|
* Read bytes from rainbow table
|
||||||
// * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-P8-P9-P10
|
* @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-P8-P9-P10
|
||||||
// * @return crc
|
* @return crc
|
||||||
// */
|
*/
|
||||||
// static uint32_t subghz_protocol_nice_one_crc(uint8_t* p) {
|
static uint32_t subghz_protocol_nice_one_crc(uint8_t* p) {
|
||||||
// uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
// uint8_t crc_data = 0xff;
|
uint8_t crc_data = 0xff;
|
||||||
// for(uint8_t i = 4; i < 68; i++) {
|
for(uint8_t i = 4; i < 68; i++) {
|
||||||
// if(subghz_protocol_blocks_get_bit_array(p, i)) {
|
if(subghz_protocol_blocks_get_bit_array(p, i)) {
|
||||||
// crc = crc_data ^ 1;
|
crc = crc_data ^ 1;
|
||||||
// } else {
|
} else {
|
||||||
// crc = crc_data;
|
crc = crc_data;
|
||||||
// }
|
}
|
||||||
// crc_data >>= 1;
|
crc_data >>= 1;
|
||||||
// if((crc & 0x01)) {
|
if((crc & 0x01)) {
|
||||||
// crc_data ^= 0x97;
|
crc_data ^= 0x97;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// crc = 0;
|
crc = 0;
|
||||||
// for(uint8_t i = 0; i < 8; i++) {
|
for(uint8_t i = 0; i < 8; i++) {
|
||||||
// crc <<= 1;
|
crc <<= 1;
|
||||||
// if((crc_data >> i) & 0x01) crc = crc | 1;
|
if((crc_data >> i) & 0x01) crc = crc | 1;
|
||||||
// }
|
}
|
||||||
// return crc;
|
return crc;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * Read bytes from rainbow table
|
* Read bytes from rainbow table
|
||||||
// * @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-XX-XX-XX
|
* @param p array[10] P0-P1|P2-P3-P4-P5-P6-P7-XX-XX-XX
|
||||||
// * @param num_parcel parcel number 0..15
|
* @param num_parcel parcel number 0..15
|
||||||
// * @param hold_bit 0 - the button was only pressed, 1 - the button was held down
|
* @param hold_bit 0 - the button was only pressed, 1 - the button was held down
|
||||||
// */
|
*/
|
||||||
// static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit) {
|
static void subghz_protocol_nice_one_get_data(uint8_t* p, uint8_t num_parcel, uint8_t hold_bit) {
|
||||||
// uint8_t k = 0;
|
uint8_t k = 0;
|
||||||
// uint8_t crc = 0;
|
uint8_t crc = 0;
|
||||||
// p[1] = (p[1] & 0x0f) | ((0x0f ^ (p[0] & 0x0F) ^ num_parcel) << 4);
|
p[1] = (p[1] & 0x0f) | ((0x0f ^ (p[0] & 0x0F) ^ num_parcel) << 4);
|
||||||
// if(num_parcel < 4) {
|
if(num_parcel < 4) {
|
||||||
// k = 0x8f;
|
k = 0x8f;
|
||||||
// } else {
|
} else {
|
||||||
// k = 0x80;
|
k = 0x80;
|
||||||
// }
|
}
|
||||||
|
|
||||||
// if(!hold_bit) {
|
if(!hold_bit) {
|
||||||
// hold_bit = 0;
|
hold_bit = 0;
|
||||||
// } else {
|
} else {
|
||||||
// hold_bit = 0x10;
|
hold_bit = 0x10;
|
||||||
// }
|
}
|
||||||
// k = num_parcel ^ k;
|
k = num_parcel ^ k;
|
||||||
// p[7] = k;
|
p[7] = k;
|
||||||
// p[8] = hold_bit ^ (k << 4);
|
p[8] = hold_bit ^ (k << 4);
|
||||||
|
|
||||||
// crc = subghz_protocol_nice_one_crc(p);
|
crc = subghz_protocol_nice_one_crc(p);
|
||||||
|
|
||||||
// p[8] |= crc >> 4;
|
p[8] |= crc >> 4;
|
||||||
// p[9] = crc << 4;
|
p[9] = crc << 4;
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read bytes from rainbow table
|
* Read bytes from rainbow table
|
||||||
|
|||||||
Reference in New Issue
Block a user