|
@@ -309,6 +309,81 @@ void subghz_cli_command_rx(Cli* cli, FuriString* args, void* context) {
|
|
|
free(instance);
|
|
free(instance);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+void subghz_cli_command_rx_raw(Cli* cli, FuriString* args, void* context) {
|
|
|
|
|
+ UNUSED(context);
|
|
|
|
|
+ uint32_t frequency = 433920000;
|
|
|
|
|
+
|
|
|
|
|
+ if(furi_string_size(args)) {
|
|
|
|
|
+ int ret = sscanf(furi_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>", furi_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;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Allocate context and buffers
|
|
|
|
|
+ SubGhzCliCommandRx* instance = malloc(sizeof(SubGhzCliCommandRx));
|
|
|
|
|
+ instance->stream =
|
|
|
|
|
+ furi_stream_buffer_alloc(sizeof(LevelDuration) * 1024, sizeof(LevelDuration));
|
|
|
|
|
+ furi_check(instance->stream);
|
|
|
|
|
+
|
|
|
|
|
+ // Configure radio
|
|
|
|
|
+ furi_hal_subghz_reset();
|
|
|
|
|
+ furi_hal_subghz_load_preset(FuriHalSubGhzPresetOok270Async);
|
|
|
|
|
+ frequency = furi_hal_subghz_set_frequency_and_path(frequency);
|
|
|
|
|
+ furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
|
|
|
|
|
+
|
|
|
|
|
+ furi_hal_power_suppress_charge_enter();
|
|
|
|
|
+
|
|
|
|
|
+ // Prepare and start RX
|
|
|
|
|
+ furi_hal_subghz_start_async_rx(subghz_cli_command_rx_capture_callback, instance);
|
|
|
|
|
+
|
|
|
|
|
+ // Wait for packets to arrive
|
|
|
|
|
+ printf("Listening at %lu. Press CTRL+C to stop\r\n", frequency);
|
|
|
|
|
+ LevelDuration level_duration;
|
|
|
|
|
+ size_t counter = 0;
|
|
|
|
|
+ while(!cli_cmd_interrupt_received(cli)) {
|
|
|
|
|
+ int ret = furi_stream_buffer_receive(
|
|
|
|
|
+ instance->stream, &level_duration, sizeof(LevelDuration), 10);
|
|
|
|
|
+ if(ret == 0) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(ret != sizeof(LevelDuration)) {
|
|
|
|
|
+ puts("stream corrupt");
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ if(level_duration_is_reset(level_duration)) {
|
|
|
|
|
+ puts(". ");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ bool level = level_duration_get_level(level_duration);
|
|
|
|
|
+ uint32_t duration = level_duration_get_duration(level_duration);
|
|
|
|
|
+ printf("%c%lu ", level ? '+' : '-', duration);
|
|
|
|
|
+ }
|
|
|
|
|
+ furi_thread_stdout_flush();
|
|
|
|
|
+ counter++;
|
|
|
|
|
+ if(counter > 255) {
|
|
|
|
|
+ puts("\r\n");
|
|
|
|
|
+ counter = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // Shutdown radio
|
|
|
|
|
+ furi_hal_subghz_stop_async_rx();
|
|
|
|
|
+ furi_hal_subghz_sleep();
|
|
|
|
|
+
|
|
|
|
|
+ furi_hal_power_suppress_charge_exit();
|
|
|
|
|
+
|
|
|
|
|
+ // Cleanup
|
|
|
|
|
+ furi_stream_buffer_free(instance->stream);
|
|
|
|
|
+ free(instance);
|
|
|
|
|
+}
|
|
|
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
|
void subghz_cli_command_decode_raw(Cli* cli, FuriString* args, void* context) {
|
|
|
UNUSED(context);
|
|
UNUSED(context);
|
|
|
FuriString* file_name;
|
|
FuriString* file_name;
|
|
@@ -431,7 +506,8 @@ static void subghz_cli_command_print_usage() {
|
|
|
printf("\tchat <frequency:in Hz>\t - Chat with other Flippers\r\n");
|
|
printf("\tchat <frequency:in Hz>\t - Chat with other Flippers\r\n");
|
|
|
printf(
|
|
printf(
|
|
|
"\ttx <3 byte Key: in hex> <frequency: in Hz> <te: us> <repeat: count>\t - Transmitting key\r\n");
|
|
"\ttx <3 byte Key: in hex> <frequency: in Hz> <te: us> <repeat: count>\t - Transmitting key\r\n");
|
|
|
- printf("\trx <frequency:in Hz>\t - Reception key\r\n");
|
|
|
|
|
|
|
+ printf("\trx <frequency:in Hz>\t - Receive\r\n");
|
|
|
|
|
+ printf("\trx_raw <frequency:in Hz>\t - Receive RAW\r\n");
|
|
|
printf("\tdecode_raw <file_name: path_RAW_file>\t - Testing\r\n");
|
|
printf("\tdecode_raw <file_name: path_RAW_file>\t - Testing\r\n");
|
|
|
|
|
|
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
if(furi_hal_rtc_is_flag_set(FuriHalRtcFlagDebug)) {
|
|
@@ -733,6 +809,11 @@ static void subghz_cli_command(Cli* cli, FuriString* args, void* context) {
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ if(furi_string_cmp_str(cmd, "rx_raw") == 0) {
|
|
|
|
|
+ subghz_cli_command_rx_raw(cli, args, context);
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
if(furi_string_cmp_str(cmd, "decode_raw") == 0) {
|
|
if(furi_string_cmp_str(cmd, "decode_raw") == 0) {
|
|
|
subghz_cli_command_decode_raw(cli, args, context);
|
|
subghz_cli_command_decode_raw(cli, args, context);
|
|
|
break;
|
|
break;
|