-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
81 lines (66 loc) · 2.67 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
'''
project: Half-Duplex, slimmer maken multiconnectivity modem
author: Alfred Espinosa Encarnación, Frank Montenij
date: 06-05-2021
Description: Software for the FiPy to send an acknowledgement over the LoRaWAN, 4G (CAT-M1) network of KPN and WiFi.
Changelog: Alfred made the first version.
Frank changed the code by storing the technologies and passing that dict along when running the server.
'''
import pycom # type: ignore the line
# from LIS2HH12 import LIS2HH12 # type: ignore the line
# from pycoproc_1 import Pycoproc # type: ignore the line
from LoraWAN import LoRaWAN
from LTE import CATM1
from Wifi import WiFi
from Server import Server
import test
testing = False
if __name__ == '__main__':
# If testing is true start the testscript otherwise start the server
if testing:
test.main()
else:
try:
#py = os.fsformat('/flash')
# Creating the connection objects
ship_wifi = WiFi()
lora = LoRaWAN()
kpn = CATM1()
technologies = {
"Wifi": ship_wifi,
"LTE": kpn,
"LoRa": lora
}
# Initializing the connection objects
while not ship_wifi.wlan.isconnected():
ship_wifi.getWLAN()
# commented, because at home I never have a connection. To stop the programming from getting stuck at this line it is commented.
# lora.initLoRa()
kpn.getLTE()
pycom.heartbeat(False)
# Initialise the GPS and accelerometer that are on the pytrack
# py = Pycoproc(Pycoproc.PYTRACK)
# L76 = L76GNSS(pytrack=py)
# L76.setAlwaysOn()
#acc = LIS2HH12(py)
"""
Note: Use GPS only when in outdoor environment. It will get stuck in a loop when used inside to get a fix.
"""
# L76.get_fix(force=True, debug=False)
# if L76.fixed():
# print('fixed gps')
# pycom.rgbled(0x000f00)
# else:
# L76.get_fix(force=True, debug=False)
# print("coordinates")
# # returns the coordinates
# # with debug true you see the messages parsed by the
# # library until you get a the gps is fixed
# print(L76.coordinates(debug=False))
# print(L76.getUTCDateTime(debug=False))
# Create, setup and run the server
server = Server()
server.setup_server()
server.run(technologies)
except RuntimeError:
print("exit")