2021-05-25 13:19:07 +03:00
|
|
|
#include "subghz_cli.h"
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2021-05-25 13:19:07 +03:00
|
|
|
#include <furi.h>
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <furi_hal.h>
|
2021-06-30 00:19:20 +03:00
|
|
|
#include <stream_buffer.h>
|
2021-11-01 23:35:54 +03:00
|
|
|
|
2021-11-01 16:11:25 +03:00
|
|
|
#include <lib/toolbox/args.h>
|
|
|
|
#include <lib/subghz/subghz_keystore.h>
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
#include <lib/subghz/receiver.h>
|
|
|
|
#include <lib/subghz/transmitter.h>
|
2022-04-14 15:49:29 +03:00
|
|
|
#include <lib/subghz/subghz_file_encoder_worker.h>
|
2021-12-08 16:42:01 +03:00
|
|
|
|
|
|
|
#include "helpers/subghz_chat.h"
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2022-01-05 19:10:18 +03:00
|
|
|
#include <notification/notification_messages.h>
|
2022-03-03 12:48:56 +03:00
|
|
|
#include <flipper_format/flipper_format_i.h>
|
2021-12-04 16:40:17 +03:00
|
|
|
|
2021-07-27 14:47:45 +03:00
|
|
|
#define SUBGHZ_FREQUENCY_RANGE_STR \
|
|
|
|
"299999755...348000000 or 386999938...464000000 or 778999847...928000000"
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2021-12-24 21:47:48 +03:00
|
|
|
void subghz_cli_command_tx_carrier(Cli* cli, string_t args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2021-07-18 21:09:00 +03:00
|
|
|
uint32_t frequency = 433920000;
|
2021-05-25 13:19:07 +03:00
|
|
|
|
2021-07-18 21:09:00 +03: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);
|
2021-12-25 16:19:30 +03:00
|
|
|
cli_print_usage("subghz tx_carrier", "<Frequency: in Hz>", string_get_cstr(args));
|
2021-07-18 21:09:00 +03:00
|
|
|
return;
|
|
|
|
}
|
2021-08-08 21:03:25 +03:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-18 21:09:00 +03:00
|
|
|
printf(
|
2021-07-27 14:47:45 +03:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-18 21:09:00 +03:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
2021-05-25 13:19:07 +03:00
|
|
|
}
|
|
|
|
|
2021-08-08 21:03:25 +03: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 16:51:48 +03:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 21:03:25 +03:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-05-25 13:19:07 +03:00
|
|
|
|
2022-03-30 18:23:40 +03:00
|
|
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow);
|
|
|
|
furi_hal_gpio_write(&gpio_cc1101_g0, true);
|
2021-05-25 13:19:07 +03:00
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-09-28 03:05:40 +03: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)) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(250);
|
2021-09-28 03:05:40 +03:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
printf("This frequency can only be used for RX in your region\r\n");
|
2021-05-25 13:19:07 +03:00
|
|
|
}
|
|
|
|
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
|
|
furi_hal_subghz_sleep();
|
2021-10-04 10:01:41 +03:00
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_exit();
|
2021-05-25 13:19:07 +03:00
|
|
|
}
|
|
|
|
|
2021-12-24 21:47:48 +03:00
|
|
|
void subghz_cli_command_rx_carrier(Cli* cli, string_t args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2021-07-18 21:09:00 +03:00
|
|
|
uint32_t frequency = 433920000;
|
2021-05-25 13:19:07 +03:00
|
|
|
|
2021-07-18 21:09:00 +03: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);
|
2021-12-25 16:19:30 +03:00
|
|
|
cli_print_usage("subghz rx_carrier", "<Frequency: in Hz>", string_get_cstr(args));
|
2021-07-18 21:09:00 +03:00
|
|
|
return;
|
|
|
|
}
|
2021-08-08 21:03:25 +03:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-18 21:09:00 +03:00
|
|
|
printf(
|
2021-07-27 14:47:45 +03:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-18 21:09:00 +03:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
2021-05-25 13:19:07 +03:00
|
|
|
}
|
|
|
|
|
2021-08-08 21:03:25 +03: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 16:51:48 +03:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 21:03:25 +03:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-05-25 13:19:07 +03:00
|
|
|
printf("Receiving at frequency %lu Hz\r\n", frequency);
|
|
|
|
printf("Press CTRL+C to stop\r\n");
|
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_subghz_rx();
|
2021-05-25 13:19:07 +03:00
|
|
|
|
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(250);
|
2022-05-11 12:45:01 +03:00
|
|
|
printf("RSSI: %03.1fdbm\r", (double)furi_hal_subghz_get_rssi());
|
2021-05-25 13:19:07 +03:00
|
|
|
fflush(stdout);
|
|
|
|
}
|
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_subghz_set_path(FuriHalSubGhzPathIsolate);
|
|
|
|
furi_hal_subghz_sleep();
|
2021-05-25 13:19:07 +03:00
|
|
|
}
|
|
|
|
|
2021-12-24 21:47:48 +03:00
|
|
|
void subghz_cli_command_tx(Cli* cli, string_t args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2021-07-15 16:54:11 +03:00
|
|
|
uint32_t frequency = 433920000;
|
|
|
|
uint32_t key = 0x0074BADE;
|
2021-12-05 14:47:02 +03:00
|
|
|
uint32_t repeat = 10;
|
2021-07-15 16:54:11 +03:00
|
|
|
|
|
|
|
if(string_size(args)) {
|
2021-12-05 14:47:02 +03:00
|
|
|
int ret = sscanf(string_get_cstr(args), "%lx %lu %lu", &key, &frequency, &repeat);
|
2021-07-15 16:54:11 +03:00
|
|
|
if(ret != 3) {
|
|
|
|
printf(
|
2021-12-05 14:47:02 +03:00
|
|
|
"sscanf returned %d, key: %lx, frequency: %lu, repeat: %lu\r\n",
|
2021-07-15 16:54:11 +03:00
|
|
|
ret,
|
|
|
|
key,
|
|
|
|
frequency,
|
|
|
|
repeat);
|
|
|
|
cli_print_usage(
|
2021-12-25 16:19:30 +03:00
|
|
|
"subghz tx",
|
|
|
|
"<3 Byte Key: in hex> <Frequency: in Hz> <Repeat count>",
|
2021-07-15 16:54:11 +03:00
|
|
|
string_get_cstr(args));
|
|
|
|
return;
|
|
|
|
}
|
2021-08-08 21:03:25 +03:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-07-15 16:54:11 +03:00
|
|
|
printf(
|
2021-07-27 14:47:45 +03:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-07-15 16:54:11 +03:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
printf(
|
2021-12-05 14:47:02 +03:00
|
|
|
"Transmitting at %lu, key %lx, repeat %lu. Press CTRL+C to stop\r\n",
|
2021-07-18 21:09:00 +03:00
|
|
|
frequency,
|
|
|
|
key,
|
|
|
|
repeat);
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
string_t flipper_format_string;
|
|
|
|
string_init_printf(
|
|
|
|
flipper_format_string,
|
|
|
|
"Protocol: Princeton\n"
|
|
|
|
"Bit: 24\n"
|
|
|
|
"Key: 00 00 00 00 00 %X %X %X\n"
|
|
|
|
"TE: 403\n"
|
|
|
|
"Repeat: %d\n",
|
|
|
|
(uint8_t)((key >> 16) & 0xFF),
|
|
|
|
(uint8_t)((key >> 8) & 0xFF),
|
|
|
|
(uint8_t)(key & 0xFF),
|
|
|
|
repeat);
|
|
|
|
FlipperFormat* flipper_format = flipper_format_string_alloc();
|
|
|
|
Stream* stream = flipper_format_get_raw_stream(flipper_format);
|
|
|
|
stream_clean(stream);
|
|
|
|
stream_write_cstring(stream, string_get_cstr(flipper_format_string));
|
|
|
|
|
|
|
|
SubGhzEnvironment* environment = subghz_environment_alloc();
|
[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 17:42:56 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzTransmitter* transmitter = subghz_transmitter_alloc_init(environment, "Princeton");
|
|
|
|
subghz_transmitter_deserialize(transmitter, flipper_format);
|
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 22:56:23 +03:00
|
|
|
|
2021-08-08 21:03:25 +03: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 16:51:48 +03:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 21:03:25 +03:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2021-10-04 10:01:41 +03:00
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
furi_hal_subghz_start_async_tx(subghz_transmitter_yield, transmitter);
|
2021-07-15 16:54:11 +03: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 22:56:23 +03: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 17:42:56 +03:00
|
|
|
printf(".");
|
|
|
|
fflush(stdout);
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(333);
|
[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 17:42:56 +03:00
|
|
|
}
|
2021-08-08 21:03:25 +03: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 22:56:23 +03:00
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
flipper_format_free(flipper_format);
|
|
|
|
subghz_transmitter_free(transmitter);
|
|
|
|
subghz_environment_free(environment);
|
2021-06-30 00:19:20 +03:00
|
|
|
}
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
typedef struct {
|
|
|
|
volatile bool overrun;
|
|
|
|
StreamBufferHandle_t stream;
|
|
|
|
size_t packet_count;
|
|
|
|
} SubGhzCliCommandRx;
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
static void subghz_cli_command_rx_capture_callback(bool level, uint32_t duration, void* context) {
|
2021-07-18 21:09:00 +03:00
|
|
|
SubGhzCliCommandRx* instance = context;
|
2021-06-30 00:19:20 +03:00
|
|
|
|
|
|
|
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
2021-07-07 22:49:45 +03:00
|
|
|
LevelDuration level_duration = level_duration_make(level, duration);
|
2021-07-18 21:09:00 +03:00
|
|
|
if(instance->overrun) {
|
|
|
|
instance->overrun = false;
|
2021-07-07 22:49:45 +03:00
|
|
|
level_duration = level_duration_reset();
|
2021-06-30 00:19:20 +03:00
|
|
|
}
|
2021-07-07 22:49:45 +03:00
|
|
|
size_t ret = xStreamBufferSendFromISR(
|
2021-07-18 21:09:00 +03:00
|
|
|
instance->stream, &level_duration, sizeof(LevelDuration), &xHigherPriorityTaskWoken);
|
|
|
|
if(sizeof(LevelDuration) != ret) instance->overrun = true;
|
2021-06-30 00:19:20 +03:00
|
|
|
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
|
|
|
}
|
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
static void subghz_cli_command_rx_callback(
|
|
|
|
SubGhzReceiver* receiver,
|
|
|
|
SubGhzProtocolDecoderBase* decoder_base,
|
|
|
|
void* context) {
|
2021-07-18 21:09:00 +03:00
|
|
|
SubGhzCliCommandRx* instance = context;
|
|
|
|
instance->packet_count++;
|
2022-03-03 12:48:56 +03:00
|
|
|
|
|
|
|
string_t text;
|
|
|
|
string_init(text);
|
|
|
|
subghz_protocol_decoder_base_get_string(decoder_base, text);
|
|
|
|
subghz_receiver_reset(receiver);
|
2021-09-21 12:34:16 +03:00
|
|
|
printf("%s", string_get_cstr(text));
|
2022-03-03 12:48:56 +03:00
|
|
|
string_clear(text);
|
2021-07-18 21:09:00 +03:00
|
|
|
}
|
|
|
|
|
2021-12-24 21:47:48 +03:00
|
|
|
void subghz_cli_command_rx(Cli* cli, string_t args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2021-06-30 00:19:20 +03:00
|
|
|
uint32_t frequency = 433920000;
|
2021-07-18 21:09:00 +03:00
|
|
|
|
2021-06-30 00:19:20 +03: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);
|
2021-12-25 16:19:30 +03:00
|
|
|
cli_print_usage("subghz rx", "<Frequency: in Hz>", string_get_cstr(args));
|
2021-06-30 00:19:20 +03:00
|
|
|
return;
|
|
|
|
}
|
2021-08-08 21:03:25 +03:00
|
|
|
if(!furi_hal_subghz_is_frequency_valid(frequency)) {
|
2021-06-30 00:19:20 +03:00
|
|
|
printf(
|
2021-07-27 14:47:45 +03:00
|
|
|
"Frequency must be in " SUBGHZ_FREQUENCY_RANGE_STR " range, not %lu\r\n",
|
2021-06-30 00:19:20 +03:00
|
|
|
frequency);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
// Allocate context and buffers
|
2022-02-18 22:53:46 +03:00
|
|
|
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
2021-07-18 21:09:00 +03:00
|
|
|
instance->stream = xStreamBufferCreate(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
|
|
|
|
furi_check(instance->stream);
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzEnvironment* environment = subghz_environment_alloc();
|
|
|
|
subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes");
|
[FL-2658, FL-2657] SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode) (#1404)
* Subghz: fix cli no load keeloq_mfcodes_user
* SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode)
* SubGhz: fix syntax
* SubGhz: fix error build
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 12:45:21 +03:00
|
|
|
subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes_user");
|
2022-03-03 12:48:56 +03:00
|
|
|
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
|
|
|
environment, "/ext/subghz/assets/came_atomo");
|
|
|
|
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
|
|
|
environment, "/ext/subghz/assets/nice_flor_s");
|
|
|
|
|
2022-03-16 12:18:48 +03:00
|
|
|
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
2022-03-03 12:48:56 +03:00
|
|
|
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
|
|
|
|
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
// Configure radio
|
2021-08-08 21:03:25 +03: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 16:51:48 +03:00
|
|
|
furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok650Async);
|
2021-08-08 21:03:25 +03:00
|
|
|
frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
2022-03-30 18:23:40 +03:00
|
|
|
furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_enter();
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
// Prepare and start RX
|
2022-03-03 12:48:56 +03:00
|
|
|
furi_hal_subghz_start_async_rx(subghz_cli_command_rx_capture_callback, instance);
|
2021-06-30 00:19:20 +03:00
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
// Wait for packets to arrive
|
2021-06-30 00:19:20 +03:00
|
|
|
printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
|
2021-07-07 22:49:45 +03:00
|
|
|
LevelDuration level_duration;
|
2021-06-30 00:19:20 +03:00
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
2021-07-18 21:09:00 +03:00
|
|
|
int ret =
|
|
|
|
xStreamBufferReceive(instance->stream, &level_duration, sizeof(LevelDuration), 10);
|
2021-07-07 22:49:45 +03:00
|
|
|
if(ret == sizeof(LevelDuration)) {
|
|
|
|
if(level_duration_is_reset(level_duration)) {
|
2021-06-30 00:19:20 +03:00
|
|
|
printf(".");
|
2022-03-03 12:48:56 +03:00
|
|
|
subghz_receiver_reset(receiver);
|
2021-06-30 00:19:20 +03:00
|
|
|
} else {
|
2021-07-07 22:49:45 +03:00
|
|
|
bool level = level_duration_get_level(level_duration);
|
|
|
|
uint32_t duration = level_duration_get_duration(level_duration);
|
2022-03-03 12:48:56 +03:00
|
|
|
subghz_receiver_decode(receiver, level, duration);
|
2021-06-30 00:19:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
// Shutdown radio
|
2021-08-08 21:03:25 +03:00
|
|
|
furi_hal_subghz_stop_async_rx();
|
|
|
|
furi_hal_subghz_sleep();
|
2021-07-18 21:09:00 +03:00
|
|
|
|
2021-10-04 10:01:41 +03:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
|
|
|
|
2021-07-18 21:09:00 +03:00
|
|
|
printf("\r\nPackets recieved %u\r\n", instance->packet_count);
|
|
|
|
|
|
|
|
// Cleanup
|
2022-03-03 12:48:56 +03:00
|
|
|
subghz_receiver_free(receiver);
|
|
|
|
subghz_environment_free(environment);
|
2021-07-18 21:09:00 +03:00
|
|
|
vStreamBufferDelete(instance->stream);
|
|
|
|
free(instance);
|
2021-06-30 00:19:20 +03:00
|
|
|
}
|
2021-11-01 16:11:25 +03:00
|
|
|
|
2022-04-14 15:49:29 +03:00
|
|
|
void subghz_cli_command_decode_raw(Cli* cli, string_t args, void* context) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(context);
|
2022-04-14 15:49:29 +03:00
|
|
|
string_t file_name;
|
|
|
|
string_init(file_name);
|
2022-05-27 14:19:21 +03:00
|
|
|
string_set_str(file_name, "/any/subghz/test.sub");
|
2022-04-14 15:49:29 +03:00
|
|
|
|
|
|
|
Storage* storage = furi_record_open("storage");
|
|
|
|
FlipperFormat* fff_data_file = flipper_format_file_alloc(storage);
|
|
|
|
string_t temp_str;
|
|
|
|
string_init(temp_str);
|
|
|
|
uint32_t temp_data32;
|
|
|
|
bool check_file = false;
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(string_size(args)) {
|
|
|
|
if(!args_read_string_and_trim(args, file_name)) {
|
|
|
|
cli_print_usage(
|
|
|
|
"subghz decode_raw", "<file_name: path_RAW_file>", string_get_cstr(args));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flipper_format_file_open_existing(fff_data_file, string_get_cstr(file_name))) {
|
|
|
|
printf(
|
|
|
|
"subghz decode_raw \033[0;31mError open file\033[0m %s\r\n",
|
|
|
|
string_get_cstr(file_name));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!flipper_format_read_header(fff_data_file, temp_str, &temp_data32)) {
|
|
|
|
printf("subghz decode_raw \033[0;31mMissing or incorrect header\033[0m\r\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!strcmp(string_get_cstr(temp_str), SUBGHZ_RAW_FILE_TYPE) &&
|
|
|
|
temp_data32 == SUBGHZ_KEY_FILE_VERSION) {
|
|
|
|
} else {
|
|
|
|
printf("subghz decode_raw \033[0;31mType or version mismatch\033[0m\r\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
check_file = true;
|
|
|
|
} while(false);
|
|
|
|
|
|
|
|
string_clear(temp_str);
|
|
|
|
flipper_format_free(fff_data_file);
|
|
|
|
furi_record_close("storage");
|
|
|
|
|
|
|
|
if(check_file) {
|
|
|
|
// Allocate context
|
|
|
|
SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
|
|
|
|
|
|
|
SubGhzEnvironment* environment = subghz_environment_alloc();
|
|
|
|
if(subghz_environment_load_keystore(environment, "/ext/subghz/assets/keeloq_mfcodes")) {
|
[FL-2658, FL-2657] SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode) (#1404)
* Subghz: fix cli no load keeloq_mfcodes_user
* SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode)
* SubGhz: fix syntax
* SubGhz: fix error build
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 12:45:21 +03:00
|
|
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;32mOK\033[0m\r\n");
|
2022-04-14 15:49:29 +03:00
|
|
|
} else {
|
[FL-2658, FL-2657] SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode) (#1404)
* Subghz: fix cli no load keeloq_mfcodes_user
* SubGhz: add new protocol (IronLogic, Comunello, Sommer(fsk476), Normstahl, KEY, EcoStar, Gibidi, Mutancode)
* SubGhz: fix syntax
* SubGhz: fix error build
Co-authored-by: あく <alleteam@gmail.com>
2022-07-17 12:45:21 +03:00
|
|
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes \033[0;31mERROR\033[0m\r\n");
|
|
|
|
}
|
|
|
|
if(subghz_environment_load_keystore(
|
|
|
|
environment, "/ext/subghz/assets/keeloq_mfcodes_user")) {
|
|
|
|
printf("SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;32mOK\033[0m\r\n");
|
|
|
|
} else {
|
|
|
|
printf(
|
|
|
|
"SubGhz decode_raw: Load_keystore keeloq_mfcodes_user \033[0;31mERROR\033[0m\r\n");
|
2022-04-14 15:49:29 +03:00
|
|
|
}
|
|
|
|
subghz_environment_set_came_atomo_rainbow_table_file_name(
|
|
|
|
environment, "/ext/subghz/assets/came_atomo");
|
|
|
|
subghz_environment_set_nice_flor_s_rainbow_table_file_name(
|
|
|
|
environment, "/ext/subghz/assets/nice_flor_s");
|
|
|
|
|
|
|
|
SubGhzReceiver* receiver = subghz_receiver_alloc_init(environment);
|
|
|
|
subghz_receiver_set_filter(receiver, SubGhzProtocolFlag_Decodable);
|
|
|
|
subghz_receiver_set_rx_callback(receiver, subghz_cli_command_rx_callback, instance);
|
|
|
|
|
|
|
|
SubGhzFileEncoderWorker* file_worker_encoder = subghz_file_encoder_worker_alloc();
|
|
|
|
if(subghz_file_encoder_worker_start(file_worker_encoder, string_get_cstr(file_name))) {
|
|
|
|
//the worker needs a file in order to open and read part of the file
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(100);
|
2022-04-14 15:49:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
printf(
|
|
|
|
"Listening at \033[0;33m%s\033[0m.\r\n\r\nPress CTRL+C to stop\r\n\r\n",
|
|
|
|
string_get_cstr(file_name));
|
|
|
|
|
|
|
|
LevelDuration level_duration;
|
|
|
|
while(!cli_cmd_interrupt_received(cli)) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_us(500); //you need to have time to read from the file from the SD card
|
2022-04-14 15:49:29 +03:00
|
|
|
level_duration = subghz_file_encoder_worker_get_level_duration(file_worker_encoder);
|
|
|
|
if(!level_duration_is_reset(level_duration)) {
|
|
|
|
bool level = level_duration_get_level(level_duration);
|
|
|
|
uint32_t duration = level_duration_get_duration(level_duration);
|
|
|
|
subghz_receiver_decode(receiver, level, duration);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\r\nPackets recieved \033[0;32m%u\033[0m\r\n", instance->packet_count);
|
|
|
|
|
|
|
|
// Cleanup
|
|
|
|
subghz_receiver_free(receiver);
|
|
|
|
subghz_environment_free(environment);
|
|
|
|
|
|
|
|
if(subghz_file_encoder_worker_is_running(file_worker_encoder)) {
|
|
|
|
subghz_file_encoder_worker_stop(file_worker_encoder);
|
|
|
|
}
|
|
|
|
subghz_file_encoder_worker_free(file_worker_encoder);
|
|
|
|
free(instance);
|
|
|
|
}
|
|
|
|
string_clear(file_name);
|
|
|
|
}
|
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
static void subghz_cli_command_print_usage() {
|
2021-11-01 16:11:25 +03:00
|
|
|
printf("Usage:\r\n");
|
2021-11-03 19:41:07 +03:00
|
|
|
printf("subghz <cmd> <args>\r\n");
|
2021-11-01 16:11:25 +03:00
|
|
|
printf("Cmd list:\r\n");
|
2021-12-25 16:19:30 +03:00
|
|
|
|
|
|
|
printf("\tchat <frequency:in Hz>\t - Chat with other Flippers\r\n");
|
2021-11-01 16:11:25 +03:00
|
|
|
printf(
|
2021-12-25 16:19:30 +03:00
|
|
|
"\ttx <3 byte Key: in hex> <frequency: in Hz> <repeat: count>\t - Transmitting key\r\n");
|
|
|
|
printf("\trx <frequency:in Hz>\t - Reception key\r\n");
|
2022-04-14 15:49:29 +03:00
|
|
|
printf("\tdecode_raw <file_name: path_RAW_file>\t - Testing\r\n");
|
2021-12-25 16:19:30 +03:00
|
|
|
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
printf("\r\n");
|
|
|
|
printf(" debug cmd:\r\n");
|
|
|
|
printf("\ttx_carrier <frequency:in Hz>\t - Transmit carrier\r\n");
|
|
|
|
printf("\trx_carrier <frequency:in Hz>\t - Receiv carrier\r\n");
|
|
|
|
printf(
|
|
|
|
"\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-11-01 16:11:25 +03:00
|
|
|
}
|
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
static void subghz_cli_command_encrypt_keeloq(Cli* cli, string_t args) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(cli);
|
2021-11-01 16:11:25 +03: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 18:44:39 +03:00
|
|
|
static void subghz_cli_command_encrypt_raw(Cli* cli, string_t args) {
|
2022-05-06 16:37:10 +03:00
|
|
|
UNUSED(cli);
|
2021-11-03 19:41:07 +03: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 18:44:39 +03: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);
|
2021-12-25 16:19:30 +03:00
|
|
|
cli_print_usage("subghz chat", "<Frequency: in Hz>", string_get_cstr(args));
|
2021-12-01 18:44:39 +03:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-04-29 15:02:17 +03:00
|
|
|
SubGhzChatWorker* subghz_chat = subghz_chat_worker_alloc(cli);
|
2021-12-08 16:42:01 +03:00
|
|
|
if(!subghz_chat_worker_start(subghz_chat, frequency)) {
|
|
|
|
printf("Startup error SubGhzChatWorker\r\n");
|
|
|
|
|
|
|
|
if(subghz_chat_worker_is_running(subghz_chat)) {
|
|
|
|
subghz_chat_worker_stop(subghz_chat);
|
|
|
|
subghz_chat_worker_free(subghz_chat);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2021-12-01 18:44:39 +03:00
|
|
|
|
|
|
|
printf("Receiving at frequency %lu Hz\r\n", frequency);
|
|
|
|
printf("Press CTRL+C to stop\r\n");
|
|
|
|
|
|
|
|
furi_hal_power_suppress_charge_enter();
|
2021-12-08 16:42:01 +03:00
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
size_t message_max_len = 64;
|
|
|
|
uint8_t message[64] = {0};
|
|
|
|
string_t input;
|
|
|
|
string_init(input);
|
|
|
|
string_t name;
|
|
|
|
string_init(name);
|
2021-12-08 16:42:01 +03:00
|
|
|
string_t output;
|
|
|
|
string_init(output);
|
2021-12-04 16:40:17 +03:00
|
|
|
string_t sysmsg;
|
|
|
|
string_init(sysmsg);
|
2021-12-01 18:44:39 +03:00
|
|
|
bool exit = false;
|
2022-03-03 12:48:56 +03:00
|
|
|
SubGhzChatEvent chat_event;
|
2021-12-01 18:44:39 +03:00
|
|
|
|
2021-12-04 16:40:17 +03:00
|
|
|
NotificationApp* notification = furi_record_open("notification");
|
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
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) {
|
2021-12-08 16:42:01 +03:00
|
|
|
chat_event = subghz_chat_worker_get_event_chat(subghz_chat);
|
|
|
|
switch(chat_event.event) {
|
2022-03-03 12:48:56 +03:00
|
|
|
case SubGhzChatEventInputData:
|
2021-12-08 16:42:01 +03:00
|
|
|
if(chat_event.c == CliSymbolAsciiETX) {
|
2021-12-01 18:44:39 +03:00
|
|
|
printf("\r\n");
|
2022-03-03 12:48:56 +03:00
|
|
|
chat_event.event = SubGhzChatEventUserExit;
|
2021-12-08 16:42:01 +03:00
|
|
|
subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
|
2021-12-01 18:44:39 +03:00
|
|
|
break;
|
2021-12-08 16:42:01 +03:00
|
|
|
} else if(
|
|
|
|
(chat_event.c == CliSymbolAsciiBackspace) || (chat_event.c == CliSymbolAsciiDel)) {
|
|
|
|
size_t len = string_length_u(input);
|
|
|
|
if(len > string_length_u(name)) {
|
2021-12-02 14:19:47 +03:00
|
|
|
printf("%s", "\e[D\e[1P");
|
2021-12-01 18:44:39 +03:00
|
|
|
fflush(stdout);
|
2021-12-08 16:42:01 +03:00
|
|
|
//delete 1 char UTF
|
|
|
|
const char* str = string_get_cstr(input);
|
|
|
|
size_t size = 0;
|
|
|
|
m_str1ng_utf8_state_e s = M_STRING_UTF8_STARTING;
|
|
|
|
string_unicode_t u = 0;
|
|
|
|
string_reset(sysmsg);
|
|
|
|
while(*str) {
|
|
|
|
m_str1ng_utf8_decode(*str, &s, &u);
|
|
|
|
if((s == M_STRING_UTF8_ERROR) || s == M_STRING_UTF8_STARTING) {
|
|
|
|
string_push_u(sysmsg, u);
|
|
|
|
if(++size >= len - 1) break;
|
|
|
|
s = M_STRING_UTF8_STARTING;
|
|
|
|
}
|
|
|
|
str++;
|
|
|
|
}
|
|
|
|
string_set(input, sysmsg);
|
2021-12-01 18:44:39 +03:00
|
|
|
}
|
2021-12-08 16:42:01 +03:00
|
|
|
} else if(chat_event.c == CliSymbolAsciiCR) {
|
2021-12-01 18:44:39 +03:00
|
|
|
printf("\r\n");
|
2021-12-08 16:42:01 +03:00
|
|
|
string_push_back(input, '\r');
|
|
|
|
string_push_back(input, '\n');
|
|
|
|
while(!subghz_chat_worker_write(
|
|
|
|
subghz_chat,
|
|
|
|
(uint8_t*)string_get_cstr(input),
|
|
|
|
strlen(string_get_cstr(input)))) {
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(10);
|
2021-12-08 16:42:01 +03:00
|
|
|
}
|
|
|
|
|
2021-12-01 18:44:39 +03:00
|
|
|
string_printf(input, "%s", string_get_cstr(name));
|
|
|
|
printf("%s", string_get_cstr(input));
|
|
|
|
fflush(stdout);
|
2021-12-08 16:42:01 +03:00
|
|
|
} else if(chat_event.c == CliSymbolAsciiLF) {
|
|
|
|
//cut out the symbol \n
|
|
|
|
} else {
|
|
|
|
putc(chat_event.c, stdout);
|
|
|
|
fflush(stdout);
|
|
|
|
string_push_back(input, chat_event.c);
|
|
|
|
break;
|
2022-03-03 12:48:56 +03:00
|
|
|
case SubGhzChatEventRXData:
|
2021-12-08 16:42:01 +03:00
|
|
|
do {
|
|
|
|
memset(message, 0x00, message_max_len);
|
|
|
|
size_t len = subghz_chat_worker_read(subghz_chat, message, message_max_len);
|
|
|
|
for(size_t i = 0; i < len; i++) {
|
|
|
|
string_push_back(output, message[i]);
|
|
|
|
if(message[i] == '\n') {
|
|
|
|
printf("\r");
|
|
|
|
for(uint8_t i = 0; i < 80; i++) {
|
|
|
|
printf(" ");
|
|
|
|
}
|
|
|
|
printf("\r %s", string_get_cstr(output));
|
|
|
|
printf("%s", string_get_cstr(input));
|
|
|
|
fflush(stdout);
|
|
|
|
string_reset(output);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(subghz_chat_worker_available(subghz_chat));
|
|
|
|
break;
|
2022-03-03 12:48:56 +03:00
|
|
|
case SubGhzChatEventNewMessage:
|
2021-12-08 16:42:01 +03:00
|
|
|
notification_message(notification, &sequence_single_vibro);
|
|
|
|
break;
|
2022-03-03 12:48:56 +03:00
|
|
|
case SubGhzChatEventUserEntrance:
|
2021-12-08 16:42:01 +03:00
|
|
|
string_printf(
|
|
|
|
sysmsg,
|
|
|
|
"\033[0;34m%s joined chat.\033[0m\r\n",
|
|
|
|
furi_hal_version_get_name_ptr());
|
|
|
|
subghz_chat_worker_write(
|
|
|
|
subghz_chat,
|
|
|
|
(uint8_t*)string_get_cstr(sysmsg),
|
|
|
|
strlen(string_get_cstr(sysmsg)));
|
|
|
|
break;
|
2022-03-03 12:48:56 +03:00
|
|
|
case SubGhzChatEventUserExit:
|
2021-12-08 16:42:01 +03:00
|
|
|
string_printf(
|
|
|
|
sysmsg, "\033[0;31m%s left chat.\033[0m\r\n", furi_hal_version_get_name_ptr());
|
|
|
|
subghz_chat_worker_write(
|
|
|
|
subghz_chat,
|
|
|
|
(uint8_t*)string_get_cstr(sysmsg),
|
|
|
|
strlen(string_get_cstr(sysmsg)));
|
2022-07-20 13:56:33 +03:00
|
|
|
furi_delay_ms(10);
|
2021-12-08 16:42:01 +03:00
|
|
|
exit = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FURI_LOG_W("SubGhzChat", "Error event");
|
|
|
|
break;
|
2021-12-01 18:44:39 +03:00
|
|
|
}
|
|
|
|
}
|
2022-07-25 14:48:06 +03:00
|
|
|
if(!cli_is_connected(cli)) {
|
2022-07-23 06:35:14 +03:00
|
|
|
printf("\r\n");
|
|
|
|
chat_event.event = SubGhzChatEventUserExit;
|
|
|
|
subghz_chat_worker_put_event_chat(subghz_chat, &chat_event);
|
|
|
|
}
|
2021-12-01 18:44:39 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
string_clear(input);
|
|
|
|
string_clear(name);
|
2021-12-08 16:42:01 +03:00
|
|
|
string_clear(output);
|
2021-12-04 16:40:17 +03:00
|
|
|
string_clear(sysmsg);
|
2021-12-01 18:44:39 +03:00
|
|
|
furi_hal_power_suppress_charge_exit();
|
2021-12-04 16:40:17 +03:00
|
|
|
furi_record_close("notification");
|
2021-12-01 18:44:39 +03:00
|
|
|
|
2021-12-08 16:42:01 +03:00
|
|
|
if(subghz_chat_worker_is_running(subghz_chat)) {
|
|
|
|
subghz_chat_worker_stop(subghz_chat);
|
|
|
|
subghz_chat_worker_free(subghz_chat);
|
2021-12-01 18:44:39 +03:00
|
|
|
}
|
2021-12-08 16:42:01 +03:00
|
|
|
printf("\r\nExit chat\r\n");
|
2021-12-01 18:44:39 +03:00
|
|
|
}
|
|
|
|
|
2022-04-13 23:50:25 +03:00
|
|
|
static void subghz_cli_command(Cli* cli, string_t args, void* context) {
|
2021-11-01 16:11:25 +03:00
|
|
|
string_t cmd;
|
|
|
|
string_init(cmd);
|
|
|
|
|
|
|
|
do {
|
|
|
|
if(!args_read_string_and_trim(args, cmd)) {
|
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-25 16:19:30 +03:00
|
|
|
if(string_cmp_str(cmd, "chat") == 0) {
|
|
|
|
subghz_cli_command_chat(cli, args);
|
2021-11-01 16:11:25 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-25 16:19:30 +03:00
|
|
|
if(string_cmp_str(cmd, "tx") == 0) {
|
|
|
|
subghz_cli_command_tx(cli, args, context);
|
2021-11-03 19:41:07 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-25 16:19:30 +03:00
|
|
|
if(string_cmp_str(cmd, "rx") == 0) {
|
|
|
|
subghz_cli_command_rx(cli, args, context);
|
2021-12-01 18:44:39 +03:00
|
|
|
break;
|
|
|
|
}
|
2022-04-14 15:49:29 +03:00
|
|
|
|
|
|
|
if(string_cmp_str(cmd, "decode_raw") == 0) {
|
|
|
|
subghz_cli_command_decode_raw(cli, args, context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2021-12-25 16:19:30 +03:00
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
|
|
if(string_cmp_str(cmd, "encrypt_keeloq") == 0) {
|
|
|
|
subghz_cli_command_encrypt_keeloq(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(string_cmp_str(cmd, "encrypt_raw") == 0) {
|
|
|
|
subghz_cli_command_encrypt_raw(cli, args);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(string_cmp_str(cmd, "tx_carrier") == 0) {
|
|
|
|
subghz_cli_command_tx_carrier(cli, args, context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(string_cmp_str(cmd, "rx_carrier") == 0) {
|
|
|
|
subghz_cli_command_rx_carrier(cli, args, context);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2021-12-01 18:44:39 +03:00
|
|
|
|
2021-11-01 16:11:25 +03:00
|
|
|
subghz_cli_command_print_usage();
|
|
|
|
} while(false);
|
|
|
|
|
|
|
|
string_clear(cmd);
|
|
|
|
}
|
|
|
|
|
2021-12-24 21:47:48 +03:00
|
|
|
void subghz_on_system_start() {
|
|
|
|
#ifdef SRV_CLI
|
2021-11-01 16:11:25 +03:00
|
|
|
Cli* cli = furi_record_open("cli");
|
|
|
|
|
|
|
|
cli_add_command(cli, "subghz", CliCommandFlagDefault, subghz_cli_command, NULL);
|
|
|
|
|
|
|
|
furi_record_close("cli");
|
2022-04-13 23:50:25 +03:00
|
|
|
#else
|
|
|
|
UNUSED(subghz_cli_command);
|
2021-12-24 21:47:48 +03:00
|
|
|
#endif
|
2021-11-01 16:11:25 +03:00
|
|
|
}
|