Parcourir la source

Fix sending in custom presets: add PATABLE.

This is likely to avoid certain potential crashes, since the
load custom preset code *expects* a PATABLE at the end. It was not
provided so a read-after-end of the buffer regularly occurred.
antirez il y a 3 ans
Parent
commit
bc8f8a29db
2 fichiers modifiés avec 21 ajouts et 7 suppressions
  1. 7 4
      app_subghz.c
  2. 14 3
      custom_presets.h

+ 7 - 4
app_subghz.c

@@ -44,10 +44,13 @@ void radio_begin(ProtoViewApp* app) {
     /* The CC1101 preset can be either one of the standard presets, if
      * the modulation "custom" field is NULL, or a custom preset we
      * defined in custom_presets.h. */
-    if (ProtoViewModulations[app->modulation].custom == NULL)
-        furi_hal_subghz_load_preset(ProtoViewModulations[app->modulation].preset);
-    else
-        furi_hal_subghz_load_custom_preset(ProtoViewModulations[app->modulation].custom);
+    if (ProtoViewModulations[app->modulation].custom == NULL) {
+        furi_hal_subghz_load_preset(
+            ProtoViewModulations[app->modulation].preset);
+    } else {
+        furi_hal_subghz_load_custom_preset(
+            ProtoViewModulations[app->modulation].custom);
+    }
     furi_hal_gpio_init(&gpio_cc1101_g0, GpioModeInput, GpioPullNo, GpioSpeedLow);
     app->txrx->txrx_state = TxRxStateIDLE;
 }

+ 14 - 3
custom_presets.h

@@ -104,6 +104,9 @@ static uint8_t protoview_subghz_tpms1_fsk_async_regs[][2] = {
 
     /* End  */
     {0, 0},
+
+    /* CC1101 2FSK PATABLE. */
+    {0xC0, 0}, {0,0}, {0,0}, {0,0}
 };
 
 /* This is like the default Flipper OOK 640Khz bandwidth preset, but
@@ -125,8 +128,8 @@ static const uint8_t protoview_subghz_tpms2_ook_async_regs[][2] = {
     {CC1101_MDMCFG0, 0x00}, // Channel spacing is 25kHz
     {CC1101_MDMCFG1, 0x00}, // Channel spacing is 25kHz
     {CC1101_MDMCFG2, 0x30}, // Format ASK/OOK, No preamble/sync
-    {CC1101_MDMCFG3, 0x93}, // Data rate is 10kBaud
-    {CC1101_MDMCFG4, 0x18}, // Rx BW filter is 650.000kHz
+    {CC1101_MDMCFG3, /*0x93*/ 0x32}, // Data rate is 10kBaud
+    {CC1101_MDMCFG4, /*0x18*/ 0x17}, // Rx BW filter is 650.000kHz
 
     /* Main Radio Control State Machine */
     {CC1101_MCSM0, 0x18}, // Autocalibrate on idle-to-rx/tx, PO_TIMEOUT is 64 cycles(149-155us)
@@ -151,6 +154,9 @@ static const uint8_t protoview_subghz_tpms2_ook_async_regs[][2] = {
 
     /* End  */
     {0, 0},
+
+    /* CC1101 OOK PATABLE. */
+    {0, 0xC0}, {0,0}, {0,0}, {0,0}
 };
 
 /* 40 KBaud, 2FSK, 28 kHz deviation, 270 Khz bandwidth filter. */
@@ -196,6 +202,9 @@ static uint8_t protoview_subghz_tpms3_fsk_async_regs[][2] = {
 
     /* End  */
     {0, 0},
+
+    /* CC1101 2FSK PATABLE. */
+    {0xC0, 0}, {0,0}, {0,0}, {0,0}
 };
 
 /* FSK 19k dev, 325 Khz filter, 20kBaud. Works well with Toyota. */
@@ -239,6 +248,8 @@ static uint8_t protoview_subghz_tpms4_fsk_async_regs[][2] = {
 
     /* End  */
     {0, 0},
-};
 
+    /* CC1101 2FSK PATABLE. */
+    {0xC0, 0}, {0,0}, {0,0}, {0,0}
+};