SubGhz: Nice FlooR S improvements, cli stack overflow fix, code documentation, new key data formatting (#559)
This commit is contained in:
@@ -41,9 +41,9 @@ struct SubGhzProtocolKeeloq {
|
||||
};
|
||||
|
||||
/** Simple Learning Encrypt
|
||||
* @param data - serial number (28bit)
|
||||
* @param data - 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
|
||||
* @param key - manufacture (64bit)
|
||||
* @return ?
|
||||
* @return keelog encrypt data
|
||||
*/
|
||||
inline uint32_t subghz_protocol_keeloq_encrypt(const uint32_t data, const uint64_t key) {
|
||||
uint32_t x = data, r;
|
||||
@@ -53,9 +53,9 @@ inline uint32_t subghz_protocol_keeloq_encrypt(const uint32_t data, const uint64
|
||||
}
|
||||
|
||||
/** Simple Learning Decrypt
|
||||
* @param data - serial number (28bit)
|
||||
* @param data - keelog encrypt data
|
||||
* @param key - manufacture (64bit)
|
||||
* @return ?
|
||||
* @return 0xBSSSCCCC, B(4bit) key, S(10bit) serial&0x3FF, C(16bit) counter
|
||||
*/
|
||||
inline uint32_t subghz_protocol_keeloq_decrypt(const uint32_t data, const uint64_t key) {
|
||||
uint32_t x = data, r;
|
||||
@@ -67,7 +67,7 @@ inline uint32_t subghz_protocol_keeloq_decrypt(const uint32_t data, const uint64
|
||||
/** Normal Learning
|
||||
* @param data - serial number (28bit)
|
||||
* @param key - manufacture (64bit)
|
||||
* @return ?
|
||||
* @return manufacture for this serial number (64bit)
|
||||
*/
|
||||
inline uint64_t subghz_protocol_keeloq_normal_learning(uint32_t data, const uint64_t key){
|
||||
uint32_t k1,k2;
|
||||
@@ -116,6 +116,13 @@ void subghz_protocol_keeloq_add_manafacture_key(SubGhzProtocolKeeloq* instance,
|
||||
manufacture_code->type = type;
|
||||
}
|
||||
|
||||
/** Checking the accepted code against the database manafacture key
|
||||
*
|
||||
* @param instance SubGhzProtocolKeeloq instance
|
||||
* @param fix fix part of the parcel
|
||||
* @param hop hop encrypted part of the parcel
|
||||
* @return true on successful search
|
||||
*/
|
||||
uint8_t subghz_protocol_keeloq_check_remote_controller_selector(SubGhzProtocolKeeloq* instance, uint32_t fix , uint32_t hop) {
|
||||
uint16_t end_serial = (uint16_t)(fix&0x3FF);
|
||||
uint8_t btn = (uint8_t)(fix>>28);
|
||||
@@ -200,6 +207,10 @@ uint8_t subghz_protocol_keeloq_check_remote_controller_selector(SubGhzProtocolKe
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Analysis of received data
|
||||
*
|
||||
* @param instance SubGhzProtocolKeeloq instance
|
||||
*/
|
||||
void subghz_protocol_keeloq_check_remote_controller(SubGhzProtocolKeeloq* instance) {
|
||||
uint64_t key = subghz_protocol_common_reverse_key(instance->common.code_found, instance->common.code_count_bit);
|
||||
uint32_t key_fix = key >> 32;
|
||||
@@ -211,9 +222,16 @@ void subghz_protocol_keeloq_check_remote_controller(SubGhzProtocolKeeloq* instan
|
||||
} else {
|
||||
subghz_protocol_keeloq_check_remote_controller_selector(instance, key_fix, key_hop);
|
||||
}
|
||||
instance ->common.serial= key_fix&0x0FFFFF;
|
||||
instance->common.btn = key_fix >> 28;
|
||||
if (instance->common.callback) instance->common.callback((SubGhzProtocolCommon*)instance, instance->common.context);
|
||||
}
|
||||
|
||||
/** Send bit
|
||||
*
|
||||
* @param instance - SubGhzProtocolKeeloq instance
|
||||
* @param bit - bit
|
||||
*/
|
||||
void subghz_protocol_keeloq_send_bit(SubGhzProtocolKeeloq* instance, uint8_t bit) {
|
||||
if (bit) {
|
||||
// send bit 1
|
||||
@@ -297,8 +315,6 @@ void subghz_protocol_keeloq_parse(SubGhzProtocolKeeloq* instance, LevelPair data
|
||||
//ToDo out data display
|
||||
subghz_protocol_keeloq_check_remote_controller(instance);
|
||||
|
||||
//Print_Code(&KEELOQ);
|
||||
//Reverse_Code(KEELOQ.Code);
|
||||
instance->common.code_found = 0;
|
||||
instance->common.code_count_bit = 0;
|
||||
instance->common.header_count = 0;
|
||||
@@ -329,7 +345,6 @@ void subghz_protocol_keeloq_parse(SubGhzProtocolKeeloq* instance, LevelPair data
|
||||
}
|
||||
|
||||
void subghz_protocol_keeloq_to_str(SubGhzProtocolKeeloq* instance, string_t output) {
|
||||
//snprintf(BufTX, sizeof(BufTX),"Protocol %s: %d Bit | KEY:0x%llX HEX \n\r", common->Name_Protocol, common->Count_BIT, common->Code);
|
||||
uint32_t code_found_hi = instance->common.code_found >> 32;
|
||||
uint32_t code_found_lo = instance->common.code_found & 0x00000000ffffffff;
|
||||
|
||||
@@ -337,42 +352,26 @@ void subghz_protocol_keeloq_to_str(SubGhzProtocolKeeloq* instance, string_t outp
|
||||
|
||||
uint32_t code_found_reverse_hi = code_found_reverse>>32;
|
||||
uint32_t code_found_reverse_lo = code_found_reverse&0x00000000ffffffff;
|
||||
|
||||
if (code_found_hi>0) {
|
||||
string_cat_printf(
|
||||
output,
|
||||
"Protocol %s, %d Bit\r\n"
|
||||
" KEY:0x%lX%08lX\r\n"
|
||||
" YEK:0x%lX%08lX\r\n",
|
||||
instance->common.name,
|
||||
instance->common.code_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
code_found_reverse_hi,
|
||||
code_found_reverse_lo
|
||||
);
|
||||
} else {
|
||||
string_cat_printf(
|
||||
output,
|
||||
"Protocol %s, %d Bit\r\n"
|
||||
" KEY:0x%lX%lX\r\n"
|
||||
" YEK:0x%lX%lX\r\n",
|
||||
instance->common.name,
|
||||
instance->common.code_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
code_found_reverse_hi,
|
||||
code_found_reverse_lo
|
||||
);
|
||||
}
|
||||
string_cat_printf(
|
||||
output,
|
||||
" MF:%s FIX:%lX\r\n"
|
||||
" HOP:%lX CNT:%04X BTN:%02lX\r\n",
|
||||
instance->manufacture_name,
|
||||
"Protocol %s, %d Bit\r\n"
|
||||
"KEY:0x%lX%lX\r\n"
|
||||
"FIX:%lX MF:%s \r\n"
|
||||
"HOP:%lX \r\n"
|
||||
//"CNT:%04X BTN:%02lX\r\n",
|
||||
"SN:%05lX CNT:%04X BTN:%02lX\r\n",
|
||||
//"YEK:0x%lX%lX\r\n",
|
||||
instance->common.name,
|
||||
instance->common.code_count_bit,
|
||||
code_found_hi,
|
||||
code_found_lo,
|
||||
//code_found_reverse_hi,
|
||||
//code_found_reverse_lo
|
||||
code_found_reverse_hi,
|
||||
instance->manufacture_name,
|
||||
code_found_reverse_lo,
|
||||
instance->common.cnt, //need manufacture code
|
||||
code_found_reverse_hi >> 28
|
||||
instance->common.serial,
|
||||
instance->common.cnt,
|
||||
instance->common.btn
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user