Compare commits
44 Commits
Release-1.
...
ca9409e328
Author | SHA1 | Date | |
---|---|---|---|
ca9409e328 | |||
5a6dc524ad | |||
41b27c02dd | |||
e344977b8f | |||
aeab80d5a8 | |||
4507c80eba | |||
427e5e5d16 | |||
3a0e1a931d | |||
a960e67c7d | |||
9e1a4d821f | |||
4d0a9918ce | |||
53928a93b0 | |||
6b89ed9a8c | |||
ae29e23812 | |||
8884e995ca | |||
8eb52e286f | |||
98145b424d | |||
43ab7c6934 | |||
99dc58f3c9 | |||
3ee276c189 | |||
0b95cff140 | |||
641412ecc8 | |||
55e4fdb7d3 | |||
0e352881d3 | |||
030f010832 | |||
a2b7a1b10e | |||
10c098ad33 | |||
3c3feeb8b5 | |||
893a57707d | |||
790261b6b7 | |||
0b6c432c70 | |||
c88b532978 | |||
27b8cb0166 | |||
56872ea856 | |||
d3506fd479 | |||
ba90e98565 | |||
7b2c853b0d | |||
ed8f65b92e | |||
69e5249a9d | |||
b9f3b39684 | |||
63f8c34d97 | |||
d99216815a | |||
e6b5c0e3f0 | |||
9aa266792d |
6
.gitignore
vendored
@@ -1,5 +1 @@
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
Bestellung.xlsx
|
BIN
Documentation/Datasheets/E220-900T22D_UserManual_EN_v1.0.pdf
Normal file
31
Hardware/.gitignore
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
# For PCBs designed using KiCad: http://www.kicad-pcb.org/
|
||||
# Format documentation: http://kicad-pcb.org/help/file-formats/
|
||||
|
||||
# Temporary files
|
||||
*.000
|
||||
*.bak
|
||||
*.bck
|
||||
*.kicad_pcb-bak
|
||||
*.kicad_sch-bak
|
||||
*.kicad_prl
|
||||
*.sch-bak
|
||||
*~
|
||||
_autosave-*
|
||||
*.tmp
|
||||
*-save.pro
|
||||
*-save.kicad_pcb
|
||||
fp-info-cache
|
||||
|
||||
# Netlist files (exported from Eeschema)
|
||||
*.net
|
||||
|
||||
# Autorouter files (exported from Pcbnew)
|
||||
*.dsn
|
||||
*.ses
|
||||
|
||||
# Exported BOM files
|
||||
*.xml
|
||||
*.csv
|
||||
|
||||
gerber/
|
||||
*-backups/
|
BIN
Hardware/BOM DE-Timer HW Rev.1.0.xlsx
Normal file
19592
Hardware/DE-Timer.kicad_pcb
Normal file
437
Hardware/DE-Timer.kicad_pro
Normal file
@@ -0,0 +1,437 @@
|
||||
{
|
||||
"board": {
|
||||
"design_settings": {
|
||||
"defaults": {
|
||||
"board_outline_line_width": 0.09999999999999999,
|
||||
"copper_line_width": 0.19999999999999998,
|
||||
"copper_text_italic": false,
|
||||
"copper_text_size_h": 1.5,
|
||||
"copper_text_size_v": 1.5,
|
||||
"copper_text_thickness": 0.3,
|
||||
"copper_text_upright": false,
|
||||
"courtyard_line_width": 0.049999999999999996,
|
||||
"dimension_precision": 4,
|
||||
"dimension_units": 3,
|
||||
"dimensions": {
|
||||
"arrow_length": 1270000,
|
||||
"extension_offset": 500000,
|
||||
"keep_text_aligned": true,
|
||||
"suppress_zeroes": false,
|
||||
"text_position": 0,
|
||||
"units_format": 1
|
||||
},
|
||||
"fab_line_width": 0.09999999999999999,
|
||||
"fab_text_italic": false,
|
||||
"fab_text_size_h": 1.0,
|
||||
"fab_text_size_v": 1.0,
|
||||
"fab_text_thickness": 0.15,
|
||||
"fab_text_upright": false,
|
||||
"other_line_width": 0.15,
|
||||
"other_text_italic": false,
|
||||
"other_text_size_h": 1.0,
|
||||
"other_text_size_v": 1.0,
|
||||
"other_text_thickness": 0.15,
|
||||
"other_text_upright": false,
|
||||
"pads": {
|
||||
"drill": 3.0,
|
||||
"height": 4.0,
|
||||
"width": 4.0
|
||||
},
|
||||
"silk_line_width": 0.15,
|
||||
"silk_text_italic": false,
|
||||
"silk_text_size_h": 1.0,
|
||||
"silk_text_size_v": 1.0,
|
||||
"silk_text_thickness": 0.15,
|
||||
"silk_text_upright": false,
|
||||
"zones": {
|
||||
"45_degree_only": false,
|
||||
"min_clearance": 0.127
|
||||
}
|
||||
},
|
||||
"diff_pair_dimensions": [
|
||||
{
|
||||
"gap": 0.0,
|
||||
"via_gap": 0.0,
|
||||
"width": 0.0
|
||||
}
|
||||
],
|
||||
"drc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 2
|
||||
},
|
||||
"rule_severities": {
|
||||
"annular_width": "error",
|
||||
"clearance": "error",
|
||||
"copper_edge_clearance": "error",
|
||||
"courtyards_overlap": "error",
|
||||
"diff_pair_gap_out_of_range": "error",
|
||||
"diff_pair_uncoupled_length_too_long": "error",
|
||||
"drill_out_of_range": "error",
|
||||
"duplicate_footprints": "warning",
|
||||
"extra_footprint": "warning",
|
||||
"footprint_type_mismatch": "error",
|
||||
"hole_clearance": "error",
|
||||
"hole_near_hole": "error",
|
||||
"invalid_outline": "error",
|
||||
"item_on_disabled_layer": "error",
|
||||
"items_not_allowed": "error",
|
||||
"length_out_of_range": "error",
|
||||
"malformed_courtyard": "error",
|
||||
"microvia_drill_out_of_range": "error",
|
||||
"missing_courtyard": "ignore",
|
||||
"missing_footprint": "warning",
|
||||
"net_conflict": "warning",
|
||||
"npth_inside_courtyard": "ignore",
|
||||
"padstack": "error",
|
||||
"pth_inside_courtyard": "ignore",
|
||||
"shorting_items": "error",
|
||||
"silk_over_copper": "warning",
|
||||
"silk_overlap": "warning",
|
||||
"skew_out_of_range": "error",
|
||||
"through_hole_pad_without_hole": "error",
|
||||
"too_many_vias": "error",
|
||||
"track_dangling": "warning",
|
||||
"track_width": "error",
|
||||
"tracks_crossing": "error",
|
||||
"unconnected_items": "error",
|
||||
"unresolved_variable": "error",
|
||||
"via_dangling": "warning",
|
||||
"zone_has_empty_net": "error",
|
||||
"zones_intersect": "error"
|
||||
},
|
||||
"rules": {
|
||||
"allow_blind_buried_vias": false,
|
||||
"allow_microvias": false,
|
||||
"max_error": 0.005,
|
||||
"min_clearance": 0.0,
|
||||
"min_copper_edge_clearance": 0.0,
|
||||
"min_hole_clearance": 0.25,
|
||||
"min_hole_to_hole": 0.25,
|
||||
"min_microvia_diameter": 0.19999999999999998,
|
||||
"min_microvia_drill": 0.09999999999999999,
|
||||
"min_silk_clearance": 0.0,
|
||||
"min_through_hole_diameter": 0.3,
|
||||
"min_track_width": 0.19999999999999998,
|
||||
"min_via_annular_width": 0.049999999999999996,
|
||||
"min_via_diameter": 0.39999999999999997,
|
||||
"solder_mask_clearance": 0.0,
|
||||
"solder_mask_min_width": 0.0,
|
||||
"use_height_for_length_calcs": true
|
||||
},
|
||||
"track_widths": [
|
||||
0.0,
|
||||
0.635,
|
||||
1.27,
|
||||
2.54,
|
||||
5.08
|
||||
],
|
||||
"via_dimensions": [
|
||||
{
|
||||
"diameter": 0.0,
|
||||
"drill": 0.0
|
||||
}
|
||||
],
|
||||
"zones_allow_external_fillets": false,
|
||||
"zones_use_no_outline": true
|
||||
},
|
||||
"layer_presets": []
|
||||
},
|
||||
"boards": [],
|
||||
"cvpcb": {
|
||||
"equivalence_files": []
|
||||
},
|
||||
"erc": {
|
||||
"erc_exclusions": [],
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"pin_map": [
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
0,
|
||||
2,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
0,
|
||||
2,
|
||||
0,
|
||||
0,
|
||||
2
|
||||
],
|
||||
[
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2
|
||||
]
|
||||
],
|
||||
"rule_severities": {
|
||||
"bus_definition_conflict": "error",
|
||||
"bus_entry_needed": "error",
|
||||
"bus_label_syntax": "error",
|
||||
"bus_to_bus_conflict": "error",
|
||||
"bus_to_net_conflict": "error",
|
||||
"different_unit_footprint": "error",
|
||||
"different_unit_net": "error",
|
||||
"duplicate_reference": "error",
|
||||
"duplicate_sheet_names": "error",
|
||||
"extra_units": "error",
|
||||
"global_label_dangling": "warning",
|
||||
"hier_label_mismatch": "error",
|
||||
"label_dangling": "error",
|
||||
"lib_symbol_issues": "warning",
|
||||
"multiple_net_names": "warning",
|
||||
"net_not_bus_member": "warning",
|
||||
"no_connect_connected": "warning",
|
||||
"no_connect_dangling": "warning",
|
||||
"pin_not_connected": "error",
|
||||
"pin_not_driven": "error",
|
||||
"pin_to_pin": "warning",
|
||||
"power_pin_not_driven": "error",
|
||||
"similar_labels": "warning",
|
||||
"unannotated": "error",
|
||||
"unit_value_mismatch": "error",
|
||||
"unresolved_variable": "error",
|
||||
"wire_dangling": "error"
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"pinned_footprint_libs": [],
|
||||
"pinned_symbol_libs": []
|
||||
},
|
||||
"meta": {
|
||||
"filename": "DE-Timer.kicad_pro",
|
||||
"version": 1
|
||||
},
|
||||
"net_settings": {
|
||||
"classes": [
|
||||
{
|
||||
"bus_width": 12.0,
|
||||
"clearance": 0.1,
|
||||
"diff_pair_gap": 0.25,
|
||||
"diff_pair_via_gap": 0.25,
|
||||
"diff_pair_width": 0.2,
|
||||
"line_style": 0,
|
||||
"microvia_diameter": 0.3,
|
||||
"microvia_drill": 0.1,
|
||||
"name": "Default",
|
||||
"pcb_color": "rgba(0, 0, 0, 0.000)",
|
||||
"schematic_color": "rgba(0, 0, 0, 0.000)",
|
||||
"track_width": 0.25,
|
||||
"via_diameter": 0.8,
|
||||
"via_drill": 0.4,
|
||||
"wire_width": 6.0
|
||||
}
|
||||
],
|
||||
"meta": {
|
||||
"version": 2
|
||||
},
|
||||
"net_colors": null
|
||||
},
|
||||
"pcbnew": {
|
||||
"last_paths": {
|
||||
"gencad": "",
|
||||
"idf": "",
|
||||
"netlist": "",
|
||||
"specctra_dsn": "",
|
||||
"step": "DE-Timer.step",
|
||||
"vrml": ""
|
||||
},
|
||||
"page_layout_descr_file": ""
|
||||
},
|
||||
"schematic": {
|
||||
"annotate_start_num": 0,
|
||||
"drawing": {
|
||||
"default_line_thickness": 6.0,
|
||||
"default_text_size": 50.0,
|
||||
"field_names": [],
|
||||
"intersheets_ref_own_page": false,
|
||||
"intersheets_ref_prefix": "",
|
||||
"intersheets_ref_short": false,
|
||||
"intersheets_ref_show": false,
|
||||
"intersheets_ref_suffix": "",
|
||||
"junction_size_choice": 3,
|
||||
"label_size_ratio": 0.375,
|
||||
"pin_symbol_size": 25.0,
|
||||
"text_offset_ratio": 0.15
|
||||
},
|
||||
"legacy_lib_dir": "",
|
||||
"legacy_lib_list": [],
|
||||
"meta": {
|
||||
"version": 1
|
||||
},
|
||||
"net_format_name": "",
|
||||
"ngspice": {
|
||||
"fix_include_paths": true,
|
||||
"fix_passive_vals": false,
|
||||
"meta": {
|
||||
"version": 0
|
||||
},
|
||||
"model_mode": 0,
|
||||
"workbook_filename": ""
|
||||
},
|
||||
"page_layout_descr_file": "",
|
||||
"plot_directory": "",
|
||||
"spice_adjust_passive_values": false,
|
||||
"spice_external_command": "spice \"%I\"",
|
||||
"subpart_first_id": 65,
|
||||
"subpart_id_separator": 0
|
||||
},
|
||||
"sheets": [
|
||||
[
|
||||
"1a6d2848-e78e-49fe-8978-e1890f07836f",
|
||||
""
|
||||
]
|
||||
],
|
||||
"text_variables": {}
|
||||
}
|
3267
Hardware/DE-Timer.kicad_sch
Normal file
90
Hardware/Ebyte_RF.kicad_sym
Normal file
@@ -0,0 +1,90 @@
|
||||
(kicad_symbol_lib (version 20211014) (generator kicad_symbol_editor)
|
||||
(symbol "E220-900T22D" (in_bom yes) (on_board yes)
|
||||
(property "Reference" "U" (id 0) (at 7.62 1.27 0)
|
||||
(effects (font (size 1.27 1.27)))
|
||||
)
|
||||
(property "Value" "E220-900T22D" (id 1) (at 13.97 -1.27 0)
|
||||
(effects (font (size 1.27 1.27)))
|
||||
)
|
||||
(property "Footprint" "" (id 2) (at 0 0 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(property "Datasheet" "" (id 3) (at 0 0 0)
|
||||
(effects (font (size 1.27 1.27)) hide)
|
||||
)
|
||||
(symbol "E220-900T22D_0_1"
|
||||
(rectangle (start -5.08 -2.54) (end 12.7 -20.32)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(fill (type background))
|
||||
)
|
||||
(polyline
|
||||
(pts
|
||||
(xy 15.24 -15.24)
|
||||
(xy 13.97 -13.97)
|
||||
)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(fill (type none))
|
||||
)
|
||||
(polyline
|
||||
(pts
|
||||
(xy 15.24 -15.24)
|
||||
(xy 15.24 -13.97)
|
||||
)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(fill (type none))
|
||||
)
|
||||
(polyline
|
||||
(pts
|
||||
(xy 12.7 -17.78)
|
||||
(xy 15.24 -17.78)
|
||||
(xy 15.24 -15.24)
|
||||
(xy 16.51 -13.97)
|
||||
)
|
||||
(stroke (width 0) (type default) (color 0 0 0 0))
|
||||
(fill (type none))
|
||||
)
|
||||
)
|
||||
(symbol "E220-900T22D_1_1"
|
||||
(pin input line (at -7.62 -6.35 0) (length 2.54)
|
||||
(name "M0" (effects (font (size 1.27 1.27))))
|
||||
(number "1" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin unspecified line (at 10.16 -22.86 90) (length 2.54)
|
||||
(name "mount" (effects (font (size 1.27 1.27))))
|
||||
(number "10" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin input line (at -7.62 -8.89 0) (length 2.54)
|
||||
(name "M1" (effects (font (size 1.27 1.27))))
|
||||
(number "2" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin input line (at -7.62 -11.43 0) (length 2.54)
|
||||
(name "RXD" (effects (font (size 1.27 1.27))))
|
||||
(number "3" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin output line (at -7.62 -13.97 0) (length 2.54)
|
||||
(name "TXD" (effects (font (size 1.27 1.27))))
|
||||
(number "4" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin output line (at -7.62 -16.51 0) (length 2.54)
|
||||
(name "AUX" (effects (font (size 1.27 1.27))))
|
||||
(number "5" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin power_in line (at 3.81 0 270) (length 2.54)
|
||||
(name "VCC" (effects (font (size 1.27 1.27))))
|
||||
(number "6" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin power_in line (at 1.27 -22.86 90) (length 2.54)
|
||||
(name "GND" (effects (font (size 1.27 1.27))))
|
||||
(number "7" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin unspecified line (at 5.08 -22.86 90) (length 2.54)
|
||||
(name "mount" (effects (font (size 1.27 1.27))))
|
||||
(number "8" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
(pin unspecified line (at 7.62 -22.86 90) (length 2.54)
|
||||
(name "mount" (effects (font (size 1.27 1.27))))
|
||||
(number "9" (effects (font (size 1.27 1.27))))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
25
Hardware/Ebyte_RF.pretty/E220-900T22D.kicad_mod
Normal file
@@ -0,0 +1,25 @@
|
||||
(footprint "E220-900T22D" (version 20211014) (generator pcbnew)
|
||||
(layer "F.Cu")
|
||||
(tedit 62E17D77)
|
||||
(attr through_hole)
|
||||
(fp_text reference "REF**" (at 0 -12.93 unlocked) (layer "F.SilkS")
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
(tstamp 4c9fdea7-ba0c-45cc-8f66-240980c37d5c)
|
||||
)
|
||||
(fp_text value "E220-900T22D" (at 0 -11.43 unlocked) (layer "F.Fab")
|
||||
(effects (font (size 1 1) (thickness 0.15)))
|
||||
(tstamp c58960d9-4cac-4036-ad2e-1aef26946dae)
|
||||
)
|
||||
(fp_rect (start 18 2) (end 30.5 8.2) (layer "F.SilkS") (width 0.12) (fill none) (tstamp 477892a1-722e-4cda-bb6c-fcdb8ba5f93e))
|
||||
(fp_rect (start -18 -10.5) (end 18 10.5) (layer "F.SilkS") (width 0.12) (fill none) (tstamp 563c12e4-8f8c-446c-a11f-94f5aa93b994))
|
||||
(pad "1" thru_hole oval (at -16.5 7.62) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp cbc539d2-6a10-4052-9b7a-f10326dcac67))
|
||||
(pad "2" thru_hole oval (at -16.5 5.08) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 936e2ca6-11ae-4f42-9128-52bb329f3d21))
|
||||
(pad "3" thru_hole oval (at -16.5 2.54) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 0c30a4be-5679-499f-8c5b-5f3024f9d6cf))
|
||||
(pad "4" thru_hole oval (at -16.5 0) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 2f3deced-880d-4075-a81b-95c62da5b94d))
|
||||
(pad "5" thru_hole oval (at -16.5 -2.54) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 7e08f2a4-63d6-468b-bd8b-ec607077e023))
|
||||
(pad "6" thru_hole oval (at -16.5 -5.08) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp a06e8e78-f567-42e6-b645-013b1073ca31))
|
||||
(pad "7" thru_hole oval (at -16.5 -7.62) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 53c85970-3e21-4fae-a84f-721cfc0513b5))
|
||||
(pad "8" thru_hole oval (at 15 -1.92) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 065b9982-55f2-4822-977e-07e8a06e7b35))
|
||||
(pad "9" thru_hole oval (at 15 -4.46) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 70fb572d-d5ec-41e7-9482-63d4578b4f47))
|
||||
(pad "10" thru_hole oval (at 15 -7) (size 2.54 1.524) (drill 0.762) (layers *.Cu *.Mask) (tstamp 0f31f11f-c374-4640-b9a4-07bbdba8d354))
|
||||
)
|
3
Hardware/fp-lib-table
Normal file
@@ -0,0 +1,3 @@
|
||||
(fp_lib_table
|
||||
(lib (name "Ebyte_RF")(type "KiCad")(uri "${KIPRJMOD}/Ebyte_RF.pretty")(options "")(descr ""))
|
||||
)
|
3
Hardware/sym-lib-table
Normal file
@@ -0,0 +1,3 @@
|
||||
(sym_lib_table
|
||||
(lib (name "Ebyte_RF")(type "KiCad")(uri "${KIPRJMOD}/Ebyte_RF.kicad_sym")(options "")(descr ""))
|
||||
)
|
7
Software/.gitignore
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
data/
|
||||
.pio
|
||||
.vscode/.browse.c_cpp.db*
|
||||
.vscode/c_cpp_properties.json
|
||||
.vscode/launch.json
|
||||
.vscode/ipch
|
||||
wifi_credentials.ini
|
0
Software/README.md
Normal file
455
Software/data_src/index.htm
Normal file
@@ -0,0 +1,455 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>%DEVICENAME%</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="static/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="static/css/custom.css">
|
||||
<link rel="stylesheet" href="static/css/tweaks.css">
|
||||
<script src="static/js/jquery.min.js"></script>
|
||||
<script src="static/js/bootstrap.min.js"></script>
|
||||
<script src="static/js/websocket.js"></script>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="static/img/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon-16x16.png">
|
||||
<link rel="manifest" href="static/img/site.webmanifest">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<nav class="navbar fixed-top navbar-dark bg-primary" id="navbar1">
|
||||
<a class="navbar-brand" href="#">
|
||||
<img src="static/img/logo.png" width="30" height="30" class="d-inline-block align-top mr-1" alt="">
|
||||
%DEVICENAME%
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#collapsingNavbar"
|
||||
aria-controls="collapsingNavbar" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="collapsingNavbar">
|
||||
<ul class="navbar-nav nav mr-auto mt-2 mt-lg-0">
|
||||
|
||||
<li class="nav-item"><a class="nav-link active" role="tab" data-toggle="tab" href="#tab_home">Home</a></li>
|
||||
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_maintenance">Wartung</a></li>
|
||||
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_source">Einstellungen</a></li>
|
||||
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_sysinfo">Systeminfo</a></li>
|
||||
<li class="nav-item"><a class="nav-link" role="tab" data-toggle="tab" href="#tab_fwupdate">Update</a></li>
|
||||
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="container">
|
||||
|
||||
<!-- Tabs Content -->
|
||||
<div class="tab-content">
|
||||
<!-- Div Tab Home-->
|
||||
<div id="tab_home" class="tab-pane fade show active" role="tabpanel">
|
||||
<div class="col text-center">
|
||||
<div class="jumbotron">
|
||||
<img src="static/img/logo.png" width="120" height="120" class="img-fluid" alt="">
|
||||
<h3 class="pt-3">%DEVICENAME%</h3>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Div Group Battery remain -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Akku Ladestand</h4>
|
||||
<div class="progress">
|
||||
<div class="progress-bar text-light" role="progressbar" aria-valuenow="%BAT_REMAIN_CAPACITY%"
|
||||
aria-valuemin="0" aria-valuemax="100" style="width: %BAT_REMAIN_CAPACITY%%">
|
||||
%BAT_REMAIN_CAPACITY%%
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
<!-- Div Group Battery remain -->
|
||||
<!-- Div Group current Mode -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>aktueller Modus</h4>
|
||||
<input class="form-control" type="text" placeholder="%SYSTEM_STATUS%" readonly>
|
||||
</p>
|
||||
<!-- Div Group current Mode -->
|
||||
<!-- Div Group DTC Table -->
|
||||
<div %SHOW_DTC_TABLE%>
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Fehlercodes</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-6" scope="col">Zeitstempel</th>
|
||||
<th class="col-2" scope="col">Fehlercode</th>
|
||||
<th class="col-2" scope="col">Schwere</th>
|
||||
<th class="col-2" scope="col">Aktiv</th>
|
||||
</tr>
|
||||
%DTC_TABLE%
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
</div>
|
||||
<!-- Div Group DTC Table -->
|
||||
</div>
|
||||
<!-- Div Tab Home-->
|
||||
|
||||
<!-- Div Tab Maintenance -->
|
||||
<div id="tab_maintenance" class="tab-pane fade" role="tabpanel">
|
||||
<h3>Wartung</h3>
|
||||
<!-- Div Group EEPROM formatting -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>EEPROM formatieren</h4>
|
||||
<div class="alert alert-primary alert-dismissable show fade" role="alert">
|
||||
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
<strong>Achtung!</strong><br>
|
||||
Das Formatieren der EEPROM-Bereiche sollte nur ausgeführt werden wenn es unbedingt erforderlich ist!
|
||||
Hierdurch werden alle Einstellungen zurück gesetzt bzw. alle Betriebsdaten gehen verloren.
|
||||
Folgende Situationen erfordern unter anderem eine Formatierung:
|
||||
- Erstinitialisierung (bei neu aufgebautem Gerät)
|
||||
- Firmware-Update (nur wenn es die Release-Notes fordern)
|
||||
</div>
|
||||
<form action="post.htm" method="POST" class="form-horizontal">
|
||||
<div class="form-group row">
|
||||
<div class="offset-4 col-8">
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="reset_ee_cfg" id="reset_ee_cfg">
|
||||
<label class="form-check-label" for="reset_ee_cfg">
|
||||
Bereich "CFG"
|
||||
</label>
|
||||
</div>
|
||||
<div class="form-check">
|
||||
<input class="form-check-input" type="checkbox" name="reset_ee_pds" id="reset_ee_pds">
|
||||
<label class="form-check-label" for="reset_ee_pds">
|
||||
Bereich "PDS"
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="reset_ee_btn" type="submit" class="btn btn-outline-primary">EEPROM formatieren</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group EEPROM formatting -->
|
||||
<!-- Div Group Device Reboot -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Gerät neustarten</h4>
|
||||
<form action="post.htm" method="POST" class="form-horizontal">
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="reboot" type="submit" class="btn btn-outline-primary">Reboot</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group Device Reboot -->
|
||||
</div>
|
||||
<!-- Div Tab Maintenance -->
|
||||
|
||||
<!-- Div Tab Settings-->
|
||||
<div id="tab_source" class="tab-pane fade" role="tabpanel">
|
||||
<h3>Einstellungen</h3>
|
||||
<!-- Div Group Battery Type -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Akku-Variante</h4>
|
||||
<form action="post.htm" method="POST" class="form-horizontal">
|
||||
<div class="form-group row">
|
||||
<label for="battery_select" class="control-label col-4">Akku</label>
|
||||
<div class="col-8">
|
||||
<select id="battery_select" name="battery_select" class="select form-control">
|
||||
%BATTERY_SELECT_OPTIONS%
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="settingssave" type="submit" class="btn btn-outline-primary">Übernehmen</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group Battery Type -->
|
||||
</div>
|
||||
<!-- Div Tab Settings -->
|
||||
|
||||
<!-- Div Tab SystemInfo -->
|
||||
<div id="tab_sysinfo" class="tab-pane fade" role="tabpanel">
|
||||
<h3>Systeminfo</h3>
|
||||
<!-- Div Group Sysinfo:Geraeteinfo -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Gerät</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-7" scope="col">Parameter</td>
|
||||
<th class="col-5" scope="col">Value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Hostname</td>
|
||||
<td>%HOSTNAME%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<!-- Div Group Sysinfo:Geraeteinfo -->
|
||||
<!-- Div Group Sysinfo:Settings -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Einstellungen</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-7" scope="col">Parameter</td>
|
||||
<th class="col-5" scope="col">Value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Battery_type</td>
|
||||
<td>%BATTERY_TYPE%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>EEPROM Version</td>
|
||||
<td>%EEPROM_VERSION%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Checksum</td>
|
||||
<td>%CONFIG_CHECKSUM%</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</p>
|
||||
<!-- Div Group Sysinfo:Settings -->
|
||||
<!-- Div Group Sysinfo:Persistance -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Betriebsdaten</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-7" scope="col">Parameter</td>
|
||||
<th class="col-5" scope="col">Value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>writeCycleCounter</td>
|
||||
<td>%WRITE_CYCLE_COUNT%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>PersistenceMarker</td>
|
||||
<td>%PERSISTENCE_MARKER%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>activeFaction</td>
|
||||
<td>%ACTIVE_FACTION%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>faction_1_timer</td>
|
||||
<td>%POINTS_FAC_1%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>faction_2_timer</td>
|
||||
<td>%POINTS_FAC_2%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>faction_3_timer</td>
|
||||
<td>%POINTS_FAC_3%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>checksum</td>
|
||||
<td>%PERSISTANCE_CHECKSUM%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<!-- Div Group Sysinfo:Persistance -->
|
||||
<!-- Div Group LiveDebug -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Live Debug</h4>
|
||||
<div class="form-group row">
|
||||
<textarea class="form-control" spellcheck="false" id="livedebug-out" rows="3" readonly></textarea>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button id="btn-ws-start" class="btn btn-outline-primary">Start</button>
|
||||
<button id="btn-ws-stop" class="btn btn-outline-primary ml-2">Stop</button>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
<!-- Div Group LiveDebug -->
|
||||
</div>
|
||||
<!-- Div Tab SystemInfo -->
|
||||
|
||||
<!-- Div Tab Firmware Update-->
|
||||
<div id="tab_fwupdate" class="tab-pane fade" role="tabpanel">
|
||||
<h3>Firmware</h3>
|
||||
<!-- Div Group VersionInfo -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Version-Info</h4>
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th class="col-7" scope="col">Parameter</td>
|
||||
<th class="col-5" scope="col">Value</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Firmware Version</td>
|
||||
<td>%SW_VERSION%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Flash Version</td>
|
||||
<td>%FS_VERSION%</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Git Revision</td>
|
||||
<td>%GIT_REV%</td>
|
||||
</tr>
|
||||
</table>
|
||||
</p>
|
||||
<!-- Div Group VersionInfo -->
|
||||
<!-- Div Group EEPROM Backup -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>EEPROM-Backup</h4>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<a class="btn btn-outline-primary" href="eejson" role="button" id="ee-backup-download">Download</a>
|
||||
</div>
|
||||
</div>
|
||||
</p>
|
||||
<!-- Div Group EEPROM Backup -->
|
||||
<!-- Div Group EEPROM Restore -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>EEPROM-Restore</h4>
|
||||
<form method='POST' action='eeRestore' enctype='multipart/form-data'>
|
||||
<div class="form-group row">
|
||||
<div class="custom-file">
|
||||
<input type="file" name="ee-restore-file" class="custom-file-input" id="ee-restore-file" accept=".ee.json"
|
||||
required />
|
||||
<label class="custom-file-label" for="ee-restore-file">EEPROM-Backup auswählen</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="submit" type="submit" class="btn btn-outline-primary">Restore starten</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group EEPROM Restore -->
|
||||
<!-- Div Group Firmware Update -->
|
||||
<hr />
|
||||
<p>
|
||||
<h4>Firmware-Update</h4>
|
||||
<form method='POST' action='doUpdate' enctype='multipart/form-data'>
|
||||
<div class="form-group row">
|
||||
<div class="custom-file">
|
||||
<input type="file" name="fw-update-file" class="custom-file-input" id="fw-update-file"
|
||||
accept=".fw.bin,.fs.gz" required />
|
||||
<label class="custom-file-label" for="fw-update-file">Firmware-Update auswählen</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
<div class="col text-center">
|
||||
<button name="submit" type="submit" class="btn btn-outline-primary">Update starten</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</p>
|
||||
<!-- Div Group Firmware Update -->
|
||||
</div>
|
||||
<!-- Div Tab Firmware Update-->
|
||||
</div>
|
||||
<!-- Tabs Content -->
|
||||
</main>
|
||||
|
||||
|
||||
<!-- Footer -->
|
||||
|
||||
<footer class="page-footer navbar-dark bg-primary font-small fixed-bottom">
|
||||
<div class="container-fluid text-center">
|
||||
<div class="footer-copyright text-center py-3">
|
||||
<span class="text-muted">© 2023 -
|
||||
<a class="text-reset fw-bold" href="https://hiabuto.de/">Hiabuto Defence Systems</a></span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<!-- Footer -->
|
||||
|
||||
<!-- Modal Dialog -->
|
||||
|
||||
<div class="modal fade" id="dtcModal" tabindex="-1" role="dialog" aria-labelledby="dtcModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="dtcModalLabel">DTC-Description</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p class="dtc-desc">DTC Description</p>
|
||||
<p class="dtc-debugval">DTC DebugVal</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary" data-dismiss="modal">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal Dialog -->
|
||||
|
||||
<script>
|
||||
$('.navbar-nav>li>a').on('click', function () {
|
||||
$('.navbar-collapse').collapse('hide');
|
||||
});
|
||||
|
||||
document.querySelector('.custom-file-input').addEventListener('change', function (e) {
|
||||
var fileName = document.getElementById("fw-update-file").files[0].name;
|
||||
var nextSibling = e.target.nextElementSibling
|
||||
nextSibling.innerText = fileName
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$("tr[data-dtc]").each(function (i) {
|
||||
$(this).attr('data-toggle', "modal");
|
||||
$(this).attr('data-target', "#dtcModal");
|
||||
});
|
||||
});
|
||||
|
||||
$('#dtcModal').on('show.bs.modal', function (event) {
|
||||
var dtctr = $(event.relatedTarget)
|
||||
var dtc = dtctr.data('dtc')
|
||||
var debugval = dtctr.data('debugval')
|
||||
var modal = $(this)
|
||||
$.getJSON('static/tt_dtc/dtc_' + dtc + '.json', function (data) {
|
||||
modal.find('.modal-title').text(data.title)
|
||||
modal.find('.dtc-desc').text(data.description)
|
||||
if (debugval > 0) {
|
||||
modal.find('.dtc-debugval').text("Debugvalue: " + debugval)
|
||||
}
|
||||
else {
|
||||
modal.find('.dtc-debugval').remove()
|
||||
}
|
||||
}).fail(function () {
|
||||
console.log("An error has occurred.");
|
||||
modal.find('.modal-title').text("Fehler")
|
||||
modal.find('.dtc-desc').text("DTC-Beschreibung konnte nicht geladen werden")
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@@ -3,7 +3,7 @@
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>%DEVICE_NAME%</title>
|
||||
<title>KTM CAN Chain Oiler</title>
|
||||
<meta http-equiv="content-type" content="text/html;charset=UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="stylesheet" href="static/css/bootstrap.min.css">
|
||||
@@ -14,7 +14,7 @@
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="static/img/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="static/img/favicon-16x16.png">
|
||||
<link rel="manifest" href="static/img/site.webmanifest">
|
||||
<meta http-equiv="refresh" content="3; url='/index.htm'" />
|
||||
<meta http-equiv="refresh" content="3; url='index.htm'" />
|
||||
</head>
|
||||
|
||||
<body>
|
10003
Software/data_src/static/css/bootstrap.min.css
vendored
Normal file
8441
Software/data_src/static/css/custom.css
Normal file
27
Software/data_src/static/css/tweaks.css
Normal file
@@ -0,0 +1,27 @@
|
||||
@font-face {
|
||||
font-family: 'Comfortaa';
|
||||
font-style: normal;
|
||||
font-weight: 300;
|
||||
src: url(../fonts/comfortaa.woff2) format('woff2');
|
||||
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
|
||||
}
|
||||
|
||||
body {
|
||||
padding-top: 70px;
|
||||
margin-bottom: 70px;
|
||||
}
|
||||
|
||||
hr {
|
||||
height: 2px;
|
||||
border-width: 0;
|
||||
color: gray;
|
||||
background-color: gray
|
||||
}
|
||||
|
||||
.dtc-debugval {
|
||||
color: #F2771A;
|
||||
font: 0.8rem Inconsolata, monospace;
|
||||
background-color: black;
|
||||
padding: 10px;
|
||||
}
|
||||
|
BIN
Software/data_src/static/fonts/comfortaa.woff2
Normal file
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 55 KiB After Width: | Height: | Size: 55 KiB |
Before Width: | Height: | Size: 30 KiB After Width: | Height: | Size: 30 KiB |
BIN
Software/data_src/static/img/critical.png
Normal file
After Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
BIN
Software/data_src/static/img/info.png
Normal file
After Width: | Height: | Size: 9.6 KiB |
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 37 KiB After Width: | Height: | Size: 37 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 34 KiB After Width: | Height: | Size: 34 KiB |
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 18 KiB |
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
BIN
Software/data_src/static/img/warn.png
Normal file
After Width: | Height: | Size: 9.4 KiB |
7
Software/data_src/static/js/bootstrap.min.js
vendored
Normal file
5
Software/data_src/static/js/popper.min.js
vendored
Normal file
84
Software/data_src/static/js/websocket.js
Normal file
@@ -0,0 +1,84 @@
|
||||
var gateway = `ws://${window.location.hostname}/ws`;
|
||||
var websocket;
|
||||
|
||||
window.addEventListener("load", onLoad);
|
||||
|
||||
function initWebSocket() {
|
||||
console.log("Trying to open a WebSocket connection...");
|
||||
websocket = new WebSocket(gateway);
|
||||
websocket.onopen = onOpen;
|
||||
websocket.onclose = onClose;
|
||||
websocket.onmessage = onMessage; // <-- add this line
|
||||
}
|
||||
|
||||
function initButtons() {
|
||||
document
|
||||
.getElementById("btn-ws-stop")
|
||||
.addEventListener("click", livedebug_stop);
|
||||
document
|
||||
.getElementById("btn-ws-start")
|
||||
.addEventListener("click", livedebug_start);
|
||||
}
|
||||
|
||||
function onOpen(event) {
|
||||
console.log("Connection opened");
|
||||
}
|
||||
|
||||
function onClose(event) {
|
||||
console.log("Connection closed");
|
||||
setTimeout(initWebSocket, 2000);
|
||||
}
|
||||
|
||||
function onMessage(event) {
|
||||
var livedebug_out = document.getElementById("livedebug-out");
|
||||
var textarea_heigth = livedebug_out.scrollHeight;
|
||||
livedebug_out.value += event.data;
|
||||
livedebug_out.scrollTop = livedebug_out.scrollHeight;
|
||||
do_resize(livedebug_out);
|
||||
}
|
||||
|
||||
function onLoad(event) {
|
||||
initWebSocket();
|
||||
initButtons();
|
||||
}
|
||||
|
||||
function livedebug_start() {
|
||||
websocket.send("start");
|
||||
}
|
||||
|
||||
function livedebug_stop() {
|
||||
websocket.send("stop");
|
||||
}
|
||||
|
||||
function do_resize(textbox) {
|
||||
var maxrows = 15;
|
||||
var minrows = 3;
|
||||
var txt = textbox.value;
|
||||
var cols = textbox.cols;
|
||||
|
||||
var arraytxt = txt.split("\n");
|
||||
var rows = arraytxt.length;
|
||||
|
||||
for (i = 0; i < arraytxt.length; i++)
|
||||
rows += parseInt(arraytxt[i].length / cols);
|
||||
|
||||
if (rows > maxrows) textbox.rows = maxrows;
|
||||
else if (rows < minrows) textbox.rows = minrows;
|
||||
else textbox.rows = rows;
|
||||
}
|
||||
|
||||
function notifyMe() {
|
||||
if (!("Notification" in window)) {
|
||||
alert("This browser does not support desktop notification");
|
||||
} else if (Notification.permission === "granted") {
|
||||
const notification = new Notification("Hi there!");
|
||||
// …
|
||||
} else if (Notification.permission !== "denied") {
|
||||
Notification.requestPermission().then((permission) => {
|
||||
if (permission === "granted") {
|
||||
const notification = new Notification("Hi there!");
|
||||
// …
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_1.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "kein EEPROM gefunden",
|
||||
"description": "Es wurde kein EEPROM gefunden. Dies lässt einen Hardware-Defekt vermuten."
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_10.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Power-Monitor Fehler",
|
||||
"description": "Es gibt ein Problem mit dem Power-Monitoring. Die Akku-Überwachung ist ohne Funktion! Bitte Hardware prüfen"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_11.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Akku-Spannung niedrig",
|
||||
"description": "Die Akkuspannung ist niedrig. Bitte Akku bald aufladen!"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_12.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Akku-Spannung kritisch",
|
||||
"description": "Die Akkuspannung ist sehr niedrig. Bitte Akku umgehend ersetzen um eine schädliche Tiefentladung zu vermeiden!"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_2.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "EEPROM CFG Checksumme",
|
||||
"description": "Die Checksumme der Config-Partition des EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'CFG' im Menu 'Wartung' zurück"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_3.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "EEPROM PDS Checksumme",
|
||||
"description": "Die Checksumme der Betriebsdaten-Partition des EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'PDS' im Menu 'Wartung' zurück"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_4.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "EEPROM PDS Adresse",
|
||||
"description": "Die Adresse der Betriebsdaten-Partition im EEPROM ist ungültig. Setzen sie den EEPROM-Bereich 'PDS' im Menu 'Wartung' zurück"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_5.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "EEPROM Version falsch",
|
||||
"description": "Die Layout-Version des EEPROM stimmt nicht mit der Firmware-Version überein. Setzen sie den EEPROM-Bereich 'CFG' im Menu 'Wartung' zurück"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_6.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Flashstorage Fehler",
|
||||
"description": "Der Flashstorage konnte nicht initialisiert werden. Aktualisieren sie Flash & Firmware"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_7.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Flashstorage Version falsch",
|
||||
"description": "Die Version des Flashstorage stimmt nicht mit der Firmware-Version überein. Aktualisieren sie den Flash mit der passenden Update-Datei"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_8.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "Config-Validierung",
|
||||
"description": "Ein oder mehrer Einstellungswerte sind ausserhalb plausibler Werte. Prüfen Sie Ihre Einstellungen"
|
||||
}
|
4
Software/data_src/static/tt_dtc/dtc_9.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"title": "LoRa-Modul Fehler",
|
||||
"description": "Es gibt ein Problem mit dem LoRa-Modul. Es konnte keine LoRa-Verbindung aufgebaut werden. Bitte Hardware prüfen"
|
||||
}
|
1
Software/data_src/version
Normal file
@@ -0,0 +1 @@
|
||||
1.01
|
49
Software/include/common.h
Normal file
@@ -0,0 +1,49 @@
|
||||
|
||||
#ifndef _COMMON_H_
|
||||
#define _COMMON_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#define Q(x) #x
|
||||
#define QUOTE(x) Q(x)
|
||||
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#define HOST_NAME "AirsoftTimer_%08X"
|
||||
|
||||
#define SHUTDOWN_DELAY_MS 5000
|
||||
#define RESETABLE_AFTER_STARTUP_MS 30000
|
||||
|
||||
#define GPIO_LORA_TX D3
|
||||
#define GPIO_LORA_RX D4
|
||||
#define GPIO_LORA_AUX D0
|
||||
|
||||
#define GPIO_7SEG_EN_FAC1 D7
|
||||
#define GPIO_7SEG_EN_FAC2 D6
|
||||
#define GPIO_7SEG_EN_FAC3 D5
|
||||
#define GPIO_7SEG_CLK D8
|
||||
|
||||
#define I2C_IO_BTN_FAC1 0
|
||||
#define FAC_1_TRG_PRESSED LOW
|
||||
#define I2C_IO_BTN_FAC2 1
|
||||
#define FAC_2_TRG_PRESSED LOW
|
||||
#define I2C_IO_BTN_FAC3 2
|
||||
#define FAC_3_TRG_PRESSED LOW
|
||||
|
||||
#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
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
|
||||
#define EEPROM_SIZE_BYTES I2C_DEVICESIZE_24LC01
|
||||
#define EEPROM_ENDURANCE 1000000
|
||||
@@ -42,6 +43,8 @@ const char BatteryString[][10]{
|
||||
"LiPo 3S"
|
||||
};
|
||||
|
||||
const size_t BatteryString_Elements = sizeof(BatteryString) / sizeof(BatteryString[0]);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t EEPROM_Version = 1;
|
||||
@@ -49,6 +52,10 @@ typedef struct
|
||||
uint32_t checksum = 0;
|
||||
} configData_t;
|
||||
|
||||
const configData_t ConfigData_defaults = {
|
||||
0, BATTERY_LIPO_3S, 0
|
||||
};
|
||||
|
||||
void InitEEPROM();
|
||||
void EEPROM_Process();
|
||||
void StoreConfig_EEPROM();
|
||||
@@ -60,9 +67,7 @@ void FormatPersistence_EEPROM();
|
||||
uint32_t Checksum_EEPROM(uint8_t const *data, size_t len);
|
||||
void dumpEEPROM(uint16_t memoryAddress, uint16_t length);
|
||||
void MovePersistencePage_EEPROM(boolean reset);
|
||||
uint32_t getPersistanceAddress();
|
||||
void updatePersistanceAddress(uint32_t adress);
|
||||
uint32_t GetEESize();
|
||||
uint32_t ConfigSanityCheck(bool autocorrect = false);
|
||||
|
||||
extern configData_t ConfigData;
|
||||
extern persistenceData_t PersistenceData;
|
46
Software/include/debugger.h
Normal file
@@ -0,0 +1,46 @@
|
||||
#ifndef _DEBUGGER_H_
|
||||
#define _DEBUGGER_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include "webui.h"
|
||||
|
||||
const char PROGMEM helpCmd[] = "sysinfo - System Info\n"
|
||||
"netinfo - WiFi Info\n"
|
||||
"formatPDS - Format Persistence EEPROM Data\n"
|
||||
"formatCFG - Format Configuration EEPROM Data\n"
|
||||
"checkEE - Check EEPROM with checksum\n"
|
||||
"dumpEE1k - dump the first 1kb of EEPROM to Serial\n"
|
||||
"dumpEE - dump the whole EPPROM to Serial\n"
|
||||
"resetPageEE - Reset the PersistenceData Page\n"
|
||||
"dumpCFG - print Config struct\n"
|
||||
"dumpPDS - print PersistanceStruct\n"
|
||||
"saveEE - save EE-Data\n"
|
||||
"showdtc - Show all DTCs\n"
|
||||
"dumpGlobals - print globals\n";
|
||||
|
||||
typedef enum DebugStatus_e
|
||||
{
|
||||
disabled,
|
||||
enabled
|
||||
} DebugStatus_t;
|
||||
|
||||
typedef enum DebugPorts_e
|
||||
{
|
||||
dbg_Serial,
|
||||
dbg_Webui,
|
||||
dbg_cntElements
|
||||
} DebugPorts_t;
|
||||
|
||||
const char sDebugPorts[dbg_cntElements][7] = {
|
||||
"Serial",
|
||||
"WebUI"};
|
||||
|
||||
extern DebugStatus_t DebuggerStatus[dbg_cntElements];
|
||||
|
||||
void initDebugger();
|
||||
void pushCANDebug(uint32_t id, uint8_t dlc, uint8_t *data);
|
||||
void Debug_pushMessage(const char *format, ...);
|
||||
void SetDebugportStatus(DebugPorts_t port, DebugStatus_t status);
|
||||
void Debug_Process();
|
||||
|
||||
#endif
|
56
Software/include/dtc.h
Normal file
@@ -0,0 +1,56 @@
|
||||
#ifndef _DTC_H_
|
||||
#define _DTC_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
#define MAX_DTC_STORAGE 12
|
||||
|
||||
typedef enum DTCNums_e
|
||||
{
|
||||
DTC_NO_EEPROM_FOUND = 1,
|
||||
DTC_EEPROM_CFG_BAD,
|
||||
DTC_EEPROM_PDS_BAD,
|
||||
DTC_EEPROM_PDSADRESS_BAD,
|
||||
DTC_EEPROM_VERSION_BAD,
|
||||
DTC_FLASHFS_ERROR,
|
||||
DTC_FLASHFS_VERSION_ERROR,
|
||||
DTC_EEPROM_CFG_SANITY,
|
||||
DTC_NO_LORA_FOUND,
|
||||
DTC_NO_BATMNON_FOUND,
|
||||
DTC_BAT_LOW,
|
||||
DTC_BAT_CRITICAL,
|
||||
DTC_LAST_DTC
|
||||
} DTCNums_t;
|
||||
|
||||
typedef enum DTCActive_e
|
||||
{
|
||||
DTC_NONE,
|
||||
DTC_ACTIVE,
|
||||
DTC_PREVIOUS
|
||||
} DTCActive_t;
|
||||
|
||||
typedef enum DTCSeverity_e
|
||||
{
|
||||
DTC_INFO,
|
||||
DTC_WARN,
|
||||
DTC_CRITICAL
|
||||
} DTCSeverity_t;
|
||||
|
||||
typedef struct DTCEntry_s
|
||||
{
|
||||
DTCNums_t Number;
|
||||
uint32_t timestamp;
|
||||
DTCActive_t active;
|
||||
DTCSeverity_t severity;
|
||||
uint32_t debugVal;
|
||||
} DTCEntry_t;
|
||||
|
||||
void MaintainDTC(DTCNums_t DTC_no, DTCSeverity_t DTC_severity, boolean active, uint32_t DebugValue = 0);
|
||||
void ClearDTC(DTCNums_t DTC_no);
|
||||
void ClearAllDTC();
|
||||
DTCNums_t getlastDTC(boolean only_active);
|
||||
DTCNums_t getlastDTC_Severity(boolean only_active, DTCSeverity_t severity);
|
||||
void DTC_Process();
|
||||
|
||||
extern DTCEntry_s DTCStorage[MAX_DTC_STORAGE];
|
||||
#endif
|
61
Software/include/globals.h
Normal file
@@ -0,0 +1,61 @@
|
||||
#ifndef _GLOBALS_H_
|
||||
#define _GLOBALS_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
typedef enum eSystem_Status
|
||||
{
|
||||
sysStat_Startup,
|
||||
sysStat_Normal,
|
||||
sysStat_Error,
|
||||
sysStat_Shutdown
|
||||
} tSystem_Status;
|
||||
|
||||
typedef enum eEERequest
|
||||
{
|
||||
EE_IDLE,
|
||||
EE_CFG_SAVE,
|
||||
EE_CFG_LOAD,
|
||||
EE_CFG_FORMAT,
|
||||
EE_PDS_SAVE,
|
||||
EE_PDS_LOAD,
|
||||
EE_PDS_FORMAT,
|
||||
EE_FORMAT_ALL,
|
||||
EE_ALL_SAVE
|
||||
|
||||
} tEERequest;
|
||||
|
||||
typedef struct Globals_s
|
||||
{
|
||||
char DeviceName[33];
|
||||
char DeviceName_ID[43];
|
||||
char FlashVersion[10];
|
||||
tSystem_Status systemStatus = sysStat_Startup;
|
||||
tSystem_Status resumeStatus = sysStat_Startup;
|
||||
char systemStatustxt[16] = "";
|
||||
eEERequest requestEEAction = EE_IDLE;
|
||||
uint16_t eePersistanceAdress;
|
||||
bool hasDTC;
|
||||
int loadvoltage_mV = 0;
|
||||
int battery_level = 0;
|
||||
} Globals_t;
|
||||
|
||||
extern Globals_t globals;
|
||||
typedef struct Constants_s
|
||||
{
|
||||
uint8_t FW_Version_major;
|
||||
uint8_t FW_Version_minor;
|
||||
uint8_t Required_Flash_Version_major;
|
||||
uint8_t Required_Flash_Version_minor;
|
||||
char GitHash[11];
|
||||
} Constants_t;
|
||||
|
||||
const Constants_t constants PROGMEM = {
|
||||
1,1, // Firmware_Version
|
||||
1,1, // Required Flash Version
|
||||
GIT_REV // Git-Hash-String
|
||||
};
|
||||
|
||||
void initGlobals();
|
||||
|
||||
#endif
|
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
|
21
Software/include/lora_net.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _LORA_NET_H_
|
||||
#define _LORA_NET_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <LoRa_E220.h>
|
||||
|
||||
// local includes
|
||||
#include "lora_messages.h"
|
||||
#include "defaults.h"
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
|
||||
#define FREQUENCY_868
|
||||
|
||||
bool InitLoRa(void (*MPinHelper)(int, int));
|
||||
void LoRa_Process();
|
||||
void sendStatus_LoRa();
|
||||
|
||||
#endif
|
20
Software/include/oled_display.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#ifndef _OLED_DISPLAY_H_
|
||||
#define _OLED_DISPLAY_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_GFX.h>
|
||||
#include <Adafruit_SSD1306.h>
|
||||
#include "globals.h"
|
||||
#include "config.h"
|
||||
|
||||
#define OLED_SDA 4
|
||||
#define OLED_SCL 15
|
||||
#define OLED_RST 16
|
||||
#define SCREEN_WIDTH 128 // OLED display width, in pixels
|
||||
#define SCREEN_HEIGHT 64 // OLED display height, in pixels
|
||||
|
||||
void OLED_Init();
|
||||
void OLED_Process();
|
||||
|
||||
#endif
|
21
Software/include/sanitycheck.h
Normal file
@@ -0,0 +1,21 @@
|
||||
#ifndef _SANITYCHECK_H_
|
||||
#define _SANITYCHECK_H_
|
||||
|
||||
#ifndef ADMIN_PASSWORD
|
||||
#error "You need to define ADMIN_PASSWORD for OTA-Update"
|
||||
#endif
|
||||
#ifndef WIFI_PASSWORD
|
||||
#error "You must define an WIFI_PASSWORD for OTA-Update"
|
||||
#endif
|
||||
#ifndef WIFI_SSID
|
||||
#error "You must define an WIFI_SSID for OTA-Update"
|
||||
#endif
|
||||
#ifndef WIFI_AP_SSID
|
||||
#warning "No WIFI_AP_SSID defined. Using DeviceName"
|
||||
#define WIFI_AP_SSID DEVICE_NAME
|
||||
#endif
|
||||
#ifndef WIFI_AP_PASSWORD
|
||||
#error "You must define an WIFI_AP_PASSWORD for Standalone AP-Mode"
|
||||
#endif
|
||||
|
||||
#endif //_SANITYCHECK_H_
|
@@ -6,10 +6,19 @@
|
||||
#include <LittleFS.h>
|
||||
#include <ESPAsyncTCP.h>
|
||||
#include <ESPAsyncWebServer.h>
|
||||
#include <Updater.h>
|
||||
#include <ESP8266mDNS.h>
|
||||
#include <AsyncJson.h>
|
||||
#include <ArduinoJson.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "globals.h"
|
||||
#include "dtc.h"
|
||||
#include "common.h"
|
||||
#include "debugger.h"
|
||||
|
||||
void initWebUI();
|
||||
void Webserver_Process();
|
||||
void Websocket_PushLiveDebug(String Message);
|
||||
|
||||
#endif
|
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
@@ -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
@@ -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
@@ -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
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
@@ -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
@@ -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
@@ -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
@@ -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
|
2
Software/lib/ESP Async WebServer/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
.vscode
|
||||
.DS_Store
|
1
Software/lib/ESP Async WebServer/.piopm
Normal file
@@ -0,0 +1 @@
|
||||
{"type": "library", "name": "ESP Async WebServer", "version": "1.2.3", "spec": {"owner": "me-no-dev", "id": 306, "name": "ESP Async WebServer", "requirements": null, "uri": null}}
|
46
Software/lib/ESP Async WebServer/.travis.yml
Normal file
@@ -0,0 +1,46 @@
|
||||
sudo: false
|
||||
|
||||
language: python
|
||||
|
||||
os:
|
||||
- linux
|
||||
|
||||
git:
|
||||
depth: false
|
||||
|
||||
stages:
|
||||
- build
|
||||
|
||||
jobs:
|
||||
include:
|
||||
|
||||
- name: "Build Arduino ESP32"
|
||||
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
|
||||
stage: build
|
||||
script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp32
|
||||
|
||||
- name: "Build Arduino ESP8266"
|
||||
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
|
||||
stage: build
|
||||
script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp8266
|
||||
|
||||
- name: "Build Platformio ESP32"
|
||||
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
|
||||
stage: build
|
||||
script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp32 1 1
|
||||
|
||||
- name: "Build Platformio ESP8266"
|
||||
if: tag IS blank AND (type = pull_request OR (type = push AND branch = master))
|
||||
stage: build
|
||||
script: bash $TRAVIS_BUILD_DIR/.github/scripts/on-push.sh esp8266 1 1
|
||||
|
||||
notifications:
|
||||
email:
|
||||
on_success: change
|
||||
on_failure: change
|
||||
webhooks:
|
||||
urls:
|
||||
- https://webhooks.gitter.im/e/60e65d0c78ea0a920347
|
||||
on_success: change # options: [always|never|change] default: always
|
||||
on_failure: always # options: [always|never|change] default: always
|
||||
on_start: never # options: [always|never|change] default: always
|
17
Software/lib/ESP Async WebServer/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
set(COMPONENT_SRCDIRS
|
||||
"src"
|
||||
)
|
||||
|
||||
set(COMPONENT_ADD_INCLUDEDIRS
|
||||
"src"
|
||||
)
|
||||
|
||||
set(COMPONENT_REQUIRES
|
||||
"arduino-esp32"
|
||||
"AsyncTCP"
|
||||
)
|
||||
|
||||
register_component()
|
||||
|
||||
target_compile_definitions(${COMPONENT_TARGET} PUBLIC -DESP32)
|
||||
target_compile_options(${COMPONENT_TARGET} PRIVATE -fno-rtti)
|
1486
Software/lib/ESP Async WebServer/README.md
Normal file
1
Software/lib/ESP Async WebServer/_config.yml
Normal file
@@ -0,0 +1 @@
|
||||
theme: jekyll-theme-cayman
|
3
Software/lib/ESP Async WebServer/component.mk
Normal file
@@ -0,0 +1,3 @@
|
||||
COMPONENT_ADD_INCLUDEDIRS := src
|
||||
COMPONENT_SRCDIRS := src
|
||||
CXXFLAGS += -fno-rtti
|
3
Software/lib/ESP Async WebServer/keywords.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
JsonArray KEYWORD1
|
||||
add KEYWORD2
|
||||
createArray KEYWORD3
|
33
Software/lib/ESP Async WebServer/library.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name":"ESP Async WebServer",
|
||||
"description":"Asynchronous HTTP and WebSocket Server Library for ESP8266 and ESP32",
|
||||
"keywords":"http,async,websocket,webserver",
|
||||
"authors":
|
||||
{
|
||||
"name": "Hristo Gochkov",
|
||||
"maintainer": true
|
||||
},
|
||||
"repository":
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/me-no-dev/ESPAsyncWebServer.git"
|
||||
},
|
||||
"version": "1.2.3",
|
||||
"license": "LGPL-3.0",
|
||||
"frameworks": "arduino",
|
||||
"platforms": ["espressif8266", "espressif32"],
|
||||
"dependencies": [
|
||||
{
|
||||
"name": "ESPAsyncTCP",
|
||||
"platforms": "espressif8266"
|
||||
},
|
||||
{
|
||||
"name": "AsyncTCP",
|
||||
"platforms": "espressif32"
|
||||
},
|
||||
{
|
||||
"name": "Hash",
|
||||
"platforms": "espressif8266"
|
||||
}
|
||||
]
|
||||
}
|
9
Software/lib/ESP Async WebServer/library.properties
Normal file
@@ -0,0 +1,9 @@
|
||||
name=ESP Async WebServer
|
||||
version=1.2.3
|
||||
author=Me-No-Dev
|
||||
maintainer=Me-No-Dev
|
||||
sentence=Async Web Server for ESP8266 and ESP31B
|
||||
paragraph=Async Web Server for ESP8266 and ESP31B
|
||||
category=Other
|
||||
url=https://github.com/me-no-dev/ESPAsyncWebServer
|
||||
architectures=*
|
363
Software/lib/ESP Async WebServer/src/AsyncEventSource.cpp
Normal file
@@ -0,0 +1,363 @@
|
||||
/*
|
||||
Asynchronous WebServer library for Espressif MCUs
|
||||
|
||||
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "Arduino.h"
|
||||
#include "AsyncEventSource.h"
|
||||
|
||||
static String generateEventMessage(const char *message, const char *event, uint32_t id, uint32_t reconnect){
|
||||
String ev = "";
|
||||
|
||||
if(reconnect){
|
||||
ev += "retry: ";
|
||||
ev += String(reconnect);
|
||||
ev += "\r\n";
|
||||
}
|
||||
|
||||
if(id){
|
||||
ev += "id: ";
|
||||
ev += String(id);
|
||||
ev += "\r\n";
|
||||
}
|
||||
|
||||
if(event != NULL){
|
||||
ev += "event: ";
|
||||
ev += String(event);
|
||||
ev += "\r\n";
|
||||
}
|
||||
|
||||
if(message != NULL){
|
||||
size_t messageLen = strlen(message);
|
||||
char * lineStart = (char *)message;
|
||||
char * lineEnd;
|
||||
do {
|
||||
char * nextN = strchr(lineStart, '\n');
|
||||
char * nextR = strchr(lineStart, '\r');
|
||||
if(nextN == NULL && nextR == NULL){
|
||||
size_t llen = ((char *)message + messageLen) - lineStart;
|
||||
char * ldata = (char *)malloc(llen+1);
|
||||
if(ldata != NULL){
|
||||
memcpy(ldata, lineStart, llen);
|
||||
ldata[llen] = 0;
|
||||
ev += "data: ";
|
||||
ev += ldata;
|
||||
ev += "\r\n\r\n";
|
||||
free(ldata);
|
||||
}
|
||||
lineStart = (char *)message + messageLen;
|
||||
} else {
|
||||
char * nextLine = NULL;
|
||||
if(nextN != NULL && nextR != NULL){
|
||||
if(nextR < nextN){
|
||||
lineEnd = nextR;
|
||||
if(nextN == (nextR + 1))
|
||||
nextLine = nextN + 1;
|
||||
else
|
||||
nextLine = nextR + 1;
|
||||
} else {
|
||||
lineEnd = nextN;
|
||||
if(nextR == (nextN + 1))
|
||||
nextLine = nextR + 1;
|
||||
else
|
||||
nextLine = nextN + 1;
|
||||
}
|
||||
} else if(nextN != NULL){
|
||||
lineEnd = nextN;
|
||||
nextLine = nextN + 1;
|
||||
} else {
|
||||
lineEnd = nextR;
|
||||
nextLine = nextR + 1;
|
||||
}
|
||||
|
||||
size_t llen = lineEnd - lineStart;
|
||||
char * ldata = (char *)malloc(llen+1);
|
||||
if(ldata != NULL){
|
||||
memcpy(ldata, lineStart, llen);
|
||||
ldata[llen] = 0;
|
||||
ev += "data: ";
|
||||
ev += ldata;
|
||||
ev += "\r\n";
|
||||
free(ldata);
|
||||
}
|
||||
lineStart = nextLine;
|
||||
if(lineStart == ((char *)message + messageLen))
|
||||
ev += "\r\n";
|
||||
}
|
||||
} while(lineStart < ((char *)message + messageLen));
|
||||
}
|
||||
|
||||
return ev;
|
||||
}
|
||||
|
||||
// Message
|
||||
|
||||
AsyncEventSourceMessage::AsyncEventSourceMessage(const char * data, size_t len)
|
||||
: _data(nullptr), _len(len), _sent(0), _acked(0)
|
||||
{
|
||||
_data = (uint8_t*)malloc(_len+1);
|
||||
if(_data == nullptr){
|
||||
_len = 0;
|
||||
} else {
|
||||
memcpy(_data, data, len);
|
||||
_data[_len] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
AsyncEventSourceMessage::~AsyncEventSourceMessage() {
|
||||
if(_data != NULL)
|
||||
free(_data);
|
||||
}
|
||||
|
||||
size_t AsyncEventSourceMessage::ack(size_t len, uint32_t time) {
|
||||
// If the whole message is now acked...
|
||||
if(_acked + len > _len){
|
||||
// Return the number of extra bytes acked (they will be carried on to the next message)
|
||||
const size_t extra = _acked + len - _len;
|
||||
_acked = _len;
|
||||
return extra;
|
||||
}
|
||||
// Return that no extra bytes left.
|
||||
_acked += len;
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t AsyncEventSourceMessage::send(AsyncClient *client) {
|
||||
const size_t len = _len - _sent;
|
||||
if(client->space() < len){
|
||||
return 0;
|
||||
}
|
||||
size_t sent = client->add((const char *)_data, len);
|
||||
if(client->canSend())
|
||||
client->send();
|
||||
_sent += sent;
|
||||
return sent;
|
||||
}
|
||||
|
||||
// Client
|
||||
|
||||
AsyncEventSourceClient::AsyncEventSourceClient(AsyncWebServerRequest *request, AsyncEventSource *server)
|
||||
: _messageQueue(LinkedList<AsyncEventSourceMessage *>([](AsyncEventSourceMessage *m){ delete m; }))
|
||||
{
|
||||
_client = request->client();
|
||||
_server = server;
|
||||
_lastId = 0;
|
||||
if(request->hasHeader("Last-Event-ID"))
|
||||
_lastId = atoi(request->getHeader("Last-Event-ID")->value().c_str());
|
||||
|
||||
_client->setRxTimeout(0);
|
||||
_client->onError(NULL, NULL);
|
||||
_client->onAck([](void *r, AsyncClient* c, size_t len, uint32_t time){ ((AsyncEventSourceClient*)(r))->_onAck(len, time); }, this);
|
||||
_client->onPoll([](void *r, AsyncClient* c){ ((AsyncEventSourceClient*)(r))->_onPoll(); }, this);
|
||||
_client->onData(NULL, NULL);
|
||||
_client->onTimeout([this](void *r, AsyncClient* c __attribute__((unused)), uint32_t time){ ((AsyncEventSourceClient*)(r))->_onTimeout(time); }, this);
|
||||
_client->onDisconnect([this](void *r, AsyncClient* c){ ((AsyncEventSourceClient*)(r))->_onDisconnect(); delete c; }, this);
|
||||
|
||||
_server->_addClient(this);
|
||||
delete request;
|
||||
}
|
||||
|
||||
AsyncEventSourceClient::~AsyncEventSourceClient(){
|
||||
_messageQueue.free();
|
||||
close();
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::_queueMessage(AsyncEventSourceMessage *dataMessage){
|
||||
if(dataMessage == NULL)
|
||||
return;
|
||||
if(!connected()){
|
||||
delete dataMessage;
|
||||
return;
|
||||
}
|
||||
|
||||
_messageQueue.add(dataMessage);
|
||||
|
||||
_runQueue();
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::_onAck(size_t len, uint32_t time){
|
||||
while(len && !_messageQueue.isEmpty()){
|
||||
len = _messageQueue.front()->ack(len, time);
|
||||
if(_messageQueue.front()->finished())
|
||||
_messageQueue.remove(_messageQueue.front());
|
||||
}
|
||||
|
||||
_runQueue();
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::_onPoll(){
|
||||
if(!_messageQueue.isEmpty()){
|
||||
_runQueue();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void AsyncEventSourceClient::_onTimeout(uint32_t time __attribute__((unused))){
|
||||
_client->close(true);
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::_onDisconnect(){
|
||||
_client = NULL;
|
||||
_server->_handleDisconnect(this);
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::close(){
|
||||
if(_client != NULL)
|
||||
_client->close();
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::write(const char * message, size_t len){
|
||||
_queueMessage(new AsyncEventSourceMessage(message, len));
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::send(const char *message, const char *event, uint32_t id, uint32_t reconnect){
|
||||
String ev = generateEventMessage(message, event, id, reconnect);
|
||||
_queueMessage(new AsyncEventSourceMessage(ev.c_str(), ev.length()));
|
||||
}
|
||||
|
||||
void AsyncEventSourceClient::_runQueue(){
|
||||
while(!_messageQueue.isEmpty() && _messageQueue.front()->finished()){
|
||||
_messageQueue.remove(_messageQueue.front());
|
||||
}
|
||||
|
||||
for(auto i = _messageQueue.begin(); i != _messageQueue.end(); ++i)
|
||||
{
|
||||
if(!(*i)->sent())
|
||||
(*i)->send(_client);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handler
|
||||
|
||||
AsyncEventSource::AsyncEventSource(const String& url)
|
||||
: _url(url)
|
||||
, _clients(LinkedList<AsyncEventSourceClient *>([](AsyncEventSourceClient *c){ delete c; }))
|
||||
, _connectcb(NULL)
|
||||
{}
|
||||
|
||||
AsyncEventSource::~AsyncEventSource(){
|
||||
close();
|
||||
}
|
||||
|
||||
void AsyncEventSource::onConnect(ArEventHandlerFunction cb){
|
||||
_connectcb = cb;
|
||||
}
|
||||
|
||||
void AsyncEventSource::_addClient(AsyncEventSourceClient * client){
|
||||
/*char * temp = (char *)malloc(2054);
|
||||
if(temp != NULL){
|
||||
memset(temp+1,' ',2048);
|
||||
temp[0] = ':';
|
||||
temp[2049] = '\r';
|
||||
temp[2050] = '\n';
|
||||
temp[2051] = '\r';
|
||||
temp[2052] = '\n';
|
||||
temp[2053] = 0;
|
||||
client->write((const char *)temp, 2053);
|
||||
free(temp);
|
||||
}*/
|
||||
|
||||
_clients.add(client);
|
||||
if(_connectcb)
|
||||
_connectcb(client);
|
||||
}
|
||||
|
||||
void AsyncEventSource::_handleDisconnect(AsyncEventSourceClient * client){
|
||||
_clients.remove(client);
|
||||
}
|
||||
|
||||
void AsyncEventSource::close(){
|
||||
for(const auto &c: _clients){
|
||||
if(c->connected())
|
||||
c->close();
|
||||
}
|
||||
}
|
||||
|
||||
// pmb fix
|
||||
size_t AsyncEventSource::avgPacketsWaiting() const {
|
||||
if(_clients.isEmpty())
|
||||
return 0;
|
||||
|
||||
size_t aql=0;
|
||||
uint32_t nConnectedClients=0;
|
||||
|
||||
for(const auto &c: _clients){
|
||||
if(c->connected()) {
|
||||
aql+=c->packetsWaiting();
|
||||
++nConnectedClients;
|
||||
}
|
||||
}
|
||||
// return aql / nConnectedClients;
|
||||
return ((aql) + (nConnectedClients/2))/(nConnectedClients); // round up
|
||||
}
|
||||
|
||||
void AsyncEventSource::send(const char *message, const char *event, uint32_t id, uint32_t reconnect){
|
||||
|
||||
|
||||
String ev = generateEventMessage(message, event, id, reconnect);
|
||||
for(const auto &c: _clients){
|
||||
if(c->connected()) {
|
||||
c->write(ev.c_str(), ev.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
size_t AsyncEventSource::count() const {
|
||||
return _clients.count_if([](AsyncEventSourceClient *c){
|
||||
return c->connected();
|
||||
});
|
||||
}
|
||||
|
||||
bool AsyncEventSource::canHandle(AsyncWebServerRequest *request){
|
||||
if(request->method() != HTTP_GET || !request->url().equals(_url)) {
|
||||
return false;
|
||||
}
|
||||
request->addInterestingHeader("Last-Event-ID");
|
||||
return true;
|
||||
}
|
||||
|
||||
void AsyncEventSource::handleRequest(AsyncWebServerRequest *request){
|
||||
if((_username != "" && _password != "") && !request->authenticate(_username.c_str(), _password.c_str()))
|
||||
return request->requestAuthentication();
|
||||
request->send(new AsyncEventSourceResponse(this));
|
||||
}
|
||||
|
||||
// Response
|
||||
|
||||
AsyncEventSourceResponse::AsyncEventSourceResponse(AsyncEventSource *server){
|
||||
_server = server;
|
||||
_code = 200;
|
||||
_contentType = "text/event-stream";
|
||||
_sendContentLength = false;
|
||||
addHeader("Cache-Control", "no-cache");
|
||||
addHeader("Connection","keep-alive");
|
||||
}
|
||||
|
||||
void AsyncEventSourceResponse::_respond(AsyncWebServerRequest *request){
|
||||
String out = _assembleHead(request->version());
|
||||
request->client()->write(out.c_str(), _headLength);
|
||||
_state = RESPONSE_WAIT_ACK;
|
||||
}
|
||||
|
||||
size_t AsyncEventSourceResponse::_ack(AsyncWebServerRequest *request, size_t len, uint32_t time __attribute__((unused))){
|
||||
if(len){
|
||||
new AsyncEventSourceClient(request, _server);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
116
Software/lib/ESP Async WebServer/src/AsyncEventSource.h
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
Asynchronous WebServer library for Espressif MCUs
|
||||
|
||||
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef ASYNCEVENTSOURCE_H_
|
||||
#define ASYNCEVENTSOURCE_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#ifdef ESP32
|
||||
#include <AsyncTCP.h>
|
||||
#else
|
||||
#include <ESPAsyncTCP.h>
|
||||
#endif
|
||||
#include <ESPAsyncWebServer.h>
|
||||
|
||||
class AsyncEventSource;
|
||||
class AsyncEventSourceResponse;
|
||||
class AsyncEventSourceClient;
|
||||
typedef std::function<void(AsyncEventSourceClient *client)> ArEventHandlerFunction;
|
||||
|
||||
class AsyncEventSourceMessage {
|
||||
private:
|
||||
uint8_t * _data;
|
||||
size_t _len;
|
||||
size_t _sent;
|
||||
//size_t _ack;
|
||||
size_t _acked;
|
||||
public:
|
||||
AsyncEventSourceMessage(const char * data, size_t len);
|
||||
~AsyncEventSourceMessage();
|
||||
size_t ack(size_t len, uint32_t time __attribute__((unused)));
|
||||
size_t send(AsyncClient *client);
|
||||
bool finished(){ return _acked == _len; }
|
||||
bool sent() { return _sent == _len; }
|
||||
};
|
||||
|
||||
class AsyncEventSourceClient {
|
||||
private:
|
||||
AsyncClient *_client;
|
||||
AsyncEventSource *_server;
|
||||
uint32_t _lastId;
|
||||
LinkedList<AsyncEventSourceMessage *> _messageQueue;
|
||||
void _queueMessage(AsyncEventSourceMessage *dataMessage);
|
||||
void _runQueue();
|
||||
|
||||
public:
|
||||
|
||||
AsyncEventSourceClient(AsyncWebServerRequest *request, AsyncEventSource *server);
|
||||
~AsyncEventSourceClient();
|
||||
|
||||
AsyncClient* client(){ return _client; }
|
||||
void close();
|
||||
void write(const char * message, size_t len);
|
||||
void send(const char *message, const char *event=NULL, uint32_t id=0, uint32_t reconnect=0);
|
||||
bool connected() const { return (_client != NULL) && _client->connected(); }
|
||||
uint32_t lastId() const { return _lastId; }
|
||||
size_t packetsWaiting() const { return _messageQueue.length(); }
|
||||
|
||||
//system callbacks (do not call)
|
||||
void _onAck(size_t len, uint32_t time);
|
||||
void _onPoll();
|
||||
void _onTimeout(uint32_t time);
|
||||
void _onDisconnect();
|
||||
};
|
||||
|
||||
class AsyncEventSource: public AsyncWebHandler {
|
||||
private:
|
||||
String _url;
|
||||
LinkedList<AsyncEventSourceClient *> _clients;
|
||||
ArEventHandlerFunction _connectcb;
|
||||
public:
|
||||
AsyncEventSource(const String& url);
|
||||
~AsyncEventSource();
|
||||
|
||||
const char * url() const { return _url.c_str(); }
|
||||
void close();
|
||||
void onConnect(ArEventHandlerFunction cb);
|
||||
void send(const char *message, const char *event=NULL, uint32_t id=0, uint32_t reconnect=0);
|
||||
size_t count() const; //number clinets connected
|
||||
size_t avgPacketsWaiting() const;
|
||||
|
||||
//system callbacks (do not call)
|
||||
void _addClient(AsyncEventSourceClient * client);
|
||||
void _handleDisconnect(AsyncEventSourceClient * client);
|
||||
virtual bool canHandle(AsyncWebServerRequest *request) override final;
|
||||
virtual void handleRequest(AsyncWebServerRequest *request) override final;
|
||||
};
|
||||
|
||||
class AsyncEventSourceResponse: public AsyncWebServerResponse {
|
||||
private:
|
||||
String _content;
|
||||
AsyncEventSource *_server;
|
||||
public:
|
||||
AsyncEventSourceResponse(AsyncEventSource *server);
|
||||
void _respond(AsyncWebServerRequest *request);
|
||||
size_t _ack(AsyncWebServerRequest *request, size_t len, uint32_t time);
|
||||
bool _sourceValid() const { return true; }
|
||||
};
|
||||
|
||||
|
||||
#endif /* ASYNCEVENTSOURCE_H_ */
|