Skip to content

Commit 0fedbb1

Browse files
authored
Merge pull request #8 from ElectronicCats/meshtastic_sniffer
Meshtastic presets
2 parents baa552c + 1854b31 commit 0fedbb1

File tree

9 files changed

+6765
-66
lines changed

9 files changed

+6765
-66
lines changed

applications_user/lora_app/assets_icons.c

Lines changed: 5039 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
#pragma once
2+
3+
#include <gui/icon.h>
4+
5+
extern const Icon I_Certification1_103x56;
6+
extern const Icon I_Certification2_46x33;
7+
extern const Icon I_CertificationChina0_121x41;
8+
extern const Icon I_CertificationChina1_124x47;
9+
extern const Icon I_CertificationMexico_98x41;
10+
extern const Icon I_CertificationTaiwan_33x32;
11+
extern const Icon A_Levelup1_128x64;
12+
extern const Icon A_Levelup2_128x64;
13+
extern const Icon I_125_10px;
14+
extern const Icon I_Nfc_10px;
15+
extern const Icon I_back_10px;
16+
extern const Icon I_badusb_10px;
17+
extern const Icon I_dir_10px;
18+
extern const Icon I_file_10px;
19+
extern const Icon I_ibutt_10px;
20+
extern const Icon I_ir_10px;
21+
extern const Icon I_js_script_10px;
22+
extern const Icon I_keyboard_10px;
23+
extern const Icon I_loading_10px;
24+
extern const Icon I_music_10px;
25+
extern const Icon I_settings_10px;
26+
extern const Icon I_sub1_10px;
27+
extern const Icon I_u2f_10px;
28+
extern const Icon I_unknown_10px;
29+
extern const Icon I_update_10px;
30+
extern const Icon I_BLE_Pairing_128x64;
31+
extern const Icon I_Ble_connected_15x15;
32+
extern const Icon I_Ble_disconnected_15x15;
33+
extern const Icon I_Button_18x18;
34+
extern const Icon I_Circles_47x47;
35+
extern const Icon I_Left_mouse_icon_9x9;
36+
extern const Icon I_Ok_btn_9x9;
37+
extern const Icon I_Ok_btn_pressed_13x13;
38+
extern const Icon I_Pressed_Button_13x13;
39+
extern const Icon I_Right_mouse_icon_9x9;
40+
extern const Icon I_Space_65x18;
41+
extern const Icon I_Voldwn_6x6;
42+
extern const Icon I_Volup_8x6;
43+
extern const Icon I_Bad_BLE_48x22;
44+
extern const Icon I_Clock_18x18;
45+
extern const Icon I_Error_18x18;
46+
extern const Icon I_EviSmile1_18x21;
47+
extern const Icon I_EviSmile2_18x21;
48+
extern const Icon I_EviWaiting1_18x21;
49+
extern const Icon I_EviWaiting2_18x21;
50+
extern const Icon I_Percent_10x14;
51+
extern const Icon I_Smile_18x18;
52+
extern const Icon I_UsbTree_48x22;
53+
extern const Icon I_ActiveConnection_50x64;
54+
extern const Icon I_ButtonCenter_7x7;
55+
extern const Icon I_ButtonDown_7x4;
56+
extern const Icon I_ButtonLeftSmall_3x5;
57+
extern const Icon I_ButtonLeft_4x7;
58+
extern const Icon I_ButtonRightSmall_3x5;
59+
extern const Icon I_ButtonRight_4x7;
60+
extern const Icon I_ButtonUp_7x4;
61+
extern const Icon I_DFU_128x50;
62+
extern const Icon I_Hashmark_7x7;
63+
extern const Icon I_More_data_placeholder_5x7;
64+
extern const Icon I_Warning_30x23;
65+
extern const Icon I_arrow_nano_down;
66+
extern const Icon I_arrow_nano_up;
67+
extern const Icon A_Loading_24;
68+
extern const Icon A_Round_loader_8x8;
69+
extern const Icon I_DolphinDone_80x58;
70+
extern const Icon I_DolphinMafia_119x62;
71+
extern const Icon I_DolphinReadingSuccess_59x63;
72+
extern const Icon I_DolphinSaved_92x58;
73+
extern const Icon I_DolphinSuccess_91x55;
74+
extern const Icon I_DolphinWait_59x54;
75+
extern const Icon I_WarningDolphinFlip_45x42;
76+
extern const Icon I_WarningDolphin_45x42;
77+
extern const Icon I_Erase_pin_128x64;
78+
extern const Icon I_ArrowUpEmpty_14x15;
79+
extern const Icon I_ArrowUpFilled_14x15;
80+
extern const Icon I_InfraredArrowDown_4x8;
81+
extern const Icon I_InfraredArrowUp_4x8;
82+
extern const Icon I_InfraredLearnShort_128x31;
83+
extern const Icon I_back_btn_10x8;
84+
extern const Icon I_celsius_24x23;
85+
extern const Icon I_celsius_hover_24x23;
86+
extern const Icon I_ch_down_24x21;
87+
extern const Icon I_ch_down_hover_24x21;
88+
extern const Icon I_ch_text_31x34;
89+
extern const Icon I_ch_up_24x21;
90+
extern const Icon I_ch_up_hover_24x21;
91+
extern const Icon I_cool_30x51;
92+
extern const Icon I_dry_19x20;
93+
extern const Icon I_dry_hover_19x20;
94+
extern const Icon I_dry_text_15x5;
95+
extern const Icon I_fahren_24x23;
96+
extern const Icon I_fahren_hover_24x23;
97+
extern const Icon I_heat_30x51;
98+
extern const Icon I_hourglass0_24x24;
99+
extern const Icon I_hourglass1_24x24;
100+
extern const Icon I_hourglass2_24x24;
101+
extern const Icon I_hourglass3_24x24;
102+
extern const Icon I_hourglass4_24x24;
103+
extern const Icon I_hourglass5_24x24;
104+
extern const Icon I_hourglass6_24x24;
105+
extern const Icon I_max_24x23;
106+
extern const Icon I_max_hover_24x23;
107+
extern const Icon I_mute_19x20;
108+
extern const Icon I_mute_hover_19x20;
109+
extern const Icon I_mute_text_19x5;
110+
extern const Icon I_next_19x20;
111+
extern const Icon I_next_hover_19x20;
112+
extern const Icon I_next_text_19x6;
113+
extern const Icon I_off_19x20;
114+
extern const Icon I_off_hover_19x20;
115+
extern const Icon I_off_text_12x5;
116+
extern const Icon I_pause_19x20;
117+
extern const Icon I_pause_hover_19x20;
118+
extern const Icon I_pause_text_23x5;
119+
extern const Icon I_play_19x20;
120+
extern const Icon I_play_hover_19x20;
121+
extern const Icon I_play_text_19x5;
122+
extern const Icon I_power_19x20;
123+
extern const Icon I_power_hover_19x20;
124+
extern const Icon I_power_text_24x5;
125+
extern const Icon I_prev_19x20;
126+
extern const Icon I_prev_hover_19x20;
127+
extern const Icon I_prev_text_19x5;
128+
extern const Icon I_vol_ac_text_30x30;
129+
extern const Icon I_vol_tv_text_29x34;
130+
extern const Icon I_voldown_24x21;
131+
extern const Icon I_voldown_hover_24x21;
132+
extern const Icon I_volup_24x21;
133+
extern const Icon I_volup_hover_24x21;
134+
extern const Icon I_DoorLeft_70x55;
135+
extern const Icon I_DoorRight_70x55;
136+
extern const Icon I_SmallArrowDown_3x5;
137+
extern const Icon I_SmallArrowDown_4x7;
138+
extern const Icon I_SmallArrowUp_3x5;
139+
extern const Icon I_SmallArrowUp_4x7;
140+
extern const Icon I_KeyBackspaceSelected_16x9;
141+
extern const Icon I_KeyBackspace_16x9;
142+
extern const Icon I_KeySaveBlockedSelected_24x11;
143+
extern const Icon I_KeySaveBlocked_24x11;
144+
extern const Icon I_KeySaveSelected_24x11;
145+
extern const Icon I_KeySave_24x11;
146+
extern const Icon I_KeySignSelected_21x11;
147+
extern const Icon I_KeySign_21x11;
148+
extern const Icon I_err_01;
149+
extern const Icon I_err_02;
150+
extern const Icon I_err_03;
151+
extern const Icon I_err_04;
152+
extern const Icon I_err_05;
153+
extern const Icon I_err_06;
154+
extern const Icon I_err_07;
155+
extern const Icon I_err_09;
156+
extern const Icon A_125khz_14;
157+
extern const Icon A_BadUsb_14;
158+
extern const Icon A_Debug_14;
159+
extern const Icon A_FileManager_14;
160+
extern const Icon A_GPIO_14;
161+
extern const Icon A_Infrared_14;
162+
extern const Icon A_NFC_14;
163+
extern const Icon A_Plugins_14;
164+
extern const Icon A_Settings_14;
165+
extern const Icon A_Sub1ghz_14;
166+
extern const Icon A_U2F_14;
167+
extern const Icon A_iButton_14;
168+
extern const Icon I_ArrowC_1_36x36;
169+
extern const Icon I_Detailed_chip_17x13;
170+
extern const Icon I_Keychain_39x36;
171+
extern const Icon I_MFKey_qr_25x25;
172+
extern const Icon I_Medium_chip_22x21;
173+
extern const Icon I_Modern_reader_18x34;
174+
extern const Icon I_Move_flipper_26x39;
175+
extern const Icon I_NFC_dolphin_emulation_51x64;
176+
extern const Icon I_NFC_manual_60x50;
177+
extern const Icon I_Release_arrow_18x15;
178+
extern const Icon I_check_big_20x17;
179+
extern const Icon I_Pin_arrow_up_7x9;
180+
extern const Icon I_Pin_attention_dpad_29x29;
181+
extern const Icon I_Pin_back_arrow_10x8;
182+
extern const Icon I_Pin_pointer_5x3;
183+
extern const Icon I_Pin_star_7x7;
184+
extern const Icon I_passport_bad1_46x49;
185+
extern const Icon I_passport_bad2_46x49;
186+
extern const Icon I_passport_bad3_46x49;
187+
extern const Icon I_passport_bottom_128x18;
188+
extern const Icon I_passport_happy1_46x49;
189+
extern const Icon I_passport_happy2_46x49;
190+
extern const Icon I_passport_happy3_46x49;
191+
extern const Icon I_passport_left_6x46;
192+
extern const Icon I_passport_okay1_46x49;
193+
extern const Icon I_passport_okay2_46x49;
194+
extern const Icon I_passport_okay3_46x49;
195+
extern const Icon I_BatteryBody_52x28;
196+
extern const Icon I_Battery_16x16;
197+
extern const Icon I_FaceCharging_29x14;
198+
extern const Icon I_FaceConfused_29x14;
199+
extern const Icon I_FaceNopower_29x14;
200+
extern const Icon I_FaceNormal_29x14;
201+
extern const Icon I_Health_16x16;
202+
extern const Icon I_Temperature_16x16;
203+
extern const Icon I_Unplug_bg_bottom_128x10;
204+
extern const Icon I_Unplug_bg_top_128x14;
205+
extern const Icon I_Voltage_16x16;
206+
extern const Icon I_RFIDBigChip_37x36;
207+
extern const Icon I_RFIDDolphinReceive_97x61;
208+
extern const Icon I_RFIDDolphinSend_97x61;
209+
extern const Icon I_SDQuestion_35x43;
210+
extern const Icon I_LoadingHourglass_24x24;
211+
extern const Icon I_dolph_cry_49x54;
212+
extern const Icon I_qr_benchmark_25x25;
213+
extern const Icon A_Alarm_47x39;
214+
extern const Icon I_Alert_9x8;
215+
extern const Icon I_Attention_5x8;
216+
extern const Icon I_BLE_beacon_7x8;
217+
extern const Icon I_Background_128x11;
218+
extern const Icon I_Battery_26x8;
219+
extern const Icon I_Bluetooth_Connected_16x8;
220+
extern const Icon I_Bluetooth_Idle_5x8;
221+
extern const Icon I_Charging_lightning_9x10;
222+
extern const Icon I_Charging_lightning_mask_9x10;
223+
extern const Icon I_Exp_module_connected_12x8;
224+
extern const Icon I_GameMode_11x8;
225+
extern const Icon I_Hidden_window_9x8;
226+
extern const Icon I_Muted_8x8;
227+
extern const Icon I_Rpc_active_7x8;
228+
extern const Icon I_SDcardFail_11x8;
229+
extern const Icon I_SDcardMounted_11x8;
230+
extern const Icon I_External_ant_1_9x11;
231+
extern const Icon I_Internal_ant_1_9x11;
232+
extern const Icon I_Lock_7x8;
233+
extern const Icon I_MHz_25x11;
234+
extern const Icon I_Quest_7x8;
235+
extern const Icon I_Scanning_short_96x52;
236+
extern const Icon I_Unlock_7x8;
237+
extern const Icon A_SubGhz_External_ant;
238+
extern const Icon A_SubGhz_Internal_ant;
239+
extern const Icon I_Auth_62x31;
240+
extern const Icon I_Connect_me_62x31;
241+
extern const Icon I_Connected_62x31;
242+
extern const Icon I_Drive_112x35;
243+
extern const Icon I_Error_62x31;
244+
extern const Icon I_Updating_32x40;
245+
extern const Icon I_iButtonDolphinVerySuccess_92x55;
246+
extern const Icon I_iButtonKey_49x44;

