Compare commits
2 Commits
641412ecc8
...
3ee276c189
Author | SHA1 | Date | |
---|---|---|---|
3ee276c189 | |||
0b95cff140 |
@ -1 +0,0 @@
|
||||
E:\Dark Emergency Timer\Hardware\DE-Timer\_autosave-DE-Timer.kicad_sch
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
@ -33,9 +33,9 @@
|
||||
"other_text_thickness": 0.15,
|
||||
"other_text_upright": false,
|
||||
"pads": {
|
||||
"drill": 0.762,
|
||||
"height": 1.524,
|
||||
"width": 1.524
|
||||
"drill": 3.0,
|
||||
"height": 4.0,
|
||||
"width": 4.0
|
||||
},
|
||||
"silk_line_width": 0.15,
|
||||
"silk_text_italic": false,
|
||||
@ -384,7 +384,7 @@
|
||||
"idf": "",
|
||||
"netlist": "",
|
||||
"specctra_dsn": "",
|
||||
"step": "",
|
||||
"step": "DE-Timer.step",
|
||||
"vrml": ""
|
||||
},
|
||||
"page_layout_descr_file": ""
|
||||
|
@ -1601,6 +1601,13 @@
|
||||
(effects (font (size 1.27 1.27)) (justify right) hide)
|
||||
)
|
||||
)
|
||||
(global_label "LoRa_M0" (shape input) (at 262.89 76.2 270) (fields_autoplaced)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
(uuid 72e274cf-d09b-40a2-b1e3-3b71338c2588)
|
||||
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 262.9694 86.8379 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right) hide)
|
||||
)
|
||||
)
|
||||
(global_label "BTN_FAC_2" (shape input) (at 199.39 121.92 0) (fields_autoplaced)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
(uuid 7a25f527-6714-4bf4-8e93-5473e8c7ec97)
|
||||
@ -1727,6 +1734,13 @@
|
||||
(effects (font (size 1.27 1.27)) (justify right) hide)
|
||||
)
|
||||
)
|
||||
(global_label "LoRa_M1" (shape input) (at 256.54 76.2 270) (fields_autoplaced)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
(uuid eeff06ce-5dd6-48ad-98cf-4489d7624b9c)
|
||||
(property "Intersheet References" "${INTERSHEET_REFS}" (id 0) (at 256.6194 86.8379 90)
|
||||
(effects (font (size 1.27 1.27)) (justify right) hide)
|
||||
)
|
||||
)
|
||||
(global_label "LoRa_M1" (shape output) (at 234.95 125.73 180) (fields_autoplaced)
|
||||
(effects (font (size 1.27 1.27)) (justify right))
|
||||
(uuid f177e463-2a20-4337-808d-73eaa4f12d69)
|
||||
@ -1897,7 +1911,7 @@
|
||||
(property "Reference" "R6" (id 0) (at 212.598 44.5516 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "R" (id 1) (at 212.598 46.863 0)
|
||||
(property "Value" "4k7" (id 1) (at 212.598 46.863 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 209.042 45.72 90)
|
||||
@ -1916,7 +1930,7 @@
|
||||
(property "Reference" "R7" (id 0) (at 217.678 44.5516 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "R" (id 1) (at 217.678 46.863 0)
|
||||
(property "Value" "4k7" (id 1) (at 217.678 46.863 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 214.122 45.72 90)
|
||||
@ -2302,7 +2316,7 @@
|
||||
(uuid 00000000-0000-0000-0000-0000608139a0)
|
||||
(property "Reference" "U6" (id 0) (at 100.33 78.9432 0))
|
||||
(property "Value" "OKI-78SR-5_1.5-W36-C" (id 1) (at 100.33 81.2546 0))
|
||||
(property "Footprint" "Converter_DCDC:Converter_DCDC_muRata_OKI-78SR_Vertical" (id 2) (at 101.6 91.44 0)
|
||||
(property "Footprint" "Converter_DCDC:Converter_DCDC_RECOM_R-78E-0.5_THT" (id 2) (at 101.6 91.44 0)
|
||||
(effects (font (size 1.27 1.27) italic) (justify left) hide)
|
||||
)
|
||||
(property "Datasheet" "https://power.murata.com/data/power/oki-78sr.pdf" (id 3) (at 100.33 85.09 0)
|
||||
@ -2396,6 +2410,25 @@
|
||||
(pin "9" (uuid 8020776e-90b2-4b88-a91b-d42c0c930bde))
|
||||
)
|
||||
|
||||
(symbol (lib_id "Device:R") (at 256.54 72.39 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 2bcb8eff-5353-49d7-940f-1af0870f1ac9)
|
||||
(property "Reference" "R10" (id 0) (at 258.318 71.2216 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "4k7" (id 1) (at 258.318 73.533 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 254.762 72.39 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (id 3) (at 256.54 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 6115d08d-ef27-4828-8c89-a6e903cffdaa))
|
||||
(pin "2" (uuid e577afa2-1c52-4e68-895a-b4c7f4efbfd1))
|
||||
)
|
||||
|
||||
(symbol (lib_id "power:GND") (at 160.02 83.82 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 3608f094-4a83-4b12-a751-ce01f8af8f37)
|
||||
@ -2433,7 +2466,7 @@
|
||||
(symbol (lib_id "power:+3.3V") (at 243.84 68.58 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 40a343f4-2d59-4a27-ab4f-ae28f587fed5)
|
||||
(property "Reference" "#PWR?" (id 0) (at 243.84 72.39 0)
|
||||
(property "Reference" "#PWR02" (id 0) (at 243.84 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Value" "+3.3V" (id 1) (at 244.221 64.1858 0))
|
||||
@ -2465,10 +2498,10 @@
|
||||
(symbol (lib_id "Device:R") (at 250.19 72.39 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 43fa7042-3495-4cdb-99c3-d2fae29fcc2e)
|
||||
(property "Reference" "R?" (id 0) (at 251.968 71.2216 0)
|
||||
(property "Reference" "R9" (id 0) (at 251.968 71.2216 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "R" (id 1) (at 251.968 73.533 0)
|
||||
(property "Value" "4k7" (id 1) (at 251.968 73.533 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 248.412 72.39 90)
|
||||
@ -2566,7 +2599,7 @@
|
||||
(symbol (lib_id "power:+3.3V") (at 250.19 68.58 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 6c9e14ce-f378-409f-83b0-3017c42aa43a)
|
||||
(property "Reference" "#PWR?" (id 0) (at 250.19 72.39 0)
|
||||
(property "Reference" "#PWR03" (id 0) (at 250.19 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Value" "+3.3V" (id 1) (at 250.571 64.1858 0))
|
||||
@ -2633,7 +2666,7 @@
|
||||
(property "Reference" "C2" (id 0) (at 142.621 76.3016 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "C" (id 1) (at 142.621 78.613 0)
|
||||
(property "Value" "100n" (id 1) (at 142.621 78.613 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder" (id 2) (at 140.6652 81.28 0)
|
||||
@ -2739,7 +2772,7 @@
|
||||
(symbol (lib_id "power:+3.3V") (at 237.49 68.58 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid 9db85383-a03f-4209-a928-87be53d1e345)
|
||||
(property "Reference" "#PWR?" (id 0) (at 237.49 72.39 0)
|
||||
(property "Reference" "#PWR01" (id 0) (at 237.49 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Value" "+3.3V" (id 1) (at 237.871 64.1858 0))
|
||||
@ -2780,10 +2813,10 @@
|
||||
(symbol (lib_id "Device:R") (at 243.84 72.39 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid af841cc7-411b-4fa7-bf12-b2b6bf90990e)
|
||||
(property "Reference" "R?" (id 0) (at 245.618 71.2216 0)
|
||||
(property "Reference" "R8" (id 0) (at 245.618 71.2216 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "R" (id 1) (at 245.618 73.533 0)
|
||||
(property "Value" "4k7" (id 1) (at 245.618 73.533 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 242.062 72.39 90)
|
||||
@ -2796,6 +2829,22 @@
|
||||
(pin "2" (uuid b71998a2-dc31-488e-96c8-f96d58289595))
|
||||
)
|
||||
|
||||
(symbol (lib_id "power:+3.3V") (at 262.89 68.58 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid b2a70cb2-3ea0-4d7a-83e9-2996d0cf206b)
|
||||
(property "Reference" "#PWR0131" (id 0) (at 262.89 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Value" "+3.3V" (id 1) (at 263.271 64.1858 0))
|
||||
(property "Footprint" "" (id 2) (at 262.89 68.58 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "" (id 3) (at 262.89 68.58 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid a565fbe1-90b3-4bf4-85a9-0bf50a5110f2))
|
||||
)
|
||||
|
||||
(symbol (lib_id "power:GND") (at 139.7 81.28 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid bb27d01d-6f95-44db-9098-a0b85d39315e)
|
||||
@ -2918,6 +2967,41 @@
|
||||
(pin "1" (uuid 1d18dbe4-48e7-470b-b33a-c9b54fb84aeb))
|
||||
)
|
||||
|
||||
(symbol (lib_id "power:+3.3V") (at 256.54 68.58 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid f19e33ae-597f-4b9a-8f2d-c4d9c6bead68)
|
||||
(property "Reference" "#PWR0130" (id 0) (at 256.54 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Value" "+3.3V" (id 1) (at 256.921 64.1858 0))
|
||||
(property "Footprint" "" (id 2) (at 256.54 68.58 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "" (id 3) (at 256.54 68.58 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid f4708d09-7ba1-402c-9e48-47aea89c0016))
|
||||
)
|
||||
|
||||
(symbol (lib_id "Device:R") (at 262.89 72.39 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid f4ba32ab-ab3d-4753-a0b7-a2a898ba4b27)
|
||||
(property "Reference" "R11" (id 0) (at 264.668 71.2216 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "4k7" (id 1) (at 264.668 73.533 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 261.112 72.39 90)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "~" (id 3) (at 262.89 72.39 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(pin "1" (uuid 4b77d0a4-5200-4718-ad55-d12fcc0160fd))
|
||||
(pin "2" (uuid 970b75d2-be6a-4922-bf76-1e9d7e25dec5))
|
||||
)
|
||||
|
||||
(symbol (lib_id "Connector_Generic:Conn_01x04") (at 116.84 147.32 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid f7c59d3b-150e-4fe4-9d7a-d8150b555fa0)
|
||||
@ -2942,10 +3026,10 @@
|
||||
(symbol (lib_id "Device:R") (at 237.49 72.39 0) (unit 1)
|
||||
(in_bom yes) (on_board yes)
|
||||
(uuid fe50da4c-5b14-4959-9cb1-4b2b431f31fd)
|
||||
(property "Reference" "R?" (id 0) (at 239.268 71.2216 0)
|
||||
(property "Reference" "R5" (id 0) (at 239.268 71.2216 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Value" "R" (id 1) (at 239.268 73.533 0)
|
||||
(property "Value" "4k7" (id 1) (at 239.268 73.533 0)
|
||||
(effects (font (size 1.27 1.27)) (justify left))
|
||||
)
|
||||
(property "Footprint" "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder" (id 2) (at 235.712 72.39 90)
|
||||
@ -2963,6 +3047,15 @@
|
||||
)
|
||||
|
||||
(symbol_instances
|
||||
(path "/9db85383-a03f-4209-a928-87be53d1e345"
|
||||
(reference "#PWR01") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/40a343f4-2d59-4a27-ab4f-ae28f587fed5"
|
||||
(reference "#PWR02") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/6c9e14ce-f378-409f-83b0-3017c42aa43a"
|
||||
(reference "#PWR03") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/e450da72-98c3-4b02-bd53-9f12a50ec903"
|
||||
(reference "#PWR0101") (unit 1) (value "GND") (footprint "")
|
||||
)
|
||||
@ -3050,6 +3143,12 @@
|
||||
(path "/88bd6a1b-baf5-4675-82b2-2c94b1d8679e"
|
||||
(reference "#PWR0129") (unit 1) (value "GND") (footprint "")
|
||||
)
|
||||
(path "/f19e33ae-597f-4b9a-8f2d-c4d9c6bead68"
|
||||
(reference "#PWR0130") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/b2a70cb2-3ea0-4d7a-83e9-2996d0cf206b"
|
||||
(reference "#PWR0131") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-0000606a3dab"
|
||||
(reference "#PWR0137") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
@ -3068,20 +3167,11 @@
|
||||
(path "/00000000-0000-0000-0000-0000608d2410"
|
||||
(reference "#PWR0151") (unit 1) (value "GND") (footprint "")
|
||||
)
|
||||
(path "/40a343f4-2d59-4a27-ab4f-ae28f587fed5"
|
||||
(reference "#PWR?") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/6c9e14ce-f378-409f-83b0-3017c42aa43a"
|
||||
(reference "#PWR?") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/9db85383-a03f-4209-a928-87be53d1e345"
|
||||
(reference "#PWR?") (unit 1) (value "+3.3V") (footprint "")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-00006065cd79"
|
||||
(reference "C1") (unit 1) (value "NP") (footprint "Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder")
|
||||
)
|
||||
(path "/79810dae-0a78-4064-835f-fd152b22a1ed"
|
||||
(reference "C2") (unit 1) (value "C") (footprint "Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder")
|
||||
(reference "C2") (unit 1) (value "100n") (footprint "Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-00006065ba95"
|
||||
(reference "C3") (unit 1) (value "C") (footprint "Capacitor_SMD:C_0805_2012Metric_Pad1.18x1.45mm_HandSolder")
|
||||
@ -3134,20 +3224,26 @@
|
||||
(path "/644e1842-7b7f-4923-bdec-dc0f5dc47467"
|
||||
(reference "R4") (unit 1) (value "0") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/fe50da4c-5b14-4959-9cb1-4b2b431f31fd"
|
||||
(reference "R5") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-000060644009"
|
||||
(reference "R6") (unit 1) (value "R") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
(reference "R6") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-000060644d37"
|
||||
(reference "R7") (unit 1) (value "R") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/43fa7042-3495-4cdb-99c3-d2fae29fcc2e"
|
||||
(reference "R?") (unit 1) (value "R") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
(reference "R7") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/af841cc7-411b-4fa7-bf12-b2b6bf90990e"
|
||||
(reference "R?") (unit 1) (value "R") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
(reference "R8") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/fe50da4c-5b14-4959-9cb1-4b2b431f31fd"
|
||||
(reference "R?") (unit 1) (value "R") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
(path "/43fa7042-3495-4cdb-99c3-d2fae29fcc2e"
|
||||
(reference "R9") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/2bcb8eff-5353-49d7-940f-1af0870f1ac9"
|
||||
(reference "R10") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/f4ba32ab-ab3d-4753-a0b7-a2a898ba4b27"
|
||||
(reference "R11") (unit 1) (value "4k7") (footprint "Resistor_SMD:R_0805_2012Metric_Pad1.20x1.40mm_HandSolder")
|
||||
)
|
||||
(path "/0dfd3030-be04-4d31-ab7a-5e9d80308efc"
|
||||
(reference "U1") (unit 1) (value "WeMos_D1_mini") (footprint "Module:WEMOS_D1_mini_light")
|
||||
@ -3165,7 +3261,7 @@
|
||||
(reference "U5") (unit 1) (value "PCF8574") (footprint "Package_SO:SOIC-16W_7.5x10.3mm_P1.27mm")
|
||||
)
|
||||
(path "/00000000-0000-0000-0000-0000608139a0"
|
||||
(reference "U6") (unit 1) (value "OKI-78SR-5_1.5-W36-C") (footprint "Converter_DCDC:Converter_DCDC_muRata_OKI-78SR_Vertical")
|
||||
(reference "U6") (unit 1) (value "OKI-78SR-5_1.5-W36-C") (footprint "Converter_DCDC:Converter_DCDC_RECOM_R-78E-0.5_THT")
|
||||
)
|
||||
)
|
||||
)
|
||||
|
30
Software/include/lora_messages.h
Normal file
30
Software/include/lora_messages.h
Normal file
@ -0,0 +1,30 @@
|
||||
#ifndef _LORA_MESSAGES_H_
|
||||
#define _LORA_MESSAGES_H_
|
||||
|
||||
#define MESSAGES_VERSION 1.0
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef char MessageType_t[8];
|
||||
typedef uint16_t NodeID_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NodeID_t nodeid;
|
||||
uint32_t millis;
|
||||
uint8_t faction_active;
|
||||
uint32_t faction_1_timer;
|
||||
uint32_t faction_2_timer;
|
||||
uint32_t faction_3_timer;
|
||||
} __attribute__((packed)) MessageStatus_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
NodeID_t nodeid;
|
||||
bool gpsfix;
|
||||
double latitude;
|
||||
double longitude;
|
||||
double altitude;
|
||||
} __attribute__((packed)) MessagePosition_t;
|
||||
|
||||
#endif
|
1
Software/lib/EByte LoRa E220 library/.gitattributes
vendored
Normal file
1
Software/lib/EByte LoRa E220 library/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
resources export-ignore
|
1
Software/lib/EByte LoRa E220 library/.piopm
Normal file
1
Software/lib/EByte LoRa E220 library/.piopm
Normal file
@ -0,0 +1 @@
|
||||
{"type": "library", "name": "EByte LoRa E220 library", "version": "1.0.6", "spec": {"owner": "xreef", "id": 13661, "name": "EByte LoRa E220 library", "requirements": null, "uri": null}}
|
11
Software/lib/EByte LoRa E220 library/.project
Normal file
11
Software/lib/EByte LoRa E220 library/.project
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>LoRa_E220_Series_Library</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
</natures>
|
||||
</projectDescription>
|
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* EBYTE LoRa E220 Series
|
||||
* https://www.mischianti.org/category/my-libraries/lora-e22-devices/
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019 Renzo Mischianti www.mischianti.org All right reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef EBYTE_LORA_E220_LIBRARY_H
|
||||
#define EBYTE_LORA_E220_LIBRARY_H
|
||||
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
#endif
|
||||
|
||||
#pragma once
|
24
Software/lib/EByte LoRa E220 library/LICENSE.md
Normal file
24
Software/lib/EByte LoRa E220 library/LICENSE.md
Normal file
@ -0,0 +1,24 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2017 Renzo Mischianti www.mischianti.org All right reserved.
|
||||
|
||||
You may copy, alter and reuse this code in any way you like, but please leave
|
||||
reference to www.mischianti.org in your comments if you redistribute this code.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
1051
Software/lib/EByte LoRa E220 library/LoRa_E220.cpp
Normal file
1051
Software/lib/EByte LoRa E220 library/LoRa_E220.cpp
Normal file
File diff suppressed because it is too large
Load Diff
401
Software/lib/EByte LoRa E220 library/LoRa_E220.h
Normal file
401
Software/lib/EByte LoRa E220 library/LoRa_E220.h
Normal file
@ -0,0 +1,401 @@
|
||||
/*
|
||||
* EBYTE LoRa E220 Series
|
||||
*
|
||||
* AUTHOR: Renzo Mischianti
|
||||
* VERSION: 1.0.6
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2022 Renzo Mischianti www.mischianti.org All right reserved.
|
||||
*
|
||||
* You may copy, alter and reuse this code in any way you like, but please leave
|
||||
* reference to www.mischianti.org in your comments if you redistribute this code.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
#ifndef LoRa_E220_h
|
||||
#define LoRa_E220_h
|
||||
|
||||
#if !defined(ARDUINO_ARCH_STM32) && !defined(ESP32) && !defined(ARDUINO_ARCH_SAMD) && !defined(ARDUINO_ARCH_MBED) && !defined(__STM32F1__) && !defined(__STM32F4__)
|
||||
#define ACTIVATE_SOFTWARE_SERIAL
|
||||
#endif
|
||||
#if defined(ESP32)
|
||||
#define HARDWARE_SERIAL_SELECTABLE_PIN
|
||||
#endif
|
||||
|
||||
#ifdef ACTIVATE_SOFTWARE_SERIAL
|
||||
#include <SoftwareSerial.h>
|
||||
#endif
|
||||
|
||||
#include <includes/statesNaming.h>
|
||||
|
||||
#if ARDUINO >= 100
|
||||
#include "Arduino.h"
|
||||
#else
|
||||
#include "WProgram.h"
|
||||
#endif
|
||||
|
||||
#define MAX_SIZE_TX_PACKET 200
|
||||
|
||||
// Uncomment to enable printing out nice debug messages.
|
||||
//#define LoRa_E220_DEBUG
|
||||
|
||||
// Define where debug output will be printed.
|
||||
#define DEBUG_PRINTER Serial
|
||||
|
||||
// Setup debug printing macros.
|
||||
#ifdef LoRa_E220_DEBUG
|
||||
#define DEBUG_PRINT(...) { DEBUG_PRINTER.print(__VA_ARGS__); }
|
||||
#define DEBUG_PRINTLN(...) { DEBUG_PRINTER.println(__VA_ARGS__); }
|
||||
#else
|
||||
#define DEBUG_PRINT(...) {}
|
||||
#define DEBUG_PRINTLN(...) {}
|
||||
#endif
|
||||
|
||||
enum MODE_TYPE {
|
||||
MODE_0_NORMAL = 0,
|
||||
MODE_0_TRANSMISSION = 0,
|
||||
MODE_1_WOR_TRANSMITTER = 1,
|
||||
MODE_1_WOR = 1,
|
||||
MODE_2_WOR_RECEIVER = 2,
|
||||
MODE_2_POWER_SAVING = 2,
|
||||
MODE_3_CONFIGURATION = 3,
|
||||
MODE_3_PROGRAM = 3,
|
||||
MODE_3_SLEEP = 3,
|
||||
MODE_INIT = 0xFF
|
||||
};
|
||||
|
||||
enum PROGRAM_COMMAND {
|
||||
WRITE_CFG_PWR_DWN_SAVE = 0xC0,
|
||||
READ_CONFIGURATION = 0xC1,
|
||||
WRITE_CFG_PWR_DWN_LOSE = 0xC2,
|
||||
WRONG_FORMAT = 0xFF,
|
||||
RETURNED_COMMAND = 0xC1,
|
||||
SPECIAL_WIFI_CONF_COMMAND = 0xCF
|
||||
};
|
||||
|
||||
enum REGISTER_ADDRESS {
|
||||
REG_ADDRESS_CFG = 0x00,
|
||||
REG_ADDRESS_SPED = 0x02,
|
||||
REG_ADDRESS_TRANS_MODE = 0x03,
|
||||
REG_ADDRESS_CHANNEL = 0x04,
|
||||
REG_ADDRESS_OPTION = 0x05,
|
||||
REG_ADDRESS_CRYPT = 0x06,
|
||||
REG_ADDRESS_PID = 0x08
|
||||
};
|
||||
|
||||
enum PACKET_LENGHT {
|
||||
PL_CONFIGURATION = 0x08,
|
||||
|
||||
PL_SPED = 0x01,
|
||||
PL_OPTION = 0x01,
|
||||
PL_TRANSMISSION_MODE= 0x01,
|
||||
PL_CHANNEL = 0x01,
|
||||
PL_CRYPT = 0x02,
|
||||
PL_PID = 0x03
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct Speed {
|
||||
uint8_t airDataRate :3; //bit 0-2
|
||||
String getAirDataRateDescription() {
|
||||
return getAirDataRateDescriptionByParams(this->airDataRate);
|
||||
}
|
||||
|
||||
uint8_t uartParity :2; //bit 3-4
|
||||
String getUARTParityDescription() {
|
||||
return getUARTParityDescriptionByParams(this->uartParity);
|
||||
}
|
||||
|
||||
uint8_t uartBaudRate :3; //bit 5-7
|
||||
String getUARTBaudRateDescription() {
|
||||
return getUARTBaudRateDescriptionByParams(this->uartBaudRate);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct TransmissionMode {
|
||||
byte WORPeriod :3; //bit 2,1,0
|
||||
String getWORPeriodByParamsDescription() {
|
||||
return getWORPeriodByParams(this->WORPeriod);
|
||||
}
|
||||
byte reserved2 :1; //bit 3
|
||||
byte enableLBT :1; //bit 4
|
||||
String getLBTEnableByteDescription() {
|
||||
return getLBTEnableByteByParams(this->enableLBT);
|
||||
}
|
||||
byte reserved :1; //bit 5
|
||||
|
||||
byte fixedTransmission :1; //bit 6
|
||||
String getFixedTransmissionDescription() {
|
||||
return getFixedTransmissionDescriptionByParams(this->fixedTransmission);
|
||||
}
|
||||
|
||||
byte enableRSSI :1; //bit 7
|
||||
String getRSSIEnableByteDescription() {
|
||||
return getRSSIEnableByteByParams(this->enableRSSI);
|
||||
}
|
||||
};
|
||||
|
||||
struct Option {
|
||||
uint8_t transmissionPower :2; //bit 0-1
|
||||
String getTransmissionPowerDescription() {
|
||||
return getTransmissionPowerDescriptionByParams(this->transmissionPower);
|
||||
}
|
||||
uint8_t reserved :3; //bit 2-4
|
||||
|
||||
uint8_t RSSIAmbientNoise :1; //bit 5
|
||||
String getRSSIAmbientNoiseEnable() {
|
||||
return getRSSIAmbientNoiseEnableByParams(this->RSSIAmbientNoise);
|
||||
}
|
||||
|
||||
uint8_t subPacketSetting :2; //bit 6-7
|
||||
String getSubPacketSetting() {
|
||||
return getSubPacketSettingByParams(this->subPacketSetting);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct Crypt {
|
||||
byte CRYPT_H = 0;
|
||||
byte CRYPT_L = 0;
|
||||
};
|
||||
|
||||
struct Configuration {
|
||||
byte COMMAND = 0;
|
||||
byte STARTING_ADDRESS = 0;
|
||||
byte LENGHT = 0;
|
||||
|
||||
byte ADDH = 0;
|
||||
byte ADDL = 0;
|
||||
|
||||
struct Speed SPED;
|
||||
struct Option OPTION;
|
||||
|
||||
byte CHAN = 0;
|
||||
String getChannelDescription() {
|
||||
return String(this->CHAN + OPERATING_FREQUENCY) + F("MHz");
|
||||
}
|
||||
|
||||
struct TransmissionMode TRANSMISSION_MODE;
|
||||
|
||||
struct Crypt CRYPT;
|
||||
};
|
||||
|
||||
struct ModuleInformation {
|
||||
byte COMMAND = 0;
|
||||
byte STARTING_ADDRESS = 0;
|
||||
byte LENGHT = 0;
|
||||
|
||||
byte model = 0;
|
||||
byte version = 0;
|
||||
byte features = 0;
|
||||
};
|
||||
|
||||
struct ResponseStatus {
|
||||
Status code;
|
||||
String getResponseDescription() {
|
||||
return getResponseDescriptionByParams(this->code);
|
||||
}
|
||||
};
|
||||
|
||||
struct ResponseStructContainer {
|
||||
void *data;
|
||||
byte rssi;
|
||||
ResponseStatus status;
|
||||
void close() {
|
||||
free(this->data);
|
||||
}
|
||||
};
|
||||
struct ResponseContainer {
|
||||
String data;
|
||||
byte rssi;
|
||||
ResponseStatus status;
|
||||
};
|
||||
|
||||
struct ConfigurationMessage
|
||||
{
|
||||
byte specialCommand1 = 0xCF;
|
||||
byte specialCommand2 = 0xCF;
|
||||
|
||||
unsigned char message[];
|
||||
};
|
||||
|
||||
//struct FixedStransmission {
|
||||
// byte ADDL = 0;
|
||||
// byte ADDH = 0;
|
||||
// byte CHAN = 0;
|
||||
// void *message;
|
||||
//};
|
||||
#pragma pack(pop)
|
||||
|
||||
class LoRa_E220 {
|
||||
public:
|
||||
#ifdef ACTIVATE_SOFTWARE_SERIAL
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
#endif
|
||||
|
||||
LoRa_E220(HardwareSerial* serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(HardwareSerial* serial, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(HardwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
|
||||
#ifdef HARDWARE_SERIAL_SELECTABLE_PIN
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, HardwareSerial* serial, UART_BPS_RATE bpsRate, uint32_t serialConfig = SERIAL_8N1);
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, HardwareSerial* serial, byte auxPin, UART_BPS_RATE bpsRate, uint32_t serialConfig = SERIAL_8N1);
|
||||
LoRa_E220(byte txE220pin, byte rxE220pin, HardwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate, uint32_t serialConfig = SERIAL_8N1);
|
||||
#endif
|
||||
|
||||
#ifdef ACTIVATE_SOFTWARE_SERIAL
|
||||
LoRa_E220(SoftwareSerial* serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(SoftwareSerial* serial, byte auxPin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
LoRa_E220(SoftwareSerial* serial, byte auxPin, byte m0Pin, byte m1Pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600);
|
||||
#endif
|
||||
|
||||
// LoRa_E220(byte txE220pin, byte rxE220pin, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600, MODE_TYPE mode = MODE_0_NORMAL);
|
||||
// LoRa_E220(HardwareSerial* serial = &Serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600, MODE_TYPE mode = MODE_0_NORMAL);
|
||||
// LoRa_E220(SoftwareSerial* serial, UART_BPS_RATE bpsRate = UART_BPS_RATE_9600, MODE_TYPE mode = MODE_0_NORMAL);
|
||||
|
||||
bool begin();
|
||||
Status setMode(MODE_TYPE mode);
|
||||
MODE_TYPE getMode();
|
||||
|
||||
ResponseStructContainer getConfiguration();
|
||||
ResponseStatus setConfiguration(Configuration configuration, PROGRAM_COMMAND saveType = WRITE_CFG_PWR_DWN_LOSE);
|
||||
|
||||
ResponseStructContainer getModuleInformation();
|
||||
ResponseStatus resetModule();
|
||||
|
||||
ResponseStatus sendMessage(const void *message, const uint8_t size);
|
||||
|
||||
ResponseContainer receiveMessageUntil(char delimiter = '\0');
|
||||
ResponseStructContainer receiveMessage(const uint8_t size);
|
||||
ResponseStructContainer receiveMessageRSSI(const uint8_t size);
|
||||
|
||||
ResponseStructContainer receiveMessageComplete(const uint8_t size, bool enableRSSI);
|
||||
ResponseContainer receiveMessageComplete(bool enableRSSI);
|
||||
|
||||
ResponseStatus sendMessage(const String message);
|
||||
ResponseContainer receiveMessage();
|
||||
ResponseContainer receiveMessageRSSI();
|
||||
|
||||
ResponseStatus sendFixedMessage(byte ADDH, byte ADDL, byte CHAN, const String message);
|
||||
|
||||
ResponseStatus sendFixedMessage(byte ADDH,byte ADDL, byte CHAN, const void *message, const uint8_t size);
|
||||
ResponseStatus sendBroadcastFixedMessage(byte CHAN, const void *message, const uint8_t size);
|
||||
ResponseStatus sendBroadcastFixedMessage(byte CHAN, const String message);
|
||||
|
||||
ResponseContainer receiveInitialMessage(const uint8_t size);
|
||||
|
||||
ResponseStatus sendConfigurationMessage( byte ADDH,byte ADDL, byte CHAN, Configuration *configuration, PROGRAM_COMMAND programCommand = WRITE_CFG_PWR_DWN_SAVE);
|
||||
|
||||
int available();
|
||||
|
||||
void (*setMPins)(int, int);
|
||||
|
||||
private:
|
||||
|
||||
HardwareSerial* hs;
|
||||
|
||||
#ifdef ACTIVATE_SOFTWARE_SERIAL
|
||||
SoftwareSerial* ss;
|
||||
#endif
|
||||
|
||||
bool isSoftwareSerial = true;
|
||||
|
||||
int8_t txE220pin = -1;
|
||||
int8_t rxE220pin = -1;
|
||||
int8_t auxPin = -1;
|
||||
|
||||
#ifdef HARDWARE_SERIAL_SELECTABLE_PIN
|
||||
uint32_t serialConfig = SERIAL_8N1;
|
||||
#endif
|
||||
|
||||
int8_t m0Pin = -1;
|
||||
int8_t m1Pin = -1;
|
||||
|
||||
unsigned long halfKeyloqKey = 0x06660708;
|
||||
unsigned long encrypt(unsigned long data);
|
||||
unsigned long decrypt(unsigned long data);
|
||||
|
||||
UART_BPS_RATE bpsRate = UART_BPS_RATE_9600;
|
||||
|
||||
struct NeedsStream {
|
||||
template<typename T>
|
||||
void begin(T &t, uint32_t baud) {
|
||||
DEBUG_PRINTLN("Begin ");
|
||||
t.setTimeout(500);
|
||||
t.begin(baud);
|
||||
stream = &t;
|
||||
}
|
||||
|
||||
#ifdef HARDWARE_SERIAL_SELECTABLE_PIN
|
||||
// template< typename T >
|
||||
// void begin( T &t, uint32_t baud, SerialConfig config ){
|
||||
// DEBUG_PRINTLN("Begin ");
|
||||
// t.setTimeout(500);
|
||||
// t.begin(baud, config);
|
||||
// stream = &t;
|
||||
// }
|
||||
//
|
||||
template< typename T >
|
||||
void begin( T &t, uint32_t baud, uint32_t config ) {
|
||||
DEBUG_PRINTLN("Begin ");
|
||||
t.setTimeout(500);
|
||||
t.begin(baud, config);
|
||||
stream = &t;
|
||||
}
|
||||
|
||||
template< typename T >
|
||||
void begin( T &t, uint32_t baud, uint32_t config, int8_t txE220pin, int8_t rxE220pin ) {
|
||||
DEBUG_PRINTLN("Begin ");
|
||||
t.setTimeout(500);
|
||||
t.begin(baud, config, txE220pin, rxE220pin);
|
||||
stream = &t;
|
||||
}
|
||||
#endif
|
||||
|
||||
void listen() {}
|
||||
|
||||
Stream *stream;
|
||||
};
|
||||
NeedsStream serialDef;
|
||||
|
||||
MODE_TYPE mode = MODE_0_NORMAL;
|
||||
|
||||
void managedDelay(unsigned long timeout);
|
||||
Status waitCompleteResponse(unsigned long timeout = 1000, unsigned int waitNoAux = 100);
|
||||
void flush();
|
||||
void cleanUARTBuffer();
|
||||
|
||||
Status sendStruct(void *structureManaged, uint16_t size_);
|
||||
Status receiveStruct(void *structureManaged, uint16_t size_);
|
||||
void writeProgramCommand(PROGRAM_COMMAND cmd, REGISTER_ADDRESS addr, PACKET_LENGHT pl);
|
||||
|
||||
RESPONSE_STATUS checkUARTConfiguration(MODE_TYPE mode);
|
||||
|
||||
#ifdef LoRa_E220_DEBUG
|
||||
void printParameters(struct Configuration *configuration);
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
1090
Software/lib/EByte LoRa E220 library/README.md
Normal file
1090
Software/lib/EByte LoRa E220 library/README.md
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,138 @@
|
||||
/*
|
||||
* LoRa E220
|
||||
* Get configuration.
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- 11 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void printParameters(struct Configuration configuration);
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial){};
|
||||
delay(500);
|
||||
|
||||
Serial.println();
|
||||
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
Configuration configuration = *(Configuration*) c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
printParameters(configuration);
|
||||
|
||||
ResponseStructContainer cMi;
|
||||
cMi = e220ttl.getModuleInformation();
|
||||
// It's important get information pointer before all other operation
|
||||
ModuleInformation mi = *(ModuleInformation*)cMi.data;
|
||||
|
||||
Serial.println(cMi.status.getResponseDescription());
|
||||
Serial.println(cMi.status.code);
|
||||
|
||||
printModuleInformation(mi);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
void printParameters(struct Configuration configuration) {
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
|
||||
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
|
||||
Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRateDescription());
|
||||
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
|
||||
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
|
||||
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation) {
|
||||
Serial.println("----------------------------------------");
|
||||
Serial.print(F("HEAD: ")); Serial.print(moduleInformation.COMMAND, HEX);Serial.print(" ");Serial.print(moduleInformation.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(moduleInformation.LENGHT, DEC);
|
||||
|
||||
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
|
||||
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
|
||||
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
||||
|
@ -0,0 +1,417 @@
|
||||
/*
|
||||
* LoRa E220
|
||||
* Set configuration.
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- 11 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void printParameters(struct Configuration configuration);
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while(!Serial){};
|
||||
delay(500);
|
||||
|
||||
Serial.println();
|
||||
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
Configuration configuration = *(Configuration*) c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
printParameters(configuration);
|
||||
|
||||
// ----------------------- DEFAULT TRANSPARENT -----------------------
|
||||
configuration.ADDL = 0x03; // First part of address
|
||||
configuration.ADDH = 0x00; // Second part
|
||||
|
||||
configuration.CHAN = 23; // Communication channel
|
||||
|
||||
configuration.SPED.uartBaudRate = UART_BPS_9600; // Serial baud rate
|
||||
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24; // Air baud rate
|
||||
configuration.SPED.uartParity = MODE_00_8N1; // Parity bit
|
||||
|
||||
configuration.OPTION.subPacketSetting = SPS_200_00; // Packet size
|
||||
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED; // Need to send special command
|
||||
configuration.OPTION.transmissionPower = POWER_22; // Device power
|
||||
|
||||
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED; // Enable RSSI info
|
||||
configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION; // Enable repeater mode
|
||||
configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED; // Check interference
|
||||
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011; // WOR timing
|
||||
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_TRANSPARENT_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- FIXED SENDER -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- FIXED RECEIVER -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- FIXED SENDER RSSI -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- FIXED RECEIVER RSSI -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- WOR SENDER -----------------------
|
||||
// configuration.ADDL = 0x02;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
//
|
||||
// ----------------------- WOR RECEIVER -----------------------
|
||||
// configuration.ADDL = 0x03;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 1 -----------------------
|
||||
// configuration.ADDL = 0x04;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 2 -----------------------
|
||||
// configuration.ADDL = 0x05;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE 3 -----------------------
|
||||
// configuration.ADDL = 0x06;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 1 -----------------------
|
||||
// configuration.ADDL = 0x04;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 2 -----------------------
|
||||
// configuration.ADDL = 0x05;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- BROADCAST MESSAGE RSSI 3 -----------------------
|
||||
// configuration.ADDL = 0x06;
|
||||
// configuration.ADDH = 0x00;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
// ----------------------- MONITORING -----------------------
|
||||
// configuration.ADDL = BROADCAST_ADDRESS;
|
||||
// configuration.ADDH = BROADCAST_ADDRESS;
|
||||
//
|
||||
// configuration.CHAN = 23;
|
||||
//
|
||||
// configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
// configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
// configuration.SPED.uartParity = MODE_00_8N1;
|
||||
//
|
||||
// configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
// configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_DISABLED;
|
||||
// configuration.OPTION.transmissionPower = POWER_22;
|
||||
//
|
||||
// configuration.TRANSMISSION_MODE.enableRSSI = RSSI_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
// configuration.TRANSMISSION_MODE.enableLBT = LBT_DISABLED;
|
||||
// configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
|
||||
// Set configuration changed and set to not hold the configuration
|
||||
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_SAVE);
|
||||
Serial.println(rs.getResponseDescription());
|
||||
Serial.println(rs.code);
|
||||
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
configuration = *(Configuration*) c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
printParameters(configuration);
|
||||
c.close();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
}
|
||||
void printParameters(struct Configuration configuration) {
|
||||
DEBUG_PRINTLN("----------------------------------------");
|
||||
|
||||
DEBUG_PRINT(F("HEAD : ")); DEBUG_PRINT(configuration.COMMAND, HEX);DEBUG_PRINT(" ");DEBUG_PRINT(configuration.STARTING_ADDRESS, HEX);DEBUG_PRINT(" ");DEBUG_PRINTLN(configuration.LENGHT, HEX);
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("AddH : ")); DEBUG_PRINTLN(configuration.ADDH, HEX);
|
||||
DEBUG_PRINT(F("AddL : ")); DEBUG_PRINTLN(configuration.ADDL, HEX);
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("Chan : ")); DEBUG_PRINT(configuration.CHAN, DEC); DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.getChannelDescription());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("SpeedParityBit : ")); DEBUG_PRINT(configuration.SPED.uartParity, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTParityDescription());
|
||||
DEBUG_PRINT(F("SpeedUARTDatte : ")); DEBUG_PRINT(configuration.SPED.uartBaudRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getUARTBaudRateDescription());
|
||||
DEBUG_PRINT(F("SpeedAirDataRate : ")); DEBUG_PRINT(configuration.SPED.airDataRate, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.SPED.getAirDataRateDescription());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("OptionSubPacketSett: ")); DEBUG_PRINT(configuration.OPTION.subPacketSetting, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getSubPacketSetting());
|
||||
DEBUG_PRINT(F("OptionTranPower : ")); DEBUG_PRINT(configuration.OPTION.transmissionPower, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getTransmissionPowerDescription());
|
||||
DEBUG_PRINT(F("OptionRSSIAmbientNo: ")); DEBUG_PRINT(configuration.OPTION.RSSIAmbientNoise, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
DEBUG_PRINTLN(F(" "));
|
||||
DEBUG_PRINT(F("TransModeWORPeriod : ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.WORPeriod, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
DEBUG_PRINT(F("TransModeEnableLBT : ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableLBT, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
DEBUG_PRINT(F("TransModeEnableRSSI: ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.enableRSSI, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
DEBUG_PRINT(F("TransModeFixedTrans: ")); DEBUG_PRINT(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);DEBUG_PRINT(" -> "); DEBUG_PRINTLN(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
|
||||
DEBUG_PRINTLN("----------------------------------------");
|
||||
}
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation) {
|
||||
Serial.println("----------------------------------------");
|
||||
DEBUG_PRINT(F("HEAD: ")); DEBUG_PRINT(moduleInformation.COMMAND, HEX);DEBUG_PRINT(" ");DEBUG_PRINT(moduleInformation.STARTING_ADDRESS, HEX);DEBUG_PRINT(" ");DEBUG_PRINTLN(moduleInformation.LENGHT, DEC);
|
||||
|
||||
Serial.print(F("Model no.: ")); Serial.println(moduleInformation.model, HEX);
|
||||
Serial.print(F("Version : ")); Serial.println(moduleInformation.version, HEX);
|
||||
Serial.print(F("Features : ")); Serial.println(moduleInformation.features, HEX);
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a transparent message, you must check that the transmitter and receiver have the same
|
||||
* CHANNEL ADDL and ADDH
|
||||
*
|
||||
* Pay attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
// If you have ever change configuration you must restore It
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendMessage("Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
e220ttl.sendMessage(input);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,168 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Send a string message to a fixed point ADDH ADDL CHAN
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* Pai attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
// #define DESTINATION_ADDL 3
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void printParameters(struct Configuration configuration);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
Configuration configuration = *(Configuration*) c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
printParameters(configuration);
|
||||
c.close();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void printParameters(struct Configuration configuration) {
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
Serial.print(F("HEAD : ")); Serial.print(configuration.COMMAND, HEX);Serial.print(" ");Serial.print(configuration.STARTING_ADDRESS, HEX);Serial.print(" ");Serial.println(configuration.LENGHT, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("AddH : ")); Serial.println(configuration.ADDH, HEX);
|
||||
Serial.print(F("AddL : ")); Serial.println(configuration.ADDL, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("Chan : ")); Serial.print(configuration.CHAN, DEC); Serial.print(" -> "); Serial.println(configuration.getChannelDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("SpeedParityBit : ")); Serial.print(configuration.SPED.uartParity, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTParityDescription());
|
||||
Serial.print(F("SpeedUARTDatte : ")); Serial.print(configuration.SPED.uartBaudRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getUARTBaudRateDescription());
|
||||
Serial.print(F("SpeedAirDataRate : ")); Serial.print(configuration.SPED.airDataRate, BIN);Serial.print(" -> "); Serial.println(configuration.SPED.getAirDataRateDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("OptionSubPacketSett: ")); Serial.print(configuration.OPTION.subPacketSetting, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getSubPacketSetting());
|
||||
Serial.print(F("OptionTranPower : ")); Serial.print(configuration.OPTION.transmissionPower, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getTransmissionPowerDescription());
|
||||
Serial.print(F("OptionRSSIAmbientNo: ")); Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);Serial.print(" -> "); Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("TransModeWORPeriod : ")); Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
Serial.print(F("TransModeEnableLBT : ")); Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
Serial.print(F("TransModeEnableRSSI: ")); Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
Serial.print(F("TransModeFixedTrans: ")); Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);Serial.print(" -> "); Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
@ -0,0 +1,149 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a structured message to the device that have ADDH ADDL CHAN -> 0 DESTINATION_ADDL 23
|
||||
*
|
||||
* write the int humidity value on serial (or reset device that send default message)
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* Pay attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
#define DESTINATION_ADDL 3
|
||||
#define ROOM "Kitchen"
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
//#define DESTINATION_ADDL 2
|
||||
//#define ROOM "Bath"
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
// #define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
struct Message {
|
||||
char type[5];
|
||||
char message[8];
|
||||
float temperature;
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
struct Message message = {"TEMP", ROOM, 19.2};
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(Message));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessageRSSI(sizeof(Message));
|
||||
#else
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(Message));
|
||||
#endif
|
||||
|
||||
// Is something goes wrong print error
|
||||
if (rsc.status.code!=1){
|
||||
Serial.println(rsc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rsc.status.getResponseDescription());
|
||||
struct Message message = *(Message*) rsc.data;
|
||||
Serial.println(message.type);
|
||||
Serial.println(message.message);
|
||||
Serial.println(message.temperature);
|
||||
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rsc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
struct Message message = { "TEMP", ROOM, 0 };
|
||||
message.temperature = Serial.parseFloat();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(Message));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
@ -0,0 +1,188 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* send a structured message to the device that have ADDH ADDL CHAN -> 0 DESTINATION_ADDL 23
|
||||
*
|
||||
* The receiver read the first part of the packet and undestand the type.
|
||||
* If the type is HUMI read the message and the humidity as int
|
||||
* else read the temperature as float.
|
||||
* I use byte array because some microcontroller can have different size for float
|
||||
*
|
||||
* You must configure 2 device: one as SENDER (with FIXED SENDER config) and uncomment the relative
|
||||
* define with the correct DESTINATION_ADDL, and one as RECEIVER (with FIXED RECEIVER config)
|
||||
* and uncomment the relative define with the correct DESTINATION_ADDL.
|
||||
*
|
||||
* Write a string on serial monitor or reset to resend default value.
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
#define MESSAGE_TYPE "HUMI"
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
//#define DESTINATION_ADDL 3
|
||||
//#define ROOM "Kitchen"
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
#define ROOM "Bathroo"
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
// #define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
struct MessageTemperature {
|
||||
char type[5];
|
||||
char message[8];
|
||||
byte temperature[4];
|
||||
};
|
||||
|
||||
struct MessageHumidity {
|
||||
char type[5];
|
||||
char message[8];
|
||||
byte humidity;
|
||||
};
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
struct MessageHumidity message = { "HUMI", ROOM, 80 };
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageHumidity));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
|
||||
struct MessageTemperature messageT = { "TEMP", ROOM, 0 };
|
||||
*(float*)(messageT.temperature) = 19.2;
|
||||
|
||||
// Send message
|
||||
ResponseStatus rsT = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &messageT, sizeof(MessageTemperature));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rsT.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available() > 1) {
|
||||
// read the String message
|
||||
char type[5]; // first part of structure
|
||||
ResponseContainer rs = e220ttl.receiveInitialMessage(sizeof(type));
|
||||
String typeStr = rs.data;
|
||||
|
||||
// Is something goes wrong print error
|
||||
if (rs.status.code != 1) {
|
||||
Serial.println(rs.status.getResponseDescription());
|
||||
} else {
|
||||
Serial.println(typeStr);
|
||||
if (typeStr == "TEMP") {
|
||||
struct MessageTemperaturePartial {
|
||||
char message[8];
|
||||
byte temperature[4];
|
||||
};
|
||||
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage( sizeof(MessageTemperaturePartial));
|
||||
struct MessageTemperaturePartial message = *(MessageTemperaturePartial*) rsc.data;
|
||||
|
||||
Serial.println(*(float*)(message.temperature));
|
||||
Serial.println(message.message);
|
||||
rsc.close();
|
||||
} else if (typeStr == "HUMI") {
|
||||
struct MessageHumidityPartial {
|
||||
char message[8];
|
||||
byte humidity;
|
||||
};
|
||||
|
||||
ResponseStructContainer rsc = e220ttl.receiveMessage(sizeof(MessageHumidityPartial));
|
||||
struct MessageHumidityPartial message = *(MessageHumidityPartial*) rsc.data;
|
||||
|
||||
Serial.println(message.humidity);
|
||||
Serial.println(message.message);
|
||||
rsc.close();
|
||||
} else {
|
||||
Serial.println("Something goes wrong!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
if (MESSAGE_TYPE == "HUMI") {
|
||||
struct MessageHumidity message = { "HUMI", ROOM, 0 };
|
||||
message.humidity = Serial.parseInt();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageHumidity));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
} else {
|
||||
struct MessageTemperature message = { "TEMP", ROOM, 0 };
|
||||
*(float*)(message.temperature) = Serial.parseFloat();
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, &message, sizeof(MessageTemperature));
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,111 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Send wake up WOR message to a device in Sleep (WOR transmitter)
|
||||
*
|
||||
* You must configure the address with 0 3 23 (FIXED SENDER configuration)
|
||||
* and pay attention that WOR period must be the same of receiver
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or 3.3v) ----- 19 (or 3.3v) ----- 4 (or 3.3v) ----- 2 (or 3.3v) ----- 10 (or 3.3v) ----- PB0 (or 3.3v) ----- 7 Volt div (or 3.3v)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED SENDER configuration
|
||||
#define DESTINATION_ADDL 3
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
|
||||
e220ttl.setMode(MODE_1_WOR_TRANSMITTER);
|
||||
|
||||
Serial.println("Hi, I'm going to send WOR message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "Hello, world? WOR!");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
|
||||
// e220ttl.setMode(MODE_0_NORMAL);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,137 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
* Stay in sleep mode and wait a wake up WOR message
|
||||
*
|
||||
* You must configure the address with 0 2 23 (FIXED RECEIVER configuration)
|
||||
* and pay attention that WOR period must be the same of sender
|
||||
*
|
||||
* You must uncommend the correct constructor and set the correct AUX_PIN define.
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or 3.3v) ----- 21 (or 3.3v) ----- 6 (or 3.3v) ----- 4 (or 3.3v) ----- PB10 (or 3.3v) ----- 6 Volt div (or 3.3v)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// With FIXED RECEIVER configuration
|
||||
#define DESTINATION_ADDL 2
|
||||
|
||||
#define AUX_PIN 15
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
bool interruptExecuted = false;
|
||||
#ifdef ESP32
|
||||
void IRAM_ATTR wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#elif define(ESP8266)
|
||||
ICACHE_RAM_ATTR void wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#else
|
||||
void wakeUp() {
|
||||
// Do not use Serial on interrupt callback
|
||||
interruptExecuted = true;
|
||||
detachInterrupt(AUX_PIN);
|
||||
}
|
||||
#endif
|
||||
|
||||
//The setup function is called once at startup of the sketch
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
while (!Serial) {
|
||||
; // wait for serial port to connect. Needed for native USB
|
||||
}
|
||||
delay(100);
|
||||
|
||||
e220ttl.begin();
|
||||
|
||||
e220ttl.setMode(MODE_2_WOR_RECEIVER);
|
||||
|
||||
delay(1000);
|
||||
Serial.println();
|
||||
Serial.println("Start sleep!");
|
||||
delay(100);
|
||||
attachInterrupt(AUX_PIN, wakeUp, FALLING);
|
||||
}
|
||||
|
||||
// The loop function is called in an endless loop
|
||||
void loop() {
|
||||
if (e220ttl.available() > 1) {
|
||||
Serial.println("Message arrived!");
|
||||
ResponseContainer rs = e220ttl.receiveMessage();
|
||||
// First of all get the data
|
||||
String message = rs.data;
|
||||
|
||||
Serial.println(rs.status.getResponseDescription());
|
||||
Serial.println(message);
|
||||
|
||||
// Work only with full connection
|
||||
e220ttl.setMode(MODE_0_NORMAL);
|
||||
|
||||
delay(1000);
|
||||
|
||||
ResponseStatus rsSend = e220ttl.sendFixedMessage(0, DESTINATION_ADDL, 23, "We have received the message!");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rsSend.getResponseDescription());
|
||||
}
|
||||
|
||||
if(interruptExecuted) {
|
||||
Serial.println("WakeUp Callback, AUX pin go LOW and start receive message!");
|
||||
Serial.flush();
|
||||
interruptExecuted = false;
|
||||
}
|
||||
}
|
@ -0,0 +1,105 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
*
|
||||
* Receive messages on CHANNEL 23
|
||||
* Uncomment #define ENABLE_RSSI true in this sketch
|
||||
* if the sender send RSSI also
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// If you want use RSSI uncomment
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Start receiving!");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
Serial.println("Message received!");
|
||||
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,128 @@
|
||||
/*
|
||||
* EBYTE LoRa E220
|
||||
*
|
||||
* Send a string message to all devices of the Channel CHAN 23
|
||||
*
|
||||
* Write a string on serial monitor or reset to send the string to all device on channel 23.
|
||||
*
|
||||
* Send a fixed message, you must check that the transmitter and receiver have different
|
||||
* ADDL or ADDH, check the configuration down
|
||||
*
|
||||
* For the test you can use
|
||||
* - BROADCAST MESSAGE 1
|
||||
* - BROADCAST MESSAGE 2
|
||||
* - BROADCAST MESSAGE 3
|
||||
*
|
||||
* Pai attention e220 support RSSI, if you want use that functionality you must enable RSSI on configuration
|
||||
* configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
*
|
||||
* and uncomment #define ENABLE_RSSI true in this sketch
|
||||
*
|
||||
* by Renzo Mischianti <https://www.mischianti.org>
|
||||
*
|
||||
* https://www.mischianti.org
|
||||
*
|
||||
* E220 ----- WeMos D1 mini ----- esp32 ----- Arduino Nano 33 IoT ----- Arduino MKR ----- Raspberry Pi Pico ----- stm32 ----- ArduinoUNO
|
||||
* M0 ----- D7 (or GND) ----- 19 (or GND) ----- 4 (or GND) ----- 2 (or GND) ----- 10 (or GND) ----- PB0 (or GND) ----- 7 Volt div (or GND)
|
||||
* M1 ----- D6 (or GND) ----- 21 (or GND) ----- 6 (or GND) ----- 4 (or GND) ----- 11 (or GND) ----- PB10 (or GND) ----- 6 Volt div (or GND)
|
||||
* TX ----- D3 (PullUP) ----- TX2 (PullUP) ----- TX1 (PullUP) ----- 14 (PullUP) ----- 8 (PullUP) ----- PA2 TX2 (PullUP) ----- 4 (PullUP)
|
||||
* RX ----- D4 (PullUP) ----- RX2 (PullUP) ----- RX1 (PullUP) ----- 13 (PullUP) ----- 9 (PullUP) ----- PA3 RX2 (PullUP) ----- 5 Volt div (PullUP)
|
||||
* AUX ----- D5 (PullUP) ----- 18 (PullUP) ----- 2 (PullUP) ----- 0 (PullUP) ----- 2 (PullUP) ----- PA0 (PullUP) ----- 3 (PullUP)
|
||||
* VCC ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v ----- 3.3v/5v
|
||||
* GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND ----- GND
|
||||
*
|
||||
*/
|
||||
|
||||
// If you want use RSSI uncomment //#define ENABLE_RSSI true
|
||||
// and use relative configuration with RSSI enabled
|
||||
//#define ENABLE_RSSI true
|
||||
|
||||
#include "Arduino.h"
|
||||
#include "LoRa_E220.h"
|
||||
|
||||
// ---------- esp8266 pins --------------
|
||||
//LoRa_E220 e220ttl(RX, TX, AUX, M0, M1); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
LoRa_E220 e220ttl(D3, D4, D5, D7, D6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(D2, D3); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(D2, D3); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, D5, D7, D6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Arduino pins --------------
|
||||
//LoRa_E220 e220ttl(4, 5, 3, 7, 6); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
//LoRa_E220 e220ttl(4, 5); // Config without connect AUX and M0 M1
|
||||
|
||||
//#include <SoftwareSerial.h>
|
||||
//SoftwareSerial mySerial(4, 5); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX
|
||||
//LoRa_E220 e220ttl(&mySerial, 3, 7, 6); // AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ------------- Arduino Nano 33 IoT -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 2, 4, 6); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ------------- Arduino MKR WiFi 1010 -------------
|
||||
// LoRa_E220 e220ttl(&Serial1, 0, 2, 4); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
// ---------- esp32 pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 15, 21, 19); // RX AUX M0 M1
|
||||
|
||||
//LoRa_E220 e220ttl(&Serial2, 22, 4, 18, 21, 19, UART_BPS_RATE_9600); // esp32 RX <-- e220 TX, esp32 TX --> e220 RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------- Raspberry PI Pico pins --------------
|
||||
// LoRa_E220 e220ttl(&Serial2, 2, 10, 11); // RX AUX M0 M1
|
||||
// -------------------------------------
|
||||
|
||||
// ---------------- STM32 --------------------
|
||||
//HardwareSerial Serial2(USART2); // PA3 (RX) PA2 (TX)
|
||||
//LoRa_E220 e220ttl(&Serial2, PA0, PB0, PB10); // RX AUX M0 M1
|
||||
// -------------------------------------------------
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
delay(500);
|
||||
|
||||
// Startup all pins and UART
|
||||
e220ttl.begin();
|
||||
|
||||
Serial.println("Hi, I'm going to send message!");
|
||||
|
||||
// Send message
|
||||
ResponseStatus rs = e220ttl.sendBroadcastFixedMessage(23, "Hello, world?");
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// If something available
|
||||
if (e220ttl.available()>1) {
|
||||
// read the String message
|
||||
#ifdef ENABLE_RSSI
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
#else
|
||||
ResponseContainer rc = e220ttl.receiveMessage();
|
||||
#endif
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code!=1){
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}else{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
#ifdef ENABLE_RSSI
|
||||
Serial.print("RSSI: "); Serial.println(rc.rssi, DEC);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (Serial.available()) {
|
||||
String input = Serial.readString();
|
||||
ResponseStatus rs = e220ttl.sendBroadcastFixedMessage(23, input);
|
||||
// Check If there is some problem of succesfully send
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
}
|
||||
|
461
Software/lib/EByte LoRa E220 library/includes/statesNaming.h
Normal file
461
Software/lib/EByte LoRa E220 library/includes/statesNaming.h
Normal file
@ -0,0 +1,461 @@
|
||||
#include "Arduino.h"
|
||||
|
||||
#ifdef FREQUENCY_433
|
||||
#define OPERATING_FREQUENCY 410
|
||||
#elif defined(FREQUENCY_400)
|
||||
#define OPERATING_FREQUENCY 410
|
||||
#elif defined(FREQUENCY_230)
|
||||
#define OPERATING_FREQUENCY 220
|
||||
#elif defined(FREQUENCY_868)
|
||||
#define OPERATING_FREQUENCY 850
|
||||
#elif defined(FREQUENCY_915)
|
||||
#define OPERATING_FREQUENCY 850
|
||||
#else
|
||||
#define OPERATING_FREQUENCY 410
|
||||
#endif
|
||||
|
||||
#define BROADCAST_ADDRESS 255
|
||||
|
||||
typedef enum RESPONSE_STATUS {
|
||||
#ifndef ARDUINO_ARCH_STM32
|
||||
SUCCESS = 1,
|
||||
#endif
|
||||
E220_SUCCESS = 1,
|
||||
ERR_E220_UNKNOWN, /* something shouldn't happened */
|
||||
ERR_E220_NOT_SUPPORT,
|
||||
ERR_E220_NOT_IMPLEMENT,
|
||||
ERR_E220_NOT_INITIAL,
|
||||
ERR_E220_INVALID_PARAM,
|
||||
ERR_E220_DATA_SIZE_NOT_MATCH,
|
||||
ERR_E220_BUF_TOO_SMALL,
|
||||
ERR_E220_TIMEOUT,
|
||||
ERR_E220_HARDWARE,
|
||||
ERR_E220_HEAD_NOT_RECOGNIZED,
|
||||
ERR_E220_NO_RESPONSE_FROM_DEVICE,
|
||||
ERR_E220_WRONG_UART_CONFIG,
|
||||
ERR_E220_WRONG_FORMAT,
|
||||
ERR_E220_PACKET_TOO_BIG
|
||||
} Status;
|
||||
|
||||
static String getResponseDescriptionByParams(byte status){
|
||||
switch (status)
|
||||
{
|
||||
case E220_SUCCESS:
|
||||
return F("Success");
|
||||
break;
|
||||
case ERR_E220_UNKNOWN:
|
||||
return F("Unknown");
|
||||
break;
|
||||
case ERR_E220_NOT_SUPPORT:
|
||||
return F("Not support!");
|
||||
break;
|
||||
case ERR_E220_NOT_IMPLEMENT:
|
||||
return F("Not implement");
|
||||
break;
|
||||
case ERR_E220_NOT_INITIAL:
|
||||
return F("Not initial!");
|
||||
break;
|
||||
case ERR_E220_INVALID_PARAM:
|
||||
return F("Invalid param!");
|
||||
break;
|
||||
case ERR_E220_DATA_SIZE_NOT_MATCH:
|
||||
return F("Data size not match!");
|
||||
break;
|
||||
case ERR_E220_BUF_TOO_SMALL:
|
||||
return F("Buff too small!");
|
||||
break;
|
||||
case ERR_E220_TIMEOUT:
|
||||
return F("Timeout!!");
|
||||
break;
|
||||
case ERR_E220_HARDWARE:
|
||||
return F("Hardware error!");
|
||||
break;
|
||||
case ERR_E220_HEAD_NOT_RECOGNIZED:
|
||||
return F("Save mode returned not recognized!");
|
||||
break;
|
||||
case ERR_E220_NO_RESPONSE_FROM_DEVICE:
|
||||
return F("No response from device! (Check wiring)");
|
||||
break;
|
||||
case ERR_E220_WRONG_UART_CONFIG:
|
||||
return F("Wrong UART configuration! (BPS must be 9600 for configuration)");
|
||||
break;
|
||||
case ERR_E220_PACKET_TOO_BIG:
|
||||
return F("The device support only 200byte of data transmission!");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid status!");
|
||||
}
|
||||
}
|
||||
|
||||
enum UART_PARITY
|
||||
{
|
||||
MODE_00_8N1 = 0b00,
|
||||
MODE_01_8O1 = 0b01,
|
||||
MODE_10_8E1 = 0b10,
|
||||
MODE_11_8N1 = 0b11
|
||||
};
|
||||
|
||||
static String getUARTParityDescriptionByParams(byte uartParity){
|
||||
switch (uartParity)
|
||||
{
|
||||
case MODE_00_8N1:
|
||||
return F("8N1 (Default)");
|
||||
break;
|
||||
case MODE_01_8O1:
|
||||
return F("8O1");
|
||||
break;
|
||||
case MODE_10_8E1:
|
||||
return F("8E1");
|
||||
break;
|
||||
case MODE_11_8N1:
|
||||
return F("8N1 (equal to 00");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid UART Parity!");
|
||||
}
|
||||
}
|
||||
|
||||
enum UART_BPS_TYPE
|
||||
{
|
||||
UART_BPS_1200 = 0b000,
|
||||
UART_BPS_2400 = 0b001,
|
||||
UART_BPS_4800 = 0b010,
|
||||
UART_BPS_9600 = 0b011,
|
||||
UART_BPS_19200 = 0b100,
|
||||
UART_BPS_38400 = 0b101,
|
||||
UART_BPS_57600 = 0b110,
|
||||
UART_BPS_115200 = 0b111
|
||||
};
|
||||
|
||||
enum UART_BPS_RATE
|
||||
{
|
||||
UART_BPS_RATE_1200 = 1200,
|
||||
UART_BPS_RATE_2400 = 2400,
|
||||
UART_BPS_RATE_4800 = 4800,
|
||||
UART_BPS_RATE_9600 = 9600,
|
||||
UART_BPS_RATE_19200 = 19200,
|
||||
UART_BPS_RATE_38400 = 38400,
|
||||
UART_BPS_RATE_57600 = 57600,
|
||||
UART_BPS_RATE_115200 = 115200
|
||||
};
|
||||
|
||||
static String getUARTBaudRateDescriptionByParams(byte uartBaudRate)
|
||||
{
|
||||
switch (uartBaudRate)
|
||||
{
|
||||
case UART_BPS_1200:
|
||||
return F("1200bps");
|
||||
break;
|
||||
case UART_BPS_2400:
|
||||
return F("2400bps");
|
||||
break;
|
||||
case UART_BPS_4800:
|
||||
return F("4800bps");
|
||||
break;
|
||||
case UART_BPS_9600:
|
||||
return F("9600bps (default)");
|
||||
break;
|
||||
case UART_BPS_19200:
|
||||
return F("19200bps");
|
||||
break;
|
||||
case UART_BPS_38400:
|
||||
return F("38400bps");
|
||||
break;
|
||||
case UART_BPS_57600:
|
||||
return F("57600bps");
|
||||
break;
|
||||
case UART_BPS_115200:
|
||||
return F("115200bps");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid UART Baud Rate!");
|
||||
}
|
||||
}
|
||||
|
||||
enum AIR_DATA_RATE
|
||||
{
|
||||
AIR_DATA_RATE_000_24 = 0b000,
|
||||
AIR_DATA_RATE_001_24 = 0b001,
|
||||
AIR_DATA_RATE_010_24 = 0b010,
|
||||
AIR_DATA_RATE_011_48 = 0b011,
|
||||
AIR_DATA_RATE_100_96 = 0b100,
|
||||
AIR_DATA_RATE_101_192 = 0b101,
|
||||
AIR_DATA_RATE_110_384 = 0b110,
|
||||
AIR_DATA_RATE_111_625 = 0b111
|
||||
};
|
||||
|
||||
|
||||
static String getAirDataRateDescriptionByParams(byte airDataRate)
|
||||
{
|
||||
switch (airDataRate)
|
||||
{
|
||||
case AIR_DATA_RATE_000_24:
|
||||
return F("2.4kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_001_24:
|
||||
return F("2.4kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_010_24:
|
||||
return F("2.4kbps (default)");
|
||||
break;
|
||||
case AIR_DATA_RATE_011_48:
|
||||
return F("4.8kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_100_96:
|
||||
return F("9.6kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_101_192:
|
||||
return F("19.2kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_110_384:
|
||||
return F("38.4kbps");
|
||||
break;
|
||||
case AIR_DATA_RATE_111_625:
|
||||
return F("62.5kbps");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid Air Data Rate!");
|
||||
}
|
||||
}
|
||||
|
||||
enum SUB_PACKET_SETTING {
|
||||
SPS_200_00 = 0b00,
|
||||
SPS_128_01 = 0b01,
|
||||
SPS_064_10 = 0b10,
|
||||
SPS_032_11 = 0b11
|
||||
|
||||
};
|
||||
static String getSubPacketSettingByParams(byte subPacketSetting)
|
||||
{
|
||||
switch (subPacketSetting)
|
||||
{
|
||||
case SPS_200_00:
|
||||
return F("200bytes (default)");
|
||||
break;
|
||||
case SPS_128_01:
|
||||
return F("128bytes");
|
||||
break;
|
||||
case SPS_064_10:
|
||||
return F("64bytes");
|
||||
break;
|
||||
case SPS_032_11:
|
||||
return F("32bytes");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid Sub Packet Setting!");
|
||||
}
|
||||
}
|
||||
|
||||
enum RSSI_AMBIENT_NOISE_ENABLE {
|
||||
RSSI_AMBIENT_NOISE_ENABLED = 0b1,
|
||||
RSSI_AMBIENT_NOISE_DISABLED = 0b0
|
||||
};
|
||||
static String getRSSIAmbientNoiseEnableByParams(byte rssiAmbientNoiseEnabled)
|
||||
{
|
||||
switch (rssiAmbientNoiseEnabled)
|
||||
{
|
||||
case RSSI_AMBIENT_NOISE_ENABLED:
|
||||
return F("Enabled");
|
||||
break;
|
||||
case RSSI_AMBIENT_NOISE_DISABLED:
|
||||
return F("Disabled (default)");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid RSSI Ambient Noise enabled!");
|
||||
}
|
||||
}
|
||||
|
||||
enum WOR_PERIOD {
|
||||
WOR_500_000 = 0b000,
|
||||
WOR_1000_001 = 0b001,
|
||||
WOR_1500_010 = 0b010,
|
||||
WOR_2000_011 = 0b011,
|
||||
WOR_2500_100 = 0b100,
|
||||
WOR_3000_101 = 0b101,
|
||||
WOR_3500_110 = 0b110,
|
||||
WOR_4000_111 = 0b111
|
||||
|
||||
};
|
||||
static String getWORPeriodByParams(byte WORPeriod)
|
||||
{
|
||||
switch (WORPeriod)
|
||||
{
|
||||
case WOR_500_000:
|
||||
return F("500ms");
|
||||
break;
|
||||
case WOR_1000_001:
|
||||
return F("1000ms");
|
||||
break;
|
||||
case WOR_1500_010:
|
||||
return F("1500ms");
|
||||
break;
|
||||
case WOR_2000_011:
|
||||
return F("2000ms (default)");
|
||||
break;
|
||||
case WOR_2500_100:
|
||||
return F("2500ms");
|
||||
break;
|
||||
case WOR_3000_101:
|
||||
return F("3000ms");
|
||||
break;
|
||||
case WOR_3500_110:
|
||||
return F("3500ms");
|
||||
break;
|
||||
case WOR_4000_111:
|
||||
return F("4000ms");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid WOR period!");
|
||||
}
|
||||
}
|
||||
enum LBT_ENABLE_BYTE {
|
||||
LBT_ENABLED = 0b1,
|
||||
LBT_DISABLED = 0b0
|
||||
};
|
||||
static String getLBTEnableByteByParams(byte LBTEnableByte)
|
||||
{
|
||||
switch (LBTEnableByte)
|
||||
{
|
||||
case LBT_ENABLED:
|
||||
return F("Enabled");
|
||||
break;
|
||||
case LBT_DISABLED:
|
||||
return F("Disabled (default)");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid LBT enable byte!");
|
||||
}
|
||||
}
|
||||
|
||||
enum RSSI_ENABLE_BYTE {
|
||||
RSSI_ENABLED = 0b1,
|
||||
RSSI_DISABLED = 0b0
|
||||
};
|
||||
static String getRSSIEnableByteByParams(byte RSSIEnableByte)
|
||||
{
|
||||
switch (RSSIEnableByte)
|
||||
{
|
||||
case RSSI_ENABLED:
|
||||
return F("Enabled");
|
||||
break;
|
||||
case RSSI_DISABLED:
|
||||
return F("Disabled (default)");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid RSSI enable byte!");
|
||||
}
|
||||
}
|
||||
|
||||
enum FIDEX_TRANSMISSION
|
||||
{
|
||||
FT_TRANSPARENT_TRANSMISSION = 0b0,
|
||||
FT_FIXED_TRANSMISSION = 0b1
|
||||
};
|
||||
|
||||
|
||||
static String getFixedTransmissionDescriptionByParams(byte fixedTransmission)
|
||||
{
|
||||
switch (fixedTransmission)
|
||||
{
|
||||
case FT_TRANSPARENT_TRANSMISSION:
|
||||
return F("Transparent transmission (default)");
|
||||
break;
|
||||
case FT_FIXED_TRANSMISSION:
|
||||
return F("Fixed transmission (first three bytes can be used as high/low address and channel)");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid fixed transmission param!");
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef E220_22
|
||||
enum TRANSMISSION_POWER
|
||||
{
|
||||
POWER_22 = 0b00,
|
||||
POWER_17 = 0b01,
|
||||
POWER_13 = 0b10,
|
||||
POWER_10 = 0b11
|
||||
|
||||
};
|
||||
|
||||
static String getTransmissionPowerDescriptionByParams(byte transmissionPower)
|
||||
{
|
||||
switch (transmissionPower)
|
||||
{
|
||||
case POWER_22:
|
||||
return F("22dBm (Default)");
|
||||
break;
|
||||
case POWER_17:
|
||||
return F("17dBm");
|
||||
break;
|
||||
case POWER_13:
|
||||
return F("13dBm");
|
||||
break;
|
||||
case POWER_10:
|
||||
return F("10dBm");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid transmission power param");
|
||||
}
|
||||
}
|
||||
#elif defined(E220_30)
|
||||
enum TRANSMISSION_POWER
|
||||
{
|
||||
POWER_30 = 0b00,
|
||||
POWER_27 = 0b01,
|
||||
POWER_24 = 0b10,
|
||||
POWER_21 = 0b11
|
||||
|
||||
};
|
||||
|
||||
static String getTransmissionPowerDescriptionByParams(byte transmissionPower)
|
||||
{
|
||||
switch (transmissionPower)
|
||||
{
|
||||
case POWER_30:
|
||||
return F("30dBm (Default)");
|
||||
break;
|
||||
case POWER_27:
|
||||
return F("27dBm");
|
||||
break;
|
||||
case POWER_24:
|
||||
return F("24dBm");
|
||||
break;
|
||||
case POWER_21:
|
||||
return F("21dBm");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid transmission power param");
|
||||
}
|
||||
}
|
||||
#else
|
||||
enum TRANSMISSION_POWER
|
||||
{
|
||||
POWER_22 = 0b00,
|
||||
POWER_17 = 0b01,
|
||||
POWER_13 = 0b10,
|
||||
POWER_10 = 0b11
|
||||
|
||||
};
|
||||
|
||||
static String getTransmissionPowerDescriptionByParams(byte transmissionPower)
|
||||
{
|
||||
switch (transmissionPower)
|
||||
{
|
||||
case POWER_22:
|
||||
return F("22dBm (Default)");
|
||||
break;
|
||||
case POWER_17:
|
||||
return F("17dBm");
|
||||
break;
|
||||
case POWER_13:
|
||||
return F("13dBm");
|
||||
break;
|
||||
case POWER_10:
|
||||
return F("10dBm");
|
||||
break;
|
||||
default:
|
||||
return F("Invalid transmission power param");
|
||||
}
|
||||
}
|
||||
#endif
|
30
Software/lib/EByte LoRa E220 library/keywords.txt
Normal file
30
Software/lib/EByte LoRa E220 library/keywords.txt
Normal file
@ -0,0 +1,30 @@
|
||||
###########################################
|
||||
# Syntax Coloring Map For LoRa_E32_Series-library
|
||||
###########################################
|
||||
|
||||
###########################################
|
||||
# Datatypes (KEYWORD1)
|
||||
###########################################
|
||||
|
||||
LoRa_E220 KEYWORD1
|
||||
|
||||
###########################################
|
||||
# Methods and Functions (KEYWORD2)
|
||||
###########################################
|
||||
|
||||
begin KEYWORD2
|
||||
|
||||
getConfiguration KEYWORD2
|
||||
setConfiguration KEYWORD2
|
||||
|
||||
getModuleInformation KEYWORD2
|
||||
printParameters KEYWORD2
|
||||
resetModule KEYWORD2
|
||||
|
||||
sendMessage KEYWORD2
|
||||
receiveMessage KEYWORD2
|
||||
|
||||
sendFixedMessage KEYWORD2
|
||||
sendBroadcastFixedMessage KEYWORD2
|
||||
|
||||
receiveInitialMessage KEYWORD2
|
11
Software/lib/EByte LoRa E220 library/library.properties
Normal file
11
Software/lib/EByte LoRa E220 library/library.properties
Normal file
@ -0,0 +1,11 @@
|
||||
name=EByte LoRa E220 library
|
||||
version=1.0.6
|
||||
author=Renzo Mischianti <renzo.mischianti@gmail.com>
|
||||
maintainer=Renzo Mischianti <renzo.mischianti@gmail.com>
|
||||
sentence=LoRa EBYTE E220 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico. LLCC68
|
||||
paragraph=Ebyte E220 LoRa (Long Range) library device very cheap and very long range (from 5Km to 10Km). Arduino LoRa EBYTE E220 device library complete and tested with Arduino, esp8266, esp32, STM32 and Raspberry Pi Pico. LLCC68
|
||||
category=Communication
|
||||
url=https://www.mischianti.org/category/my-libraries/ebyte-lora-e22-devices/
|
||||
repository=https://github.com/xreef/EByte_LoRa_E220_Series_Library
|
||||
architectures=*
|
||||
includes=LoRa_E220.h
|
@ -13,13 +13,14 @@ extra_configs =
|
||||
wifi_credentials.ini
|
||||
|
||||
[env:de-timer]
|
||||
platform = espressif32
|
||||
board = ttgo-lora32-v1
|
||||
platform = espressif8266
|
||||
framework = arduino
|
||||
board = d1_mini
|
||||
board_build.filesystem = littlefs
|
||||
;board_build.f_flash = 80000000L
|
||||
;board_build.ldscript = eagle.flash.4m1m.ld
|
||||
|
||||
monitor_filters = esp32_exception_decoder
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
monitor_speed = 115200
|
||||
|
||||
upload_protocol = esptool
|
||||
@ -30,7 +31,6 @@ upload_speed = 921600
|
||||
; --auth=${wifi_cred.admin_password}
|
||||
|
||||
build_type = debug
|
||||
|
||||
build_flags=
|
||||
!python git_rev_macro.py
|
||||
-DSERIAL_DEBUG
|
||||
@ -46,16 +46,14 @@ build_flags=
|
||||
-DFACTION_2_NAME='"MILIZ"'
|
||||
-DFACTION_3_NAME='"KGG"'
|
||||
|
||||
framework = arduino
|
||||
lib_deps =
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
;me-no-dev/ESP Async WebServer @ ^1.2.3 ; local version included due to bug
|
||||
me-no-dev/AsyncTCP @ ^1.1.1
|
||||
sstaub/Ticker @ ^4.2.0
|
||||
;xreef/EByte LoRa E220 library@^1.0.6 ;made Lib local, due to changes for I2C-controller M0,M1-Pins
|
||||
sstaub/Ticker@^4.4.0
|
||||
robtillaart/PCF8574 @ ^0.3.7
|
||||
adafruit/Adafruit INA219 @ ^1.1.1
|
||||
plerup/EspSoftwareSerial @ 6.8.5 ; needed exactly this Version as newer ones have Problems with compiling
|
||||
smougenot/TM1637@0.0.0-alpha+sha.9486982048
|
||||
me-no-dev/ESPAsyncTCP @ ^1.2.2
|
||||
robtillaart/I2C_EEPROM @ ^1.5.2
|
||||
sandeepmistry/LoRa @ ^0.8.0
|
||||
adafruit/Adafruit SSD1306 @ ^2.4.0
|
||||
adafruit/Adafruit GFX Library @ ^1.10.1
|
||||
adafruit/Adafruit BusIO @ ^1.5.0
|
||||
bblanchon/ArduinoJson @ ^6.19.4
|
@ -1,25 +1,41 @@
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define Q(x) #x
|
||||
#define QUOTE(x) Q(x)
|
||||
|
||||
// Module connection pins (ESP GPIO-Nums)
|
||||
#define CLK 12
|
||||
#define DIO_FAC_1_7SEG 13
|
||||
#define DIO_FAC_2_7SEG 17
|
||||
#define DIO_FAC_3_7SEG 21
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define DIO_FAC_1_TRG 36
|
||||
#define HOST_NAME "AirsoftTimer_%08X"
|
||||
|
||||
#define GPIO_LORA_TX D3
|
||||
#define GPIO_LORA_RX D4
|
||||
#define GPIO_LORA_AUX D0
|
||||
|
||||
#define GPIO_7SEG_EN_FAC1 D5
|
||||
#define GPIO_7SEG_EN_FAC2 D6
|
||||
#define GPIO_7SEG_EN_FAC3 D7
|
||||
#define GPIO_7SEG_CLK D8
|
||||
|
||||
#define I2C_IO_BTN_FAC1 0
|
||||
#define FAC_1_TRG_PRESSED LOW
|
||||
#define DIO_FAC_2_TRG 37
|
||||
#define I2C_IO_BTN_FAC2 1
|
||||
#define FAC_2_TRG_PRESSED LOW
|
||||
#define DIO_FAC_3_TRG 38
|
||||
#define I2C_IO_BTN_FAC3 2
|
||||
#define FAC_3_TRG_PRESSED LOW
|
||||
|
||||
#ifndef HOST_NAME
|
||||
#define HOST_NAME "DE_Timer_%06X" // Use printf-Formatting - Chip-ID (uin32_t) will be added
|
||||
#endif
|
||||
#define I2C_IO_LORA_M0 4
|
||||
#define I2C_IO_LORA_M1 3
|
||||
|
||||
#define EEPROM_TYPE 24LC64
|
||||
|
||||
#define I2C_IO_ADDRESS 0x38
|
||||
#define I2C_POWER_ADDRESS 0x40
|
||||
#define I2C_EEPROM_ADDRESS 0x50
|
||||
|
||||
#ifndef OTA_DELAY
|
||||
#define OTA_DELAY 50 // ticks -> 10ms / tick
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include "lora_net.h"
|
||||
|
||||
uint8_t LoRa_Init()
|
||||
{
|
||||
uint8_t success = false;
|
||||
// SPI LoRa pins
|
||||
SPI.begin(LORA_SCK, LORA_MISO, LORA_MOSI, LORA_SS);
|
||||
// setup LoRa transceiver module
|
||||
LoRa.setPins(LORA_SS, LORA_RST, LORA_DIO0);
|
||||
|
||||
if (!LoRa.begin(LORA_BAND))
|
||||
{
|
||||
Serial.println("Starting LoRa failed!");
|
||||
success = false;
|
||||
}
|
||||
Serial.println("LoRa Initializing OK!");
|
||||
success = true;
|
||||
|
||||
return success;
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
#ifndef _LORA_NET_H_
|
||||
#define _LORA_NET_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <SPI.h>
|
||||
#include <LoRa.h>
|
||||
|
||||
// define the pins used by the LoRa transceiver module
|
||||
#define LORA_SCK 5
|
||||
#define LORA_MISO 19
|
||||
#define LORA_MOSI 27
|
||||
#define LORA_SS 18
|
||||
#define LORA_RST 14
|
||||
#define LORA_DIO0 26
|
||||
|
||||
// 433E6 for Asia
|
||||
// 866E6 for Europe
|
||||
// 915E6 for North America
|
||||
#define LORA_BAND 8681E5
|
||||
|
||||
uint8_t LoRa_Init();
|
||||
|
||||
#endif
|
@ -1,26 +1,29 @@
|
||||
#define FREQUENCY_868
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <TM1637Display.h>
|
||||
#include <Ticker.h>
|
||||
#include <DNSServer.h>
|
||||
#include <WiFi.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPmDNS.h>
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <ArduinoOTA.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <LittleFS.h>
|
||||
#include <PCF8574.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_INA219.h>
|
||||
#include <ArduinoJson.h>
|
||||
#include <LoRa_E220.h>
|
||||
|
||||
// local includes
|
||||
#include "lora_messages.h"
|
||||
#include "defaults.h"
|
||||
#include "webui.h"
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
#include "lora_net.h"
|
||||
#include "oled_display.h"
|
||||
|
||||
#ifdef WIFI_CLIENT
|
||||
#include <WiFiMulti.h>
|
||||
@ -32,41 +35,46 @@ const uint32_t connectTimeoutMs = 5000;
|
||||
WiFiMulti wifiMulti;
|
||||
#endif
|
||||
|
||||
void SevenSeg_Output();
|
||||
void FactionTicker_callback();
|
||||
void inputGetterTicker_callback();
|
||||
void powerMonitorTicker_callback();
|
||||
void EEPROMCyclicPDS_callback();
|
||||
void toggleWiFiAP(boolean shutdown = false);
|
||||
void SystemShutdown();
|
||||
void SetBatteryType(batteryType_t type);
|
||||
void ProcessKeyCombos();
|
||||
void OverrideDisplay(const uint8_t *message, uint32_t time);
|
||||
void LoRaPublish_callback();
|
||||
|
||||
#ifdef WIFI_CLIENT
|
||||
void wifiMaintainConnectionTicker_callback();
|
||||
Ticker WiFiMaintainConnectionTicker(wifiMaintainConnectionTicker_callback, 1000, 0, MILLIS);
|
||||
#endif
|
||||
|
||||
uint32_t getESPChipID();
|
||||
|
||||
TM1637Display disp_FAC_1(CLK, DIO_FAC_1_7SEG);
|
||||
TM1637Display disp_FAC_2(CLK, DIO_FAC_2_7SEG);
|
||||
TM1637Display disp_FAC_3(CLK, DIO_FAC_3_7SEG);
|
||||
|
||||
PCF8574 i2c_io(I2C_IO_ADDRESS);
|
||||
Adafruit_INA219 ina219;
|
||||
LoRa_E220 e220ttl(GPIO_LORA_TX, GPIO_LORA_RX, GPIO_LORA_AUX, 3, 4); // Arduino RX <-- e220 TX, Arduino TX --> e220 RX AUX M0 M1
|
||||
|
||||
TM1637Display disp_FAC_1(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC1);
|
||||
TM1637Display disp_FAC_2(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC2);
|
||||
TM1637Display disp_FAC_3(GPIO_7SEG_CLK, GPIO_7SEG_EN_FAC3);
|
||||
|
||||
#ifdef CAPTIVE
|
||||
DNSServer dnsServer;
|
||||
#endif
|
||||
AsyncWebServer server(80);
|
||||
|
||||
Ticker FactionTicker(FactionTicker_callback, 1000, 0, MILLIS);
|
||||
Ticker InputGetterTicker(inputGetterTicker_callback, 250, 0, MILLIS);
|
||||
Ticker PowerMonitorTicker(powerMonitorTicker_callback, 5000, 0, MILLIS);
|
||||
Ticker EEPROMCyclicPDSTicker(EEPROMCyclicPDS_callback, 60000, 0, MILLIS);
|
||||
Ticker LoRaPublishTicker(LoRaPublish_callback, 60000, 0, MILLIS);
|
||||
void printParameters(struct Configuration configuration);
|
||||
void printModuleInformation(struct ModuleInformation moduleInformation);
|
||||
void displayInfo();
|
||||
void SevenSeg_Output();
|
||||
void toggleWiFiAP(boolean shutdown = false);
|
||||
void SystemShutdown();
|
||||
void SetBatteryType(batteryType_t type);
|
||||
void ProcessKeyCombos(bool *btnState);
|
||||
void OverrideDisplay(const uint8_t *message, uint32_t time);
|
||||
|
||||
void tmrCallback_StatusSender();
|
||||
Ticker tmrStatusSender(tmrCallback_StatusSender, 30000, 0, MILLIS);
|
||||
void tmrCallback_PowerMonitor();
|
||||
Ticker tmrPowerMonitor(tmrCallback_PowerMonitor, 10000, 0, MILLIS);
|
||||
void tmrCallback_FactionTicker();
|
||||
Ticker tmrFactionTicker(tmrCallback_FactionTicker, 1000, 0, MILLIS);
|
||||
void tmrCallback_InputGetter();
|
||||
Ticker tmrInputGetter(tmrCallback_InputGetter, 250, 0, MILLIS);
|
||||
void tmrCallback_EEPROMCyclicPDS();
|
||||
Ticker tmrEEPROMCyclicPDS(tmrCallback_EEPROMCyclicPDS, 60000, 0, MILLIS);
|
||||
|
||||
#ifdef WIFI_CLIENT
|
||||
void tmrCallback_WiFiMaintainConnection();
|
||||
Ticker tmrWiFiMaintainConnection(tmrCallback_WiFiMaintainConnection, 1000, 0, MILLIS);
|
||||
#endif
|
||||
|
||||
uint32_t getESPChipID();
|
||||
|
||||
uint8_t Faction_1_dot = 0;
|
||||
uint8_t Faction_2_dot = 0;
|
||||
@ -84,35 +92,92 @@ const uint8_t sevenSeg_ota[] = {0x3F, 0x78, 0x77, 0x00};
|
||||
const uint8_t sevenSeg_flsh[] = {0x71, 0x38, 0x6D, 0x76};
|
||||
const uint8_t sevenSeg_file[] = {0x71, 0x30, 0x38, 0x79};
|
||||
|
||||
void setMPins_Helper(int pin, int status)
|
||||
{
|
||||
i2c_io.write(pin, status);
|
||||
}
|
||||
|
||||
void setup()
|
||||
{
|
||||
setCpuFrequencyMhz(80);
|
||||
WiFi.setAutoReconnect(false);
|
||||
WiFi.persistent(false);
|
||||
WiFi.disconnect();
|
||||
system_update_cpu_freq(SYS_CPU_80MHZ);
|
||||
|
||||
Serial.begin(115200);
|
||||
Serial.print("\n\n\n");
|
||||
|
||||
strcpy(globals.DeviceName, DEVICE_NAME);
|
||||
snprintf(globals.DeviceName_ID, 42, "%s_%08X", globals.DeviceName, getESPChipID());
|
||||
|
||||
if (LoRa_Init())
|
||||
LoRaPublishTicker.start();
|
||||
OLED_Init();
|
||||
|
||||
pinMode(DIO_FAC_1_TRG, INPUT_PULLUP);
|
||||
pinMode(DIO_FAC_2_TRG, INPUT_PULLUP);
|
||||
pinMode(DIO_FAC_3_TRG, INPUT_PULLUP);
|
||||
|
||||
#ifdef SERIAL_DEBUG
|
||||
Serial.setDebugOutput(true);
|
||||
#endif
|
||||
|
||||
if (ina219.begin())
|
||||
PowerMonitorTicker.start();
|
||||
WiFi.persistent(false);
|
||||
WiFi.disconnect();
|
||||
|
||||
strcpy(globals.DeviceName, DEVICE_NAME);
|
||||
snprintf(globals.DeviceName_ID, 42, "%s_%08X", globals.DeviceName, getESPChipID());
|
||||
|
||||
if (i2c_io.begin())
|
||||
{
|
||||
Serial.printf("Initialized PCF8574-GPIO at Address 0x%02X\n", I2C_IO_ADDRESS);
|
||||
}
|
||||
else
|
||||
Serial.println("Failed to find INA219 chip");
|
||||
{
|
||||
Serial.print("PCF8574-GPIO not Initialized\n");
|
||||
}
|
||||
|
||||
if (ina219.begin())
|
||||
{
|
||||
Serial.printf("Initialized INA219-Powermonitor at Address 0x%02X\n", I2C_POWER_ADDRESS);
|
||||
tmrPowerMonitor.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
Serial.print("INA219 not Initialized\n");
|
||||
}
|
||||
|
||||
e220ttl.setMPins = &setMPins_Helper;
|
||||
e220ttl.begin();
|
||||
|
||||
ResponseStructContainer c;
|
||||
c = e220ttl.getConfiguration();
|
||||
// It's important get configuration pointer before all other operation
|
||||
Configuration configuration = *(Configuration *)c.data;
|
||||
Serial.println(c.status.getResponseDescription());
|
||||
Serial.println(c.status.code);
|
||||
|
||||
ResponseStructContainer cMi;
|
||||
cMi = e220ttl.getModuleInformation();
|
||||
// It's important get information pointer before all other operation
|
||||
ModuleInformation mi = *(ModuleInformation *)cMi.data;
|
||||
|
||||
Serial.println(cMi.status.getResponseDescription());
|
||||
Serial.println(cMi.status.code);
|
||||
|
||||
// ----------------------- DEFAULT TRANSPARENT WITH RSSI -----------------------
|
||||
configuration.ADDL = 0x02;
|
||||
configuration.ADDH = 0x00;
|
||||
|
||||
configuration.CHAN = 23;
|
||||
|
||||
configuration.SPED.uartBaudRate = UART_BPS_9600;
|
||||
configuration.SPED.airDataRate = AIR_DATA_RATE_010_24;
|
||||
configuration.SPED.uartParity = MODE_00_8N1;
|
||||
|
||||
configuration.OPTION.subPacketSetting = SPS_200_00;
|
||||
configuration.OPTION.RSSIAmbientNoise = RSSI_AMBIENT_NOISE_ENABLED;
|
||||
configuration.OPTION.transmissionPower = POWER_22;
|
||||
|
||||
configuration.TRANSMISSION_MODE.enableRSSI = RSSI_ENABLED;
|
||||
configuration.TRANSMISSION_MODE.fixedTransmission = FT_FIXED_TRANSMISSION;
|
||||
configuration.TRANSMISSION_MODE.enableLBT = LBT_ENABLED;
|
||||
configuration.TRANSMISSION_MODE.WORPeriod = WOR_2000_011;
|
||||
|
||||
// Set configuration changed and set to not hold the configuration
|
||||
ResponseStatus rs = e220ttl.setConfiguration(configuration, WRITE_CFG_PWR_DWN_LOSE);
|
||||
Serial.println(rs.getResponseDescription());
|
||||
Serial.println(rs.code);
|
||||
c.close();
|
||||
|
||||
printParameters(configuration);
|
||||
tmrStatusSender.start();
|
||||
|
||||
LittleFS.begin();
|
||||
|
||||
@ -120,11 +185,13 @@ void setup()
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.setHostname(globals.DeviceName_ID);
|
||||
wifiMulti.addAP(QUOTE(WIFI_SSID), QUOTE(WIFI_PASSWORD));
|
||||
WiFiMaintainConnectionTicker.start();
|
||||
tmrWiFiMaintainConnection.start();
|
||||
#else
|
||||
WiFi.mode(WIFI_AP);
|
||||
WiFi.begin(QUOTE(DEVICE_NAME), QUOTE(WIFI_AP_PASSWORD));
|
||||
WiFi.setSleep(true);
|
||||
#if defined(ESP32)
|
||||
WiFi.sleep(true);
|
||||
#endif
|
||||
WiFi.mode(WIFI_OFF);
|
||||
#endif
|
||||
|
||||
@ -183,29 +250,47 @@ void setup()
|
||||
|
||||
initWebUI();
|
||||
|
||||
EEPROMCyclicPDSTicker.start();
|
||||
FactionTicker.start();
|
||||
InputGetterTicker.start();
|
||||
tmrEEPROMCyclicPDS.start();
|
||||
tmrFactionTicker.start();
|
||||
tmrInputGetter.start();
|
||||
Serial.println("Setup Done");
|
||||
}
|
||||
|
||||
void loop()
|
||||
{
|
||||
EEPROMCyclicPDSTicker.update();
|
||||
FactionTicker.update();
|
||||
InputGetterTicker.update();
|
||||
PowerMonitorTicker.update();
|
||||
LoRaPublishTicker.update();
|
||||
if (e220ttl.available() > 1)
|
||||
{
|
||||
ResponseContainer rc = e220ttl.receiveMessageRSSI();
|
||||
// Is something goes wrong print error
|
||||
if (rc.status.code != 1)
|
||||
{
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Print the data received
|
||||
Serial.println(rc.status.getResponseDescription());
|
||||
Serial.println(rc.data);
|
||||
Serial.print("RSSI: ");
|
||||
Serial.println(rc.rssi, DEC);
|
||||
}
|
||||
}
|
||||
|
||||
tmrEEPROMCyclicPDS.update();
|
||||
tmrFactionTicker.update();
|
||||
tmrInputGetter.update();
|
||||
ArduinoOTA.handle();
|
||||
SevenSeg_Output();
|
||||
EEPROM_Process();
|
||||
OLED_Process();
|
||||
|
||||
tmrStatusSender.update();
|
||||
tmrPowerMonitor.update();
|
||||
|
||||
#ifdef CAPTIVE
|
||||
dnsServer.processNextRequest();
|
||||
#endif
|
||||
#ifdef WIFI_CLIENT
|
||||
WiFiMaintainConnectionTicker.update();
|
||||
tmrWiFiMaintainConnection.update();
|
||||
#endif
|
||||
if (globals.systemStatus == sysStat_Shutdown)
|
||||
SystemShutdown();
|
||||
@ -259,7 +344,7 @@ void SevenSeg_Output()
|
||||
}
|
||||
}
|
||||
|
||||
void FactionTicker_callback()
|
||||
void tmrCallback_FactionTicker()
|
||||
{
|
||||
switch (PersistenceData.activeFaction)
|
||||
{
|
||||
@ -289,15 +374,31 @@ void FactionTicker_callback()
|
||||
}
|
||||
}
|
||||
|
||||
void inputGetterTicker_callback()
|
||||
void tmrCallback_InputGetter()
|
||||
{
|
||||
ProcessKeyCombos();
|
||||
static bool btnState[3];
|
||||
static bool btnlastState[3];
|
||||
|
||||
btnState[0] = i2c_io.readButton(I2C_IO_BTN_FAC1);
|
||||
btnState[1] = i2c_io.readButton(I2C_IO_BTN_FAC2);
|
||||
btnState[2] = i2c_io.readButton(I2C_IO_BTN_FAC3);
|
||||
|
||||
ProcessKeyCombos(btnState);
|
||||
|
||||
for (int i = 0; i < sizeof(btnState); i++)
|
||||
{
|
||||
if (btnlastState[i] != btnState[i])
|
||||
{
|
||||
btnlastState[i] = btnState[i];
|
||||
Serial.printf("Button %d changed to %d\n", i, btnState[i]);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t keysPressed = 0;
|
||||
|
||||
keysPressed = +digitalRead(DIO_FAC_1_TRG) == FAC_1_TRG_PRESSED ? 1 : 0;
|
||||
keysPressed = +digitalRead(DIO_FAC_2_TRG) == FAC_2_TRG_PRESSED ? 1 : 0;
|
||||
keysPressed = +digitalRead(DIO_FAC_3_TRG) == FAC_3_TRG_PRESSED ? 1 : 0;
|
||||
keysPressed = +btnState[0] == FAC_1_TRG_PRESSED ? 1 : 0;
|
||||
keysPressed = +btnState[1] == FAC_2_TRG_PRESSED ? 1 : 0;
|
||||
keysPressed = +btnState[2] == FAC_3_TRG_PRESSED ? 1 : 0;
|
||||
|
||||
if (keysPressed > 1)
|
||||
{
|
||||
@ -306,17 +407,103 @@ void inputGetterTicker_callback()
|
||||
return;
|
||||
}
|
||||
|
||||
if (digitalRead(DIO_FAC_1_TRG) == FAC_1_TRG_PRESSED)
|
||||
if (btnState[0] == FAC_1_TRG_PRESSED)
|
||||
PersistenceData.activeFaction = FACTION_1;
|
||||
|
||||
if (digitalRead(DIO_FAC_2_TRG) == FAC_2_TRG_PRESSED)
|
||||
if (btnState[1] == FAC_2_TRG_PRESSED)
|
||||
PersistenceData.activeFaction = FACTION_2;
|
||||
|
||||
if (digitalRead(DIO_FAC_3_TRG) == FAC_3_TRG_PRESSED)
|
||||
if (btnState[2] == FAC_3_TRG_PRESSED)
|
||||
PersistenceData.activeFaction = FACTION_3;
|
||||
}
|
||||
|
||||
void powerMonitorTicker_callback()
|
||||
void printParameters(struct Configuration configuration)
|
||||
{
|
||||
Serial.println("----------------------------------------");
|
||||
|
||||
Serial.print(F("HEAD : "));
|
||||
Serial.print(configuration.COMMAND, HEX);
|
||||
Serial.print(" ");
|
||||
Serial.print(configuration.STARTING_ADDRESS, HEX);
|
||||
Serial.print(" ");
|
||||
Serial.println(configuration.LENGHT, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("AddH : "));
|
||||
Serial.println(configuration.ADDH, HEX);
|
||||
Serial.print(F("AddL : "));
|
||||
Serial.println(configuration.ADDL, HEX);
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("Chan : "));
|
||||
Serial.print(configuration.CHAN, DEC);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.getChannelDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("SpeedParityBit : "));
|
||||
Serial.print(configuration.SPED.uartParity, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.SPED.getUARTParityDescription());
|
||||
Serial.print(F("SpeedUARTDatte : "));
|
||||
Serial.print(configuration.SPED.uartBaudRate, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.SPED.getUARTBaudRateDescription());
|
||||
Serial.print(F("SpeedAirDataRate : "));
|
||||
Serial.print(configuration.SPED.airDataRate, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.SPED.getAirDataRateDescription());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("OptionSubPacketSett: "));
|
||||
Serial.print(configuration.OPTION.subPacketSetting, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.OPTION.getSubPacketSetting());
|
||||
Serial.print(F("OptionTranPower : "));
|
||||
Serial.print(configuration.OPTION.transmissionPower, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.OPTION.getTransmissionPowerDescription());
|
||||
Serial.print(F("OptionRSSIAmbientNo: "));
|
||||
Serial.print(configuration.OPTION.RSSIAmbientNoise, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.OPTION.getRSSIAmbientNoiseEnable());
|
||||
Serial.println(F(" "));
|
||||
Serial.print(F("TransModeWORPeriod : "));
|
||||
Serial.print(configuration.TRANSMISSION_MODE.WORPeriod, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.TRANSMISSION_MODE.getWORPeriodByParamsDescription());
|
||||
Serial.print(F("TransModeEnableLBT : "));
|
||||
Serial.print(configuration.TRANSMISSION_MODE.enableLBT, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.TRANSMISSION_MODE.getLBTEnableByteDescription());
|
||||
Serial.print(F("TransModeEnableRSSI: "));
|
||||
Serial.print(configuration.TRANSMISSION_MODE.enableRSSI, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.TRANSMISSION_MODE.getRSSIEnableByteDescription());
|
||||
Serial.print(F("TransModeFixedTrans: "));
|
||||
Serial.print(configuration.TRANSMISSION_MODE.fixedTransmission, BIN);
|
||||
Serial.print(" -> ");
|
||||
Serial.println(configuration.TRANSMISSION_MODE.getFixedTransmissionDescription());
|
||||
|
||||
Serial.println("----------------------------------------");
|
||||
}
|
||||
|
||||
void tmrCallback_StatusSender()
|
||||
{
|
||||
struct
|
||||
{
|
||||
MessageType_t type = "STATUS";
|
||||
MessageStatus_t status;
|
||||
} __attribute__((packed)) sendStatus;
|
||||
|
||||
sendStatus.status.nodeid = 0x0002;
|
||||
sendStatus.status.millis = millis();
|
||||
sendStatus.status.faction_active = 1;
|
||||
sendStatus.status.faction_1_timer = 0xBBBBBBBB;
|
||||
sendStatus.status.faction_2_timer = 0xCCCCCCCC;
|
||||
sendStatus.status.faction_3_timer = 0xDDDDDDDD;
|
||||
|
||||
ResponseStatus rs = e220ttl.sendFixedMessage(0xFF, 0xFF, 23, (byte *)&sendStatus, sizeof(sendStatus));
|
||||
Serial.println(rs.getResponseDescription());
|
||||
}
|
||||
|
||||
void tmrCallback_PowerMonitor()
|
||||
{
|
||||
// loadvoltage and percentage is global, because of battery Monitoring
|
||||
|
||||
@ -326,15 +513,15 @@ void powerMonitorTicker_callback()
|
||||
const int bat_max_3s = 1260;
|
||||
|
||||
float shuntvoltage = 0;
|
||||
float current_mA = 0;
|
||||
//float current_mA = 0;
|
||||
float busvoltage = 0;
|
||||
float power_mW = 0;
|
||||
//float power_mW = 0;
|
||||
int battery_level = 0;
|
||||
|
||||
shuntvoltage = ina219.getShuntVoltage_mV();
|
||||
busvoltage = ina219.getBusVoltage_V();
|
||||
current_mA = ina219.getCurrent_mA();
|
||||
power_mW = ina219.getPower_mW();
|
||||
//current_mA = ina219.getCurrent_mA();
|
||||
//power_mW = ina219.getPower_mW();
|
||||
globals.loadvoltage = busvoltage + (shuntvoltage / 1000);
|
||||
switch (ConfigData.batteryType)
|
||||
{
|
||||
@ -359,13 +546,13 @@ void powerMonitorTicker_callback()
|
||||
// Serial.printf("Power: %f mW\n", power_mW);
|
||||
}
|
||||
|
||||
void EEPROMCyclicPDS_callback()
|
||||
void tmrCallback_EEPROMCyclicPDS()
|
||||
{
|
||||
StorePersistence_EEPROM();
|
||||
}
|
||||
|
||||
#ifdef WIFI_CLIENT
|
||||
void wifiMaintainConnectionTicker_callback()
|
||||
void tmrCallback_WiFiMaintainConnection()
|
||||
{
|
||||
static uint32_t WiFiFailCount = 0;
|
||||
const uint32_t WiFiFailMax = 20;
|
||||
@ -390,7 +577,7 @@ void toggleWiFiAP(boolean shutdown)
|
||||
{
|
||||
WiFi.mode(WIFI_OFF);
|
||||
#ifdef WIFI_CLIENT
|
||||
WiFiMaintainConnectionTicker.stop();
|
||||
tmrWiFiMaintainConnection.stop();
|
||||
#endif
|
||||
}
|
||||
else if (shutdown == false)
|
||||
@ -399,7 +586,7 @@ void toggleWiFiAP(boolean shutdown)
|
||||
WiFi.softAPConfig(IPAddress(WIFI_AP_IP_GW), IPAddress(WIFI_AP_IP_GW), IPAddress(255, 255, 255, 0));
|
||||
WiFi.softAP(globals.DeviceName_ID, QUOTE(WIFI_AP_PASSWORD));
|
||||
#ifdef WIFI_CLIENT
|
||||
WiFiMaintainConnectionTicker.stop();
|
||||
tmrWiFiMaintainConnection.stop();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -420,7 +607,27 @@ void SetBatteryType(batteryType_t type)
|
||||
}
|
||||
}
|
||||
|
||||
void ProcessKeyCombos()
|
||||
void OverrideDisplay(const uint8_t *message, uint32_t time)
|
||||
{
|
||||
DisplayOverrideFlag = millis() + time;
|
||||
DisplayOverrideValue = (uint8_t *)message;
|
||||
}
|
||||
|
||||
uint32_t getESPChipID()
|
||||
{
|
||||
#if defined(ESP8266)
|
||||
return ESP.getChipId();
|
||||
#elif defined(ESP32)
|
||||
uint32_t chipId;
|
||||
for (int i = 0; i < 17; i = i + 8)
|
||||
{
|
||||
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
|
||||
}
|
||||
return chipId;
|
||||
#endif
|
||||
}
|
||||
|
||||
void ProcessKeyCombos(bool *btnState)
|
||||
{
|
||||
typedef enum
|
||||
{
|
||||
@ -434,32 +641,32 @@ void ProcessKeyCombos()
|
||||
static uint8_t keyCount_Fac2 = 0;
|
||||
static keyStatus_t keyStatus_Fac3 = KEY_RELEASED;
|
||||
|
||||
if (digitalRead(DIO_FAC_3_TRG) == FAC_3_TRG_PRESSED)
|
||||
if (btnState[2] == FAC_3_TRG_PRESSED)
|
||||
{
|
||||
keyStatus_Fac3 = KEY_PRESSED;
|
||||
|
||||
// Process FactionKey 1 ComboCounter
|
||||
if (digitalRead(DIO_FAC_1_TRG) == FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_RELEASED)
|
||||
if (btnState[0] == FAC_1_TRG_PRESSED && keyStatus_Fac1 == KEY_RELEASED)
|
||||
{
|
||||
keyStatus_Fac1 = KEY_PRESSED;
|
||||
keyCount_Fac1++;
|
||||
}
|
||||
|
||||
if (digitalRead(DIO_FAC_1_TRG) != FAC_1_TRG_PRESSED)
|
||||
if (btnState[0] != FAC_1_TRG_PRESSED)
|
||||
keyStatus_Fac1 = KEY_RELEASED;
|
||||
|
||||
// Process FactionKey 2 ComboCounter
|
||||
if (digitalRead(DIO_FAC_2_TRG) == FAC_2_TRG_PRESSED && keyStatus_Fac2 == KEY_RELEASED)
|
||||
if (btnState[1] == FAC_2_TRG_PRESSED && keyStatus_Fac2 == KEY_RELEASED)
|
||||
{
|
||||
keyStatus_Fac2 = KEY_PRESSED;
|
||||
keyCount_Fac2++;
|
||||
}
|
||||
|
||||
if (digitalRead(DIO_FAC_2_TRG) != FAC_2_TRG_PRESSED)
|
||||
if (btnState[1] != FAC_2_TRG_PRESSED)
|
||||
keyStatus_Fac2 = KEY_RELEASED;
|
||||
}
|
||||
|
||||
if (digitalRead(DIO_FAC_3_TRG) != FAC_3_TRG_PRESSED && keyStatus_Fac3 == KEY_PRESSED)
|
||||
if (btnState[2] != FAC_3_TRG_PRESSED && keyStatus_Fac3 == KEY_PRESSED)
|
||||
{
|
||||
Serial.printf("KeyCombo 1: %d | 2: %d\n", keyCount_Fac1, keyCount_Fac2);
|
||||
|
||||
@ -477,37 +684,3 @@ void ProcessKeyCombos()
|
||||
keyStatus_Fac3 = KEY_RELEASED;
|
||||
}
|
||||
}
|
||||
|
||||
void OverrideDisplay(const uint8_t *message, uint32_t time)
|
||||
{
|
||||
DisplayOverrideFlag = millis() + time;
|
||||
DisplayOverrideValue = (uint8_t *)message;
|
||||
}
|
||||
|
||||
uint32_t getESPChipID()
|
||||
{
|
||||
uint32_t chipId;
|
||||
for (int i = 0; i < 17; i = i + 8)
|
||||
{
|
||||
chipId |= ((ESP.getEfuseMac() >> (40 - i)) & 0xff) << i;
|
||||
}
|
||||
return chipId;
|
||||
}
|
||||
#
|
||||
void LoRaPublish_callback()
|
||||
{
|
||||
|
||||
StaticJsonDocument<200> doc;
|
||||
|
||||
doc["lipo"] = globals.battery_level;
|
||||
doc["afact"] = PersistenceData.activeFaction;
|
||||
doc["fac1"] = PersistenceData.faction_1_timer;
|
||||
doc["fac2"] = PersistenceData.faction_2_timer;
|
||||
doc["fac3"] = PersistenceData.faction_3_timer;
|
||||
|
||||
LoRa.beginPacket();
|
||||
serializeJson(doc, LoRa);
|
||||
LoRa.endPacket();
|
||||
|
||||
Serial.printf("Sendet LoRa-Status Package\n");
|
||||
}
|
@ -4,11 +4,12 @@
|
||||
#include <Arduino.h>
|
||||
#include <FS.h>
|
||||
#include <LittleFS.h>
|
||||
#include <AsyncTCP.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "defaults.h"
|
||||
|
||||
void initWebUI();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
This directory is intended for PlatformIO Unit Testing and project tests.
|
||||
This directory is intended for PlatformIO Test Runner and project tests.
|
||||
|
||||
Unit Testing is a software testing method by which individual units of
|
||||
source code, sets of one or more MCU program modules together with associated
|
||||
@ -8,4 +8,4 @@ determine whether they are fit for use. Unit testing finds problems early
|
||||
in the development cycle.
|
||||
|
||||
More information about PlatformIO Unit Testing:
|
||||
- https://docs.platformio.org/page/plus/unit-testing.html
|
||||
- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html
|
||||
|
Loading…
x
Reference in New Issue
Block a user