[FL-1815, FL-1851, FL-1856] SubGhz: preparation for certification, add deleting stored signals and rename file in SubGHz app (#714)
* [FL-1811] FuriHal: move core2 startup to hal init stage, prevent working with flash controller till core2 startup finish. #704 * SubGhz: fix GO0 low on last hop transmission, decreased DutyCycle in tests * SubGhz: test_static fix max 5 sec in transmission mode, DutyCycle <23% * [FL-1815] SubGhz: prohibiting transmission if it is not within the permitted range for the given region * SubGhz: fix F7 furi-hal-subghz * SubGhz: fix logic working tests * SubGhz: fix princeton encoder for test * SubGhz: add log princeton encoder * [FL-1856] Subghz: fix output a double error if the file cannot be opened * [FL-1851] SubGhz: add deleting Stored Signals in SubGHz App * SubGhz: add rename file SubGhz app * SubGhz: update stats message in princeton * SubGhz: correct spelling * SubGhz: fix FM config, add hardware signal processing less than 16 μs, add added filter for processing short signals * SubGhz: add Scher-Khan MAGICAR Dinamic protocol * SubGhz: sync fury targets Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
		| @@ -9,6 +9,8 @@ | ||||
| struct SubghzTestCarrier { | ||||
|     View* view; | ||||
|     osTimerId timer; | ||||
|     SubghzTestCarrierCallback callback; | ||||
|     void* context; | ||||
| }; | ||||
|  | ||||
| typedef enum { | ||||
| @@ -24,6 +26,16 @@ typedef struct { | ||||
|     SubghzTestCarrierModelStatus status; | ||||
| } SubghzTestCarrierModel; | ||||
|  | ||||
| void subghz_test_carrier_set_callback( | ||||
|     SubghzTestCarrier* subghz_test_carrier, | ||||
|     SubghzTestCarrierCallback callback, | ||||
|     void* context) { | ||||
|     furi_assert(subghz_test_carrier); | ||||
|     furi_assert(callback); | ||||
|     subghz_test_carrier->callback = callback; | ||||
|     subghz_test_carrier->context = context; | ||||
| } | ||||
|  | ||||
| void subghz_test_carrier_draw(Canvas* canvas, SubghzTestCarrierModel* model) { | ||||
|     char buffer[64]; | ||||
|  | ||||
| @@ -105,7 +117,11 @@ bool subghz_test_carrier_input(InputEvent* event, void* context) { | ||||
|             } else { | ||||
|                 hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); | ||||
|                 hal_gpio_write(&gpio_cc1101_g0, true); | ||||
|                 furi_hal_subghz_tx(); | ||||
|                 if(!furi_hal_subghz_tx()) { | ||||
|                     hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow); | ||||
|                     subghz_test_carrier->callback( | ||||
|                         SubghzTestCarrierEventOnlyRx, subghz_test_carrier->context); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return true; | ||||
|   | ||||
| @@ -2,8 +2,19 @@ | ||||
|  | ||||
| #include <gui/view.h> | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestCarrierEventOnlyRx, | ||||
| } SubghzTestCarrierEvent; | ||||
|  | ||||
| typedef struct SubghzTestCarrier SubghzTestCarrier; | ||||
|  | ||||
| typedef void (*SubghzTestCarrierCallback)(SubghzTestCarrierEvent event, void* context); | ||||
|  | ||||
| void subghz_test_carrier_set_callback( | ||||
|     SubghzTestCarrier* subghz_test_carrier, | ||||
|     SubghzTestCarrierCallback callback, | ||||
|     void* context); | ||||
|  | ||||
| SubghzTestCarrier* subghz_test_carrier_alloc(); | ||||
|  | ||||
| void subghz_test_carrier_free(SubghzTestCarrier* subghz_test_carrier); | ||||
|   | ||||
| @@ -16,12 +16,14 @@ struct SubghzTestPacket { | ||||
|  | ||||
|     SubGhzDecoderPrinceton* decoder; | ||||
|     SubGhzEncoderPrinceton* encoder; | ||||
|  | ||||
|     volatile size_t packet_rx; | ||||
|     SubghzTestPacketCallback callback; | ||||
|     void* context; | ||||
| }; | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestPacketModelStatusRx, | ||||
|     SubghzTestPacketModelStatusOnlyRx, | ||||
|     SubghzTestPacketModelStatusTx, | ||||
| } SubghzTestPacketModelStatus; | ||||
|  | ||||
| @@ -36,6 +38,16 @@ typedef struct { | ||||
|  | ||||
| volatile bool subghz_test_packet_overrun = false; | ||||
|  | ||||
| void subghz_test_packet_set_callback( | ||||
|     SubghzTestPacket* subghz_test_packet, | ||||
|     SubghzTestPacketCallback callback, | ||||
|     void* context) { | ||||
|     furi_assert(subghz_test_packet); | ||||
|     furi_assert(callback); | ||||
|     subghz_test_packet->callback = callback; | ||||
|     subghz_test_packet->context = context; | ||||
| } | ||||
|  | ||||
| static void subghz_test_packet_rx_callback(bool level, uint32_t duration, void* context) { | ||||
|     furi_assert(context); | ||||
|     SubghzTestPacket* instance = context; | ||||
| @@ -57,7 +69,7 @@ static void subghz_test_packet_rssi_timer_callback(void* context) { | ||||
|             if(model->status == SubghzTestPacketModelStatusRx) { | ||||
|                 model->rssi = furi_hal_subghz_get_rssi(); | ||||
|                 model->packets = instance->packet_rx; | ||||
|             } else { | ||||
|             } else if(model->status == SubghzTestPacketModelStatusTx) { | ||||
|                 model->packets = SUBGHZ_TEST_PACKET_COUNT - | ||||
|                                  subghz_encoder_princeton_get_repeat_left(instance->encoder); | ||||
|             } | ||||
| @@ -124,7 +136,7 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { | ||||
|         instance->view, (SubghzTestPacketModel * model) { | ||||
|             if(model->status == SubghzTestPacketModelStatusRx) { | ||||
|                 furi_hal_subghz_stop_async_rx(); | ||||
|             } else { | ||||
|             } else if(model->status == SubghzTestPacketModelStatusTx) { | ||||
|                 furi_hal_subghz_stop_async_tx(); | ||||
|             } | ||||
|  | ||||
| @@ -137,10 +149,10 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { | ||||
|             } else if(event->key == InputKeyUp) { | ||||
|                 if(model->path < FuriHalSubGhzPath868) model->path++; | ||||
|             } else if(event->key == InputKeyOk) { | ||||
|                 if(model->status == SubghzTestPacketModelStatusTx) { | ||||
|                     model->status = SubghzTestPacketModelStatusRx; | ||||
|                 } else { | ||||
|                 if(model->status == SubghzTestPacketModelStatusRx) { | ||||
|                     model->status = SubghzTestPacketModelStatusTx; | ||||
|                 } else { | ||||
|                     model->status = SubghzTestPacketModelStatusRx; | ||||
|                 } | ||||
|             } | ||||
|  | ||||
| @@ -151,8 +163,13 @@ static bool subghz_test_packet_input(InputEvent* event, void* context) { | ||||
|             if(model->status == SubghzTestPacketModelStatusRx) { | ||||
|                 furi_hal_subghz_start_async_rx(subghz_test_packet_rx_callback, instance); | ||||
|             } else { | ||||
|                 subghz_encoder_princeton_set(instance->encoder, 0x00AABBCC, 1000); | ||||
|                 furi_hal_subghz_start_async_tx(subghz_encoder_princeton_yield, instance->encoder); | ||||
|                 subghz_encoder_princeton_set( | ||||
|                     instance->encoder, 0x00AABBCC, SUBGHZ_TEST_PACKET_COUNT); | ||||
|                 if(!furi_hal_subghz_start_async_tx( | ||||
|                        subghz_encoder_princeton_yield, instance->encoder)) { | ||||
|                     model->status = SubghzTestPacketModelStatusOnlyRx; | ||||
|                     instance->callback(SubghzTestPacketEventOnlyRx, instance->context); | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             return true; | ||||
| @@ -195,7 +212,7 @@ void subghz_test_packet_exit(void* context) { | ||||
|         instance->view, (SubghzTestPacketModel * model) { | ||||
|             if(model->status == SubghzTestPacketModelStatusRx) { | ||||
|                 furi_hal_subghz_stop_async_rx(); | ||||
|             } else { | ||||
|             } else if(model->status == SubghzTestPacketModelStatusTx) { | ||||
|                 furi_hal_subghz_stop_async_tx(); | ||||
|             } | ||||
|             return true; | ||||
| @@ -240,4 +257,4 @@ void subghz_test_packet_free(SubghzTestPacket* instance) { | ||||
| View* subghz_test_packet_get_view(SubghzTestPacket* instance) { | ||||
|     furi_assert(instance); | ||||
|     return instance->view; | ||||
| } | ||||
| } | ||||
| @@ -2,8 +2,19 @@ | ||||
|  | ||||
| #include <gui/view.h> | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestPacketEventOnlyRx, | ||||
| } SubghzTestPacketEvent; | ||||
|  | ||||
| typedef struct SubghzTestPacket SubghzTestPacket; | ||||
|  | ||||
| typedef void (*SubghzTestPacketCallback)(SubghzTestPacketEvent event, void* context); | ||||
|  | ||||
| void subghz_test_packet_set_callback( | ||||
|     SubghzTestPacket* subghz_test_packet, | ||||
|     SubghzTestPacketCallback callback, | ||||
|     void* context); | ||||
|  | ||||
| SubghzTestPacket* subghz_test_packet_alloc(); | ||||
|  | ||||
| void subghz_test_packet_free(SubghzTestPacket* subghz_test_packet); | ||||
|   | ||||
| @@ -8,6 +8,11 @@ | ||||
| #include <notification/notification-messages.h> | ||||
| #include <lib/subghz/protocols/subghz_protocol_princeton.h> | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestStaticStatusIDLE, | ||||
|     SubghzTestStaticStatusTX, | ||||
| } SubghzTestStaticStatus; | ||||
|  | ||||
| static const uint32_t subghz_test_static_keys[] = { | ||||
|     0x0074BADE, | ||||
|     0x0074BADD, | ||||
| @@ -17,20 +22,28 @@ static const uint32_t subghz_test_static_keys[] = { | ||||
|  | ||||
| struct SubghzTestStatic { | ||||
|     View* view; | ||||
|     SubghzTestStaticStatus satus_tx; | ||||
|     SubGhzEncoderPrinceton* encoder; | ||||
|     SubghzTestStaticCallback callback; | ||||
|     void* context; | ||||
| }; | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestStaticStatusRx, | ||||
|     SubghzTestStaticStatusTx, | ||||
| } SubghzTestStaticStatus; | ||||
|  | ||||
| typedef struct { | ||||
|     uint8_t frequency; | ||||
|     uint32_t real_frequency; | ||||
|     uint8_t button; | ||||
| } SubghzTestStaticModel; | ||||
|  | ||||
| void subghz_test_static_set_callback( | ||||
|     SubghzTestStatic* subghz_test_static, | ||||
|     SubghzTestStaticCallback callback, | ||||
|     void* context) { | ||||
|     furi_assert(subghz_test_static); | ||||
|     furi_assert(callback); | ||||
|     subghz_test_static->callback = callback; | ||||
|     subghz_test_static->context = context; | ||||
| } | ||||
|  | ||||
| void subghz_test_static_draw(Canvas* canvas, SubghzTestStaticModel* model) { | ||||
|     char buffer[64]; | ||||
|  | ||||
| @@ -79,22 +92,30 @@ bool subghz_test_static_input(InputEvent* event, void* context) { | ||||
|             if(event->key == InputKeyOk) { | ||||
|                 NotificationApp* notification = furi_record_open("notification"); | ||||
|                 if(event->type == InputTypePress) { | ||||
|                     notification_message_block(notification, &sequence_set_red_255); | ||||
|  | ||||
|                     FURI_LOG_I("SubghzTestStatic", "TX Start"); | ||||
|                     furi_hal_subghz_idle(); | ||||
|                     furi_hal_subghz_set_frequency_and_path(subghz_frequencies[model->frequency]); | ||||
|                     if(!furi_hal_subghz_tx()) { | ||||
|                         instance->callback(SubghzTestStaticEventOnlyRx, instance->context); | ||||
|                     } else { | ||||
|                         notification_message_block(notification, &sequence_set_red_255); | ||||
|  | ||||
|                     subghz_encoder_princeton_set( | ||||
|                         instance->encoder, subghz_test_static_keys[model->button], 10000); | ||||
|                         FURI_LOG_I("SubghzTestStatic", "TX Start"); | ||||
|  | ||||
|                     furi_hal_subghz_start_async_tx( | ||||
|                         subghz_encoder_princeton_yield, instance->encoder); | ||||
|                         subghz_encoder_princeton_set( | ||||
|                             instance->encoder, subghz_test_static_keys[model->button], 10000); | ||||
|  | ||||
|                         furi_hal_subghz_start_async_tx( | ||||
|                             subghz_encoder_princeton_yield, instance->encoder); | ||||
|                         instance->satus_tx = SubghzTestStaticStatusTX; | ||||
|                     } | ||||
|                 } else if(event->type == InputTypeRelease) { | ||||
|                     FURI_LOG_I("SubghzTestStatic", "TX Stop"); | ||||
|                     furi_hal_subghz_stop_async_tx(); | ||||
|  | ||||
|                     notification_message(notification, &sequence_reset_red); | ||||
|                     if(instance->satus_tx == SubghzTestStaticStatusTX) { | ||||
|                         FURI_LOG_I("SubghzTestStatic", "TX Stop"); | ||||
|                         subghz_encoder_princeton_print_log(instance->encoder); | ||||
|                         furi_hal_subghz_stop_async_tx(); | ||||
|                         notification_message(notification, &sequence_reset_red); | ||||
|                     } | ||||
|                     instance->satus_tx = SubghzTestStaticStatusIDLE; | ||||
|                 } | ||||
|                 furi_record_close("notification"); | ||||
|             } | ||||
| @@ -114,12 +135,14 @@ void subghz_test_static_enter(void* context) { | ||||
|  | ||||
|     hal_gpio_init(&gpio_cc1101_g0, GpioModeOutputPushPull, GpioPullNo, GpioSpeedLow); | ||||
|     hal_gpio_write(&gpio_cc1101_g0, false); | ||||
|     instance->satus_tx = SubghzTestStaticStatusIDLE; | ||||
|  | ||||
|     with_view_model( | ||||
|         instance->view, (SubghzTestStaticModel * model) { | ||||
|             model->frequency = subghz_frequencies_433_92; | ||||
|             model->real_frequency = subghz_frequencies[model->frequency]; | ||||
|             model->button = 0; | ||||
|  | ||||
|             return true; | ||||
|         }); | ||||
| } | ||||
| @@ -156,4 +179,4 @@ void subghz_test_static_free(SubghzTestStatic* instance) { | ||||
| View* subghz_test_static_get_view(SubghzTestStatic* instance) { | ||||
|     furi_assert(instance); | ||||
|     return instance->view; | ||||
| } | ||||
| } | ||||
| @@ -2,8 +2,19 @@ | ||||
|  | ||||
| #include <gui/view.h> | ||||
|  | ||||
| typedef enum { | ||||
|     SubghzTestStaticEventOnlyRx, | ||||
| } SubghzTestStaticEvent; | ||||
|  | ||||
| typedef struct SubghzTestStatic SubghzTestStatic; | ||||
|  | ||||
| typedef void (*SubghzTestStaticCallback)(SubghzTestStaticEvent event, void* context); | ||||
|  | ||||
| void subghz_test_static_set_callback( | ||||
|     SubghzTestStatic* subghz_test_static, | ||||
|     SubghzTestStaticCallback callback, | ||||
|     void* context); | ||||
|  | ||||
| SubghzTestStatic* subghz_test_static_alloc(); | ||||
|  | ||||
| void subghz_test_static_free(SubghzTestStatic* subghz_static); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user