applications_user/lora_app/lora.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ Code porting from LoRa library https://github.dev/thekakester/Arduino-LoRa-Sx126
2323
#define FREQ_STEP 0.95367431640625
2424

2525
static uint32_t timeout = 1000;
26-
//static uint32_t timeout = 100;
2726

2827
FuriHalSpiBusHandle spi_handle;
2928
const FuriHalSpiBusHandle* spi = &spi_handle;
@@ -61,6 +60,10 @@ int16_t getRSSI() {
6160
return rssi;
6261
}
6362

63+
int8_t getSNR() {
64+
return snr;
65+
}
66+
6467
void checkBusy() {
6568
uint8_t busy_timeout_cnt;
6669
busy_timeout_cnt = 0;
@@ -570,38 +573,26 @@ bool configSetCodingRate(int cr) {
570573
return true;
571574
}
572575

573-
/* Set the sync word*/
574-
bool configSetSyncWord(uint16_t sw) {
575-
uint8_t msb = (sw >> 8) & 0xFF;
576-
uint8_t lsb = sw & 0xFF;
576+
bool configSetSyncWord(uint8_t syncWord, uint8_t controlBits) {
577+
uint8_t msb = (syncWord & 0xF0) | ((controlBits & 0xF0) >> 4);
578+
uint8_t lsb = ((syncWord & 0x0F) << 4) | (controlBits & 0x0F);
577579

578-
// Write MSB to 0x0740
580+
// Write both bytes in a single SPI transaction
579581
furi_hal_gpio_write(pin_nss1, false); // CS low
580582
furi_hal_spi_acquire(spi);
581583

582584
spiBuff[0] = 0x0D; // WriteRegister opcode
583585
spiBuff[1] = 0x07; // Address high byte (0x0740)
584586
spiBuff[2] = 0x40; // Address low byte
585-
spiBuff[3] = msb; // Data
586-
furi_hal_spi_bus_tx(spi, spiBuff, 4, timeout);
587+
spiBuff[3] = msb; // MSB data
588+
spiBuff[4] = lsb; // LSB data
587589

588-
furi_hal_spi_release(spi);
589-
furi_hal_gpio_write(pin_nss1, true); // CS high
590-
591-
// Write LSB to 0x0741
592-
furi_hal_gpio_write(pin_nss1, false); // CS low
593-
furi_hal_spi_acquire(spi);
594-
595-
spiBuff[0] = 0x0D; // WriteRegister opcode
596-
spiBuff[1] = 0x07; // Address high byte (0x0741)
597-
spiBuff[2] = 0x41; // Address low byte
598-
spiBuff[3] = lsb; // Data
599-
furi_hal_spi_bus_tx(spi, spiBuff, 4, timeout);
590+
furi_hal_spi_bus_tx(spi, spiBuff, 5, timeout);
600591

601592
furi_hal_spi_release(spi);
602593
furi_hal_gpio_write(pin_nss1, true); // CS high
603594

604-
furi_delay_ms(1); // give chip time
595+
furi_delay_ms(1);
605596

606597
return true;
607598
}
@@ -612,7 +603,12 @@ bool configSetSpreadingFactor(int sf) {
612603
if(sf < 5 || sf > 12) {
613604
return false;
614605
}
615-
lowDataRateOptimize = (sf >= 11) ? 1 : 0; // Turn on for SF11+SF12, turn off for anything else
606+
FURI_LOG_E(TAG, "SF %d", sf);
607+
FURI_LOG_E(TAG, "BW %d", bandwidth);
608+
lowDataRateOptimize = (sf == 12 && bandwidth == 4) ?
609+
1 :
610+
0; // Turn on for SF12 125 kHz, turn off for anything else
611+
FURI_LOG_E(TAG, "LOD %d", lowDataRateOptimize);
616612
spreadingFactor = sf;
617613
updateModulationParameters();
618614
return true;
@@ -629,12 +625,6 @@ void setPacketParams(
629625
uint8_t preambleMSB = packetParam1 >> 8;
630626
uint8_t preambleLSB = packetParam1 & 0xFF;
631627

632-
//savedPacketParam1 = packetParam1;
633-
//savedPacketParam2 = packetParam2;
634-
//savedPacketParam3 = packetParam3;
635-
//savedPacketParam4 = packetParam4;
636-
//savedPacketParam5 = packetParam5;
637-
638628
spiBuff[0] = 0x8C; //Opcode for "SetPacketParameters"
639629
spiBuff[1] = preambleMSB; //Preamble Len MSB
640630
spiBuff[2] = preambleLSB; //Preamble Len LSB
@@ -649,6 +639,14 @@ void setPacketParams(
649639

650640
if(furi_hal_spi_bus_tx(spi, spiBuff, 7, timeout)) {
651641
furi_hal_spi_release(spi);
642+
FURI_LOG_I(
643+
"LoRaSPI",
644+
"PacketParams written OK -> Preamble: %u, Header: %u, Payload: %u, CRC: %u, IQ: %u",
645+
packetParam1,
646+
packetParam2,
647+
packetParam3,
648+
packetParam4,
649+
packetParam5);
652650
} else {
653651
FURI_LOG_E(TAG, "FAILED - furi_hal_spi_bus_tx or furi_hal_spi_bus_rx failed.");
654652
furi_hal_spi_release(spi);
@@ -672,7 +670,7 @@ void setModeReceive() {
672670

673671
spiBuff[0] = 0x8C; //Opcode for "SetPacketParameters"
674672
spiBuff[1] = 0x00; //PacketParam1 = Preamble Len MSB
675-
spiBuff[2] = 0x0C; //PacketParam2 = Preamble Len LSB
673+
spiBuff[2] = 0x10; //PacketParam2 = Preamble Len LSB - 16
676674
spiBuff[3] = 0x00; //PacketParam3 = Header Type. 0x00 = Variable Len, 0x01 = Fixed Length
677675
spiBuff[4] = 0xFF; //PacketParam4 = Payload Length (Max is 255 bytes)
678676
spiBuff[5] = 0x00; //PacketParam5 = CRC Type. 0x00 = Off, 0x01 = on
@@ -749,7 +747,7 @@ void transmit(uint8_t* data, int dataLen) {
749747

750748
spiBuff[0] = 0x8C; // Opcode for "SetPacketParameters"
751749
spiBuff[1] = 0x00; // PacketParam1 = Preamble Len MSB
752-
spiBuff[2] = 0x0C; // PacketParam2 = Preamble Len LSB
750+
spiBuff[2] = 0x10; // PacketParam2 = Preamble Len LSB
753751
spiBuff[3] = 0x00; // PacketParam3 = Header Type. 0x00 = Variable Len, 0x01 = Fixed Length
754752
spiBuff[4] = dataLen; // PacketParam4 = Payload Length (Max is 255 bytes)
755753
spiBuff[5] = 0x00; // PacketParam5 = CRC Type. 0x00 = Off, 0x01 = on

0 commit comments

Comments
 (0)