2021-05-25 10:19:07 +00:00
|
|
|
#include "subghz_cli.h"
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-05-25 10:19:07 +00:00
|
|
|
#include <furi.h>
|
2021-08-08 18:03:25 +00:00
|
|
|
#include <furi-hal.h>
|
2021-06-29 21:19:20 +00:00
|
|
|
#include <stream_buffer.h>
|
2021-11-01 20:35:54 +00:00
|
|
|
|
2021-11-01 13:11:25 +00:00
|
|
|
#include <lib/toolbox/args.h>
|
2021-09-15 15:24:19 +00:00
|
|
|
#include <lib/subghz/subghz_parser.h>
|
2021-11-01 13:11:25 +00:00
|
|
|
#include <lib/subghz/subghz_keystore.h>
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
#include <lib/subghz/protocols/subghz_protocol_common.h>
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
#include <lib/subghz/protocols/subghz_protocol_princeton.h>
|
2021-12-01 15:44:39 +00:00
|
|
|
#include <lib/subghz/subghz_tx_rx_worker.h>
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-07-27 11:47:45 +00:00
|
|
|
#define SUBGHZ_FREQUENCY_RANGE_STR \
|
|
|
|
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
|
2021-07-18 18:09:00 +00:00
|
|
|
uint32_t frequency = 433920000;
|
2021-05-25 10:19:07 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
if(string_size(args)) {
|
|
|
|
int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
|
|
|
|
if(ret != 1) {
|
|
|
|
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
|
|
|
cli_print_usage("subghz_tx_carrier", "<Frequency in HZ>", string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-08 18:03:25 +00:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-18 18:09:00 +00:00
|
|
|
printf(
|
2021-07-27 11:47:45 +00:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-18 18:09:00 +00:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
2021-05-25 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_reset();
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 18:03:25 +00:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-05-25 10:19:07 +00:00
|
|
|
|
|
|
|
hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
2021-07-18 18:09:00 +00:00
|
|
|
hal_gpio_write(&gpio_cc1101_g0, true);
|
2021-05-25 10:19:07 +00:00
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-09-28 00:05:40 +00:00
|
|
|
if(furi_hal_subghz_tx()) {
|
|
|
|
printf("Transmitting at frequency %lu Hz\r\n", frequency);
|
|
|
|
printf("Press CTRL+C to stop\r\n");
|
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
|
|
|
osDelay(250);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("This frequency can only be used for RX in your region\r\n");
|
2021-05-25 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
|
|
furi_hal_subghz_sleep();
|
2021-10-04 07:01:41 +00:00
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_exit();
|
2021-05-25 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
|
2021-07-18 18:09:00 +00:00
|
|
|
uint32_t frequency = 433920000;
|
2021-05-25 10:19:07 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
if(string_size(args)) {
|
|
|
|
int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
|
|
|
|
if(ret != 1) {
|
|
|
|
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
|
|
|
cli_print_usage("subghz_tx_carrier", "<Frequency in HZ>", string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-08 18:03:25 +00:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-18 18:09:00 +00:00
|
|
|
printf(
|
2021-07-27 11:47:45 +00:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-18 18:09:00 +00:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
2021-05-25 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_reset();
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 18:03:25 +00:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-05-25 10:19:07 +00:00
|
|
|
printf("Receiving at frequency %lu Hz\r\n", frequency);
|
|
|
|
printf("Press CTRL+C to stop\r\n");
|
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_rx();
|
2021-05-25 10:19:07 +00:00
|
|
|
|
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
|
|
|
osDelay(250);
|
2021-08-08 18:03:25 +00:00
|
|
|
printf("RSSI: %03.1fdbm\r", furi_hal_subghz_get_rssi());
|
2021-05-25 10:19:07 +00:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
|
|
furi_hal_subghz_sleep();
|
2021-05-25 10:19:07 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
|
2021-07-15 13:54:11 +00:00
|
|
|
uint32_t frequency = 433920000;
|
|
|
|
uint32_t key = 0x0074BADE;
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
size_t repeat = 10;
|
2021-07-15 13:54:11 +00:00
|
|
|
|
|
|
|
if(string_size(args)) {
|
|
|
|
int ret = sscanf(string_get_cstr(args), "%lx %lu %u", &key, &frequency, &repeat);
|
|
|
|
if(ret != 3) {
|
|
|
|
printf(
|
|
|
|
"sscanf returned %d, key: %lx, frequency: %lu, repeat: %u\r\n",
|
|
|
|
ret,
|
|
|
|
key,
|
|
|
|
frequency,
|
|
|
|
repeat);
|
|
|
|
cli_print_usage(
|
|
|
|
"subghz_rx",
|
|
|
|
"<3 Byte Key in hex> <Frequency in HZ> <Repeat count>",
|
|
|
|
string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-08 18:03:25 +00:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-15 13:54:11 +00:00
|
|
|
printf(
|
2021-07-27 11:47:45 +00:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-15 13:54:11 +00:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
printf(
|
|
|
|
"Transmitting at %lu, key %lx, repeat %u. Press CTRL+C to stop\r\n",
|
|
|
|
frequency,
|
|
|
|
key,
|
|
|
|
repeat);
|
|
|
|
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
SubGhzDecoderPrinceton* protocol = subghz_decoder_princeton_alloc();
|
|
|
|
protocol->common.code_last_found = key;
|
|
|
|
protocol->common.code_last_count_bit = 24;
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
|
|
|
SubGhzProtocolCommonEncoder* encoder = subghz_protocol_encoder_common_alloc();
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
encoder->repeat = repeat;
|
|
|
|
|
|
|
|
subghz_protocol_princeton_send_key(protocol, encoder);
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_reset();
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 18:03:25 +00:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-10-04 07:01:41 +00:00
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
furi_hal_subghz_start_async_tx(subghz_protocol_encoder_common_yield, encoder);
|
2021-07-15 13:54:11 +00:00
|
|
|
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
while(!(furi_hal_subghz_is_async_tx_complete() || cli_cmd_interrupt_received(cli))) {
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
printf(".");
|
|
|
|
fflush(stdout);
|
|
|
|
osDelay(333);
|
|
|
|
}
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_stop_async_tx();
|
|
|
|
furi_hal_subghz_sleep();
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
SubGhz: read and save static remotes. Create new static and dynamic remotes. (#646)
* SubGhz: the functions of saving loading KeeLog have been modified, saving KeeLog is prohibited
* SubGhz: Fix displaying Nice FlorS in the Raed scene
* SubGhz: Fix displaying Faac SLH in the Raed scene
* SubGhz: Fix displaying iDo in the Raed scene
* SubGhz: Fix displaying Star Line in the Raed scene
* SubGhz: Fix displaying Nice Flo in the Raed scene, added save and load functions. (testing needed, no remote control)
* SubGhz: subghz_beginadded common encoder upload signal
* SubGhz: add Came encoder
* SubGhz: modified pricenton encoder, fix view transmitter hide the "Send" button if there is no encoder
* SubGhz: add nice flo encoder, need testing no remote control
* SubGhz: add gate_tx encoder
* SubGhz: add nero_sketch encoder
* SubGhz: add keelog encoder
* SubGhz: add long upload upload while the button is pressed while releasing the transfer is over, with a check for sticking (maximum 200 upload repetitions)
* SubGhz: fix max upload
* SubGhz: Fix structure subghz add encoder
* SubGhz: add generating and sending a dynamic keelog key, refactoring the code
* SubGhz: add notifications
* SubGhz: add creating a new remote control (Pricenton, Nice Flo 12bit, Nice Flo 24bit, CAME 12bit, CAME 24bit, Gate TX, DoorHan)
* SubGhz: Fix load file, fix scene start
* Subghz: Fix show key
* SubGhz: Fix subghz_cli
* SubGhz: Fix furi-hal-subghz
* Format sources
* SubGhz: standard notification scheme, fix broken assert in DMA.
* SubGhz: move level alignment logic to furi-hal-subghz, fix spelling, cleanup.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-16 19:56:23 +00:00
|
|
|
subghz_decoder_princeton_free(protocol);
|
|
|
|
subghz_protocol_encoder_common_free(encoder);
|
2021-06-29 21:19:20 +00:00
|
|
|
}
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
typedef struct {
|
|
|
|
volatile bool overrun;
|
|
|
|
StreamBufferHandle_t stream;
|
|
|
|
size_t packet_count;
|
|
|
|
} SubGhzCliCommandRx;
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
static void subghz_cli_command_rx_callback(bool level, uint32_t duration, void* context) {
|
|
|
|
SubGhzCliCommandRx* instance = context;
|
2021-06-29 21:19:20 +00:00
|
|
|
|
|
|
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
2021-07-07 19:49:45 +00:00
|
|
|
LevelDuration level_duration = level_duration_make(level, duration);
|
2021-07-18 18:09:00 +00:00
|
|
|
if(instance->overrun) {
|
|
|
|
instance->overrun = false;
|
2021-07-07 19:49:45 +00:00
|
|
|
level_duration = level_duration_reset();
|
2021-06-29 21:19:20 +00:00
|
|
|
}
|
2021-07-07 19:49:45 +00:00
|
|
|
size_t ret = xStreamBufferSendFromISR(
|
2021-07-18 18:09:00 +00:00
|
|
|
instance->stream, &level_duration, sizeof(LevelDuration), &xHigherPriorityTaskWoken);
|
|
|
|
if(sizeof(LevelDuration) != ret) instance->overrun = true;
|
2021-06-29 21:19:20 +00:00
|
|
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
|
|
}
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
static void subghz_cli_command_rx_text_callback(string_t text, void* context) {
|
|
|
|
SubGhzCliCommandRx* instance = context;
|
|
|
|
instance->packet_count++;
|
2021-09-21 09:34:16 +00:00
|
|
|
printf("%s", string_get_cstr(text));
|
2021-07-18 18:09:00 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
2021-06-29 21:19:20 +00:00
|
|
|
uint32_t frequency = 433920000;
|
2021-07-18 18:09:00 +00:00
|
|
|
|
2021-06-29 21:19:20 +00:00
|
|
|
if(string_size(args)) {
|
|
|
|
int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
|
|
|
|
if(ret != 1) {
|
|
|
|
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
|
|
|
cli_print_usage("subghz_rx", "<Frequency in HZ>", string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-08 18:03:25 +00:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-06-29 21:19:20 +00:00
|
|
|
printf(
|
2021-07-27 11:47:45 +00:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-06-29 21:19:20 +00:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
// Allocate context and buffers
|
|
|
|
SubGhzCliCommandRx* instance = furi_alloc(sizeof(SubGhzCliCommandRx));
|
|
|
|
instance->stream = xStreamBufferCreate(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
|
|
|
|
furi_check(instance->stream);
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-09-15 15:24:19 +00:00
|
|
|
SubGhzParser* parser = subghz_parser_alloc();
|
|
|
|
subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes");
|
2021-11-03 16:41:07 +00:00
|
|
|
subghz_parser_load_keeloq_file(parser, "/ext/subghz/keeloq_mfcodes_user");
|
|
|
|
subghz_parser_load_nice_flor_s_file(parser, "/ext/subghz/nice_flor_s_rx");
|
|
|
|
subghz_parser_load_came_atomo_file(parser, "/ext/subghz/came_atomo");
|
2021-09-15 15:24:19 +00:00
|
|
|
subghz_parser_enable_dump_text(parser, subghz_cli_command_rx_text_callback, instance);
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
// Configure radio
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_reset();
|
Skorp subghz signal archive (#667)
* SubGhz: Add millis() furi, add subghz history struct
* SubGhz: Fix subghz history
* Gubghz: Fix code repeat history, add clean history
* SubGhz: reading and adding keys to history
* Gui: Renaming Sub 1-Ghz -> SubGhz
* Archive: Renaming Sub 1-Ghz -> SubGhz
* SubGhz: Add menu history, modified button for sending a signal, changed output of data about accepted protocol
* Archive: Fix name subghz
* SubGhz: Menu navigation
* Assets: Add assets/SubGHz/icon.png
* Assets: add new icons for subghz
* SubGhz: Fix name Add manually scene
* SubGhz: Fix load icon Read scene. rename encoder struct, rename protocol function load from file, add load raw data protocol, add info pleasant signals all protocol
* SubGhz: fix memory leak
* SubGhz: change of receiving frequency for read scene
* SubGhz: Add save/load frequency and preset, add automatic configuration of transmit/receive to the desired frequency and modulation, add button "save" config scene
* SubGhz: Fix frequency and preset, fix frequency add manualli scene, fix re-executing the parser
* Furi-hal-subghz: add 2-FSK config, fix ook config 650KHz BW Tx filter
* Fix formatting and release build
* SubGhz: Delete read scene
* SubGhz: Fix frequency add manualli scene, refactoring code
* SubGhz: 2 profiles for OOK, fix broken build.
* SubGhz: Add passing static codes from read scene, add notification read scene, refactoring code
* SubGhz: fix assert on worker double stop.
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-28 13:51:48 +00:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 18:03:25 +00:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-07-18 18:09:00 +00:00
|
|
|
hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
// Prepare and start RX
|
[FL-1610] SubGhz: scene based application, PT save and replay (#630)
* SubGhz: scene based application
* SubGhz: encoder/decoder separation, DMA streaming, update app and cli.
* SubGhz: 2 stage async tx complete, minor cleanup
* SubGhz: 2 stage async tx complete, FIX state pin end transmit
* SubGhz: Pricenton, receive TE signal
* SubGhz: Pricenton, add save data, add load data
* SubGhz: Add Read scene, Fix pricenton save, load funtion
* SubGhz: Add Read, Receiver, SaveName scene
* SubGhz: Read and Save (pricenton)
* SubGhz: add Load scence
* SubGhz: Fix select file scene, add load scene, add transmitter view, add send tx pricenton
* SubGhz: Fix pricenton encoder, fix transmitter send
* SubGhz: modified Pricenton Encoder (added guard time at the beginning), modified CC1101 config, code refactoring
* SubGhz: Fix pricenton encoder defalut TE
* Archive: Fix path and name SubGhz
* Archive: Fix name app SubGhz
* GubGhz: Came: add Save, Load key
* GubGhz: GateTX: add Save, Load key
* GubGhz: NeroSketch: add Save, Load key
* Github: better linters triggers
* SubGhz: adding fast loading keys Archive -> Run in app
* GubGhz: KeeLog: add Save, Load key, key generation from the serial number of the meter and the button
* SubGhz: format sources and fix compilation
* FuriHal: add subghz configuration description for AGC section
* SubGhz: save only protocols that can be saved. Cleanup.
* Github: lint on pull requests
Co-authored-by: Aleksandr Kutuzov <alleteam@gmail.com>
2021-08-12 14:42:56 +00:00
|
|
|
furi_hal_subghz_start_async_rx(subghz_cli_command_rx_callback, instance);
|
2021-06-29 21:19:20 +00:00
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
// Wait for packets to arrive
|
2021-06-29 21:19:20 +00:00
|
|
|
printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
|
2021-07-07 19:49:45 +00:00
|
|
|
LevelDuration level_duration;
|
2021-06-29 21:19:20 +00:00
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
2021-07-18 18:09:00 +00:00
|
|
|
int ret =
|
|
|
|
xStreamBufferReceive(instance->stream, &level_duration, sizeof(LevelDuration), 10);
|
2021-07-07 19:49:45 +00:00
|
|
|
if(ret == sizeof(LevelDuration)) {
|
|
|
|
if(level_duration_is_reset(level_duration)) {
|
2021-06-29 21:19:20 +00:00
|
|
|
printf(".");
|
2021-09-15 15:24:19 +00:00
|
|
|
subghz_parser_reset(parser);
|
2021-06-29 21:19:20 +00:00
|
|
|
} else {
|
2021-07-07 19:49:45 +00:00
|
|
|
bool level = level_duration_get_level(level_duration);
|
|
|
|
uint32_t duration = level_duration_get_duration(level_duration);
|
2021-09-15 15:24:19 +00:00
|
|
|
subghz_parser_parse(parser, level, duration);
|
2021-06-29 21:19:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
// Shutdown radio
|
2021-08-08 18:03:25 +00:00
|
|
|
furi_hal_subghz_stop_async_rx();
|
|
|
|
furi_hal_subghz_sleep();
|
2021-07-18 18:09:00 +00:00
|
|
|
|
2021-10-04 07:01:41 +00:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
2021-07-18 18:09:00 +00:00
|
|
|
printf("\r\nPackets recieved %u\r\n", instance->packet_count);
|
|
|
|
|
|
|
|
// Cleanup
|
2021-09-15 15:24:19 +00:00
|
|
|
subghz_parser_free(parser);
|
2021-07-18 18:09:00 +00:00
|
|
|
vStreamBufferDelete(instance->stream);
|
|
|
|
free(instance);
|
2021-06-29 21:19:20 +00:00
|
|
|
}
|
2021-11-01 13:11:25 +00:00
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_print_usage() {
|
2021-11-01 13:11:25 +00:00
|
|
|
printf("Usage:\r\n");
|
2021-11-03 16:41:07 +00:00
|
|
|
printf("subghz <cmd> <args>\r\n");
|
2021-11-01 13:11:25 +00:00
|
|
|
printf("Cmd list:\r\n");
|
|
|
|
printf(
|
2021-11-03 16:41:07 +00:00
|
|
|
"\tencrypt_keeloq <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt keeloq manufacture keys\r\n");
|
|
|
|
printf(
|
|
|
|
"\tencrypt_raw <path_decrypted_file> <path_encrypted_file> <IV:16 bytes in hex>\t - Encrypt RAW data\r\n");
|
2021-12-01 15:44:39 +00:00
|
|
|
printf("\tchat <frequency:in Herz>\t - Chat with other Flippers\r\n");
|
2021-11-01 13:11:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
|
2021-11-01 13:11:25 +00:00
|
|
|
uint8_t iv[16];
|
|
|
|
|
|
|
|
string_t source;
|
|
|
|
string_t destination;
|
|
|
|
string_init(source);
|
|
|
|
string_init(destination);
|
|
|
|
|
|
|
|
SubGhzKeystore* keystore = subghz_keystore_alloc();
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, source)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!args_read_string_and_trim(args, destination)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!args_read_hex_bytes(args, iv, 16)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!subghz_keystore_load(keystore, string_get_cstr(source))) {
|
|
|
|
printf("Failed to load Keystore");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!subghz_keystore_save(keystore, string_get_cstr(destination), iv)) {
|
|
|
|
printf("Failed to save Keystore");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while(false);
|
|
|
|
|
|
|
|
subghz_keystore_free(keystore);
|
|
|
|
string_clear(destination);
|
|
|
|
string_clear(source);
|
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
|
2021-11-03 16:41:07 +00:00
|
|
|
uint8_t iv[16];
|
|
|
|
|
|
|
|
string_t source;
|
|
|
|
string_t destination;
|
|
|
|
string_init(source);
|
|
|
|
string_init(destination);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, source)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!args_read_string_and_trim(args, destination)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!args_read_hex_bytes(args, iv, 16)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!subghz_keystore_raw_encrypted_save(
|
|
|
|
string_get_cstr(source), string_get_cstr(destination), iv)) {
|
|
|
|
printf("Failed to save Keystore");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
} while(false);
|
|
|
|
|
|
|
|
string_clear(destination);
|
|
|
|
string_clear(source);
|
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
static void subghz_cli_command_chat(Cli* cli, string_t args) {
|
|
|
|
uint32_t frequency = 433920000;
|
|
|
|
|
|
|
|
if(string_size(args)) {
|
|
|
|
int ret = sscanf(string_get_cstr(args), "%lu", &frequency);
|
|
|
|
if(ret != 1) {
|
|
|
|
printf("sscanf returned %d, frequency: %lu\r\n", ret, frequency);
|
|
|
|
cli_print_usage("subghz_txrx", "<Frequency in HZ>", string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
|
|
|
printf(
|
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!furi_hal_subghz_is_tx_allowed(frequency)) {
|
|
|
|
printf(
|
|
|
|
"In your region, only reception on this frequency (%lu) is allowed,\r\n"
|
|
|
|
"the actual operation of the application is not possible\r\n ",
|
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SubGhzTxRxWorker* subghz_txrx = subghz_tx_rx_worker_alloc();
|
|
|
|
subghz_tx_rx_worker_start(subghz_txrx, frequency);
|
|
|
|
|
|
|
|
printf("Receiving at frequency %lu Hz\r\n", frequency);
|
|
|
|
printf("Press CTRL+C to stop\r\n");
|
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
size_t message_max_len = 64;
|
|
|
|
uint8_t message[64] = {0};
|
|
|
|
string_t input;
|
|
|
|
string_init(input);
|
|
|
|
string_t name;
|
|
|
|
string_init(name);
|
|
|
|
char c;
|
|
|
|
bool exit = false;
|
|
|
|
|
|
|
|
string_printf(name, "\033[0;33m%s\033[0m: ", furi_hal_version_get_name_ptr());
|
|
|
|
string_set(input, name);
|
|
|
|
printf("%s", string_get_cstr(input));
|
|
|
|
fflush(stdout);
|
|
|
|
|
|
|
|
while(!exit) {
|
|
|
|
if(furi_hal_vcp_rx_with_timeout((uint8_t*)&c, 1, 0) == 1) {
|
|
|
|
if(c == CliSymbolAsciiETX) {
|
|
|
|
printf("\r\n");
|
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
} else if((c >= 0x20 && c < 0x7F) || (c >= 0x80 && c < 0xF0)) {
|
|
|
|
putc(c, stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
string_push_back(input, c);
|
2021-12-02 11:19:47 +00:00
|
|
|
} else if((c == CliSymbolAsciiBackspace) || (c == CliSymbolAsciiDel)) {
|
2021-12-01 15:44:39 +00:00
|
|
|
size_t len = string_size(input);
|
|
|
|
if(len > string_size(name)) {
|
2021-12-02 11:19:47 +00:00
|
|
|
printf("%s", "\e[D\e[1P");
|
2021-12-01 15:44:39 +00:00
|
|
|
fflush(stdout);
|
2021-12-02 11:19:47 +00:00
|
|
|
string_set_strn(input, string_get_cstr(input), len - 1);
|
2021-12-01 15:44:39 +00:00
|
|
|
}
|
|
|
|
} else if(c == CliSymbolAsciiCR) {
|
|
|
|
printf("\r\n");
|
|
|
|
subghz_tx_rx_worker_write(
|
|
|
|
subghz_txrx, (uint8_t*)string_get_cstr(input), strlen(string_get_cstr(input)));
|
|
|
|
string_printf(input, "%s", string_get_cstr(name));
|
|
|
|
printf("%s", string_get_cstr(input));
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(subghz_tx_rx_worker_available(subghz_txrx)) {
|
|
|
|
memset(message, 0x00, message_max_len);
|
|
|
|
subghz_tx_rx_worker_read(subghz_txrx, message, message_max_len);
|
|
|
|
printf("\r");
|
|
|
|
for(uint8_t i = 0; i < 80; i++) {
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\r %s\r\n", message);
|
|
|
|
|
|
|
|
printf("%s", string_get_cstr(input));
|
|
|
|
fflush(stdout);
|
|
|
|
}
|
2021-12-02 11:19:47 +00:00
|
|
|
osDelay(1);
|
2021-12-01 15:44:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
printf("\r\nExit chat\r\n");
|
|
|
|
string_clear(input);
|
|
|
|
string_clear(name);
|
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
|
|
|
if(subghz_tx_rx_worker_is_running(subghz_txrx)) {
|
|
|
|
subghz_tx_rx_worker_stop(subghz_txrx);
|
|
|
|
subghz_tx_rx_worker_free(subghz_txrx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subghz_cli_command(Cli* cli, string_t args, void* context) {
|
2021-11-01 13:11:25 +00:00
|
|
|
string_t cmd;
|
|
|
|
string_init(cmd);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(string_cmp_str(cmd, "encrypt_keeloq") == 0) {
|
|
|
|
subghz_cli_command_encrypt_keeloq(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-03 16:41:07 +00:00
|
|
|
if(string_cmp_str(cmd, "encrypt_raw") == 0) {
|
|
|
|
subghz_cli_command_encrypt_raw(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-01 15:44:39 +00:00
|
|
|
if(string_cmp_str(cmd, "chat") == 0) {
|
|
|
|
subghz_cli_command_chat(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-11-01 13:11:25 +00:00
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
} while(false);
|
|
|
|
|
|
|
|
string_clear(cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
void subghz_cli_init() {
|
|
|
|
Cli* cli = furi_record_open("cli");
|
|
|
|
|
|
|
|
cli_add_command(
|
|
|
|
cli, "subghz_tx_carrier", CliCommandFlagDefault, subghz_cli_command_tx_carrier, NULL);
|
|
|
|
cli_add_command(
|
|
|
|
cli, "subghz_rx_carrier", CliCommandFlagDefault, subghz_cli_command_rx_carrier, NULL);
|
|
|
|
cli_add_command(cli, "subghz_tx", CliCommandFlagDefault, subghz_cli_command_tx, NULL);
|
|
|
|
cli_add_command(cli, "subghz_rx", CliCommandFlagDefault, subghz_cli_command_rx, NULL);
|
|
|
|
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
|
|
|
|
|
|
|
|
furi_record_close("cli");
|
|
|
|
}
|