Skip to content

Commit 8e9905e

Browse files
authored
Merge pull request #6 from qinqiao555/master
update solution-tracker files
2 parents 389da83 + fce72aa commit 8e9905e

File tree

93 files changed

+622
-2558
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+622
-2558
lines changed
Binary file not shown.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
## Release History
2+
**[QPY_OCPU_EC200UEU_AA_BETA] 2024-04-18**
3+
* ZH
4+
* 支持功能list
5+
1. app_fota
6+
2. PWM
7+
3. dataCall
8+
4. fota
9+
5. log
10+
6. net
11+
7. ntptime
12+
8. pm
13+
9. queue
14+
10. sim
15+
11. sys_bus
16+
12. uio
17+
13. ujson
18+
14. BLE
19+
15. usocket
20+
16. utime
21+
17. _thread
22+
18. Timer
23+
19. RTC
24+
20. WDT
25+
21. Pin
26+
22. ExtInt
27+
23. UART
28+
24. SPI
29+
25. IIC
30+
26. Key
31+
27. Power
32+
28. ADC
33+
29. PowerKey
34+
30. TencentYun
35+
31. voicecall
36+
32. wifiscan
37+
33. wifilocator
38+
34. SMS
39+
35. Audio
40+
36. Ethernet
41+
37. AliYun
42+
38. GNSS
43+
39. USSD
44+
45+
46+
47+
48+
* EN
49+
* Support function list
50+
1. app_fota
51+
2. PWM
52+
3. dataCall
53+
4. fota
54+
5. log
55+
6. net
56+
7. ntptime
57+
8. pm
58+
9. queue
59+
10. sim
60+
11. sys_bus
61+
12. uio
62+
13. ujson
63+
14. BLE
64+
15. usocket
65+
16. utime
66+
17. _thread
67+
18. Timer
68+
19. RTC
69+
20. WDT
70+
21. Pin
71+
22. ExtInt
72+
23. UART
73+
24. SPI
74+
25. IIC
75+
26. Key
76+
27. Power
77+
28. ADC
78+
29. PowerKey
79+
30. TencentYun
80+
31. voicecall
81+
32. wifiscan
82+
33. wifilocator
83+
34. SMS
84+
35. Audio
85+
36. Ethernet
86+
37. AliYun
87+
38. GNSS
88+
39. USSD

code/_main.py

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""
16+
@file :_main.py
17+
@author :Jack Sun (jack.sun@quectel.com)
18+
@brief :Project start.
19+
@version :2.2.0
20+
@date :2022-10-31 14:42:25
21+
@copyright :Copyright (c) 2022
22+
"""
23+
24+
import _thread
25+
try:
26+
from modules.battery import Battery
27+
from modules.history import History
28+
from modules.logging import getLogger
29+
from modules.net_manage import NetManager
30+
from modules.thingsboard import TBDeviceMQTTClient
31+
from modules.power_manage import PowerManage
32+
from modules.aliIot import AliIot, AliIotOTA
33+
from modules.location import GNSS, CellLocator, WiFiLocator, CoordinateSystemConvert
34+
from settings_user import UserConfig
35+
from tracker_tb import Tracker as TBTracker
36+
from tracker_ali import Tracker as AliTracker
37+
from settings import Settings, PROJECT_NAME, PROJECT_VERSION, FIRMWARE_NAME, FIRMWARE_VERSION
38+
except ImportError:
39+
from usr.modules.battery import Battery
40+
from usr.modules.history import History
41+
from usr.modules.logging import getLogger
42+
from usr.modules.net_manage import NetManager
43+
from usr.modules.thingsboard import TBDeviceMQTTClient
44+
from usr.modules.power_manage import PowerManage
45+
from usr.modules.aliIot import AliIot, AliIotOTA
46+
from usr.modules.location import GNSS, CellLocator, WiFiLocator, CoordinateSystemConvert
47+
from usr.settings_user import UserConfig
48+
from usr.tracker_tb import Tracker as TBTracker
49+
from usr.tracker_ali import Tracker as AliTracker
50+
from usr.settings import Settings, PROJECT_NAME, PROJECT_VERSION, FIRMWARE_NAME, FIRMWARE_VERSION
51+
52+
log = getLogger(__name__)
53+
54+
def main():
55+
log.debug("[x] Main start.")
56+
log.info("PROJECT_NAME: %s, PROJECT_VERSION: %s" % (PROJECT_NAME, PROJECT_VERSION))
57+
log.info("DEVICE_FIRMWARE_NAME: %s, DEVICE_FIRMWARE_VERSION: %s" % (FIRMWARE_NAME, FIRMWARE_VERSION))
58+
59+
# Init settings.
60+
settings = Settings()
61+
# Init battery.
62+
battery = Battery()
63+
# Init history
64+
history = History()
65+
# Init power manage and set device low energy.
66+
power_manage = PowerManage()
67+
power_manage.autosleep(1)
68+
# Init net modules and start net connect.
69+
net_manager = NetManager()
70+
_thread.stack_size(0x1000)
71+
_thread.start_new_thread(net_manager.net_connect, ())
72+
# Init GNSS modules and start reading and parsing gnss data.
73+
loc_cfg = settings.read("loc")
74+
gnss = GNSS(**loc_cfg["gps_cfg"])
75+
gnss.set_trans(0)
76+
gnss.start()
77+
# Init cell and wifi location modules.
78+
cell = CellLocator(**loc_cfg["cell_cfg"])
79+
wifi = WiFiLocator(**loc_cfg["wifi_cfg"])
80+
cyc = CoordinateSystemConvert()
81+
# Init tracker business modules.
82+
user_cfg = settings.read("user")
83+
server_cfg = settings.read("server")
84+
# Init coordinate system convert modules.
85+
if user_cfg["server"] == UserConfig._server.AliIot:
86+
server = AliIot(**server_cfg)
87+
server_ota = AliIotOTA(PROJECT_NAME, FIRMWARE_NAME)
88+
server_ota.set_server(server)
89+
tracker = AliTracker()
90+
elif user_cfg["server"] == UserConfig._server.ThingsBoard:
91+
# Init server modules.
92+
server = TBDeviceMQTTClient(**server_cfg)
93+
tracker = TBTracker()
94+
else:
95+
raise ValueError("User config server is not compared.")
96+
tracker.add_module(settings)
97+
tracker.add_module(battery)
98+
tracker.add_module(history)
99+
tracker.add_module(net_manager)
100+
tracker.add_module(server)
101+
tracker.add_module(server_ota)
102+
tracker.add_module(gnss)
103+
tracker.add_module(cell)
104+
tracker.add_module(wifi)
105+
tracker.add_module(cyc)
106+
server.add_event("over_speed_alert")
107+
server.add_event("sim_abnormal_alert")
108+
server.add_event("low_power_alert")
109+
server.add_event("fault_alert")
110+
# Set net modules callback.
111+
net_manager.set_callback(tracker.net_callback)
112+
# Set server modules callback.
113+
server.set_callback(tracker.server_callback)
114+
# Start tracker business.
115+
tracker.running()
116+
117+
log.debug("[x] Main over.")
118+
119+
if __name__ == "__main__":
120+
main()

code/main.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

code/settings.py

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,13 @@
2828
import usys as sys
2929

3030
try:
31-
from usr.dev_settings_server import AliIotConfig, ThingsBoardConfig
31+
from settings_server import AliIotConfig, ThingsBoardConfig
32+
from settings_loc import LocConfig
33+
from settings_user import UserConfig
3234
except ImportError:
3335
from usr.settings_server import AliIotConfig, ThingsBoardConfig
34-
try:
35-
from usr.dev_settings_loc import LocConfig
36-
except ImportError:
3736
from usr.settings_loc import LocConfig
38-
from usr.settings_user import UserConfig
37+
from usr.settings_user import UserConfig
3938

4039
PROJECT_NAME = "QuecPython-Tracker"
4140

@@ -45,7 +44,6 @@
4544

4645
FIRMWARE_VERSION = modem.getDevFwVersion()
4746

48-
4947
class Settings:
5048

5149
def __init__(self, config_file="/usr/tracker_config.json"):
@@ -56,24 +54,24 @@ def __init__(self, config_file="/usr/tracker_config.json"):
5654

5755
def __init_config(self):
5856
try:
59-
if not ql_fs.path_exists(self.__file):
60-
# UserConfig init
61-
self.__data["user"] = {k: v for k, v in UserConfig.__dict__.items() if not k.startswith("_")}
62-
self.__data["user"]["ota_status"]["sys_current_version"] = FIRMWARE_VERSION
63-
self.__data["user"]["ota_status"]["app_current_version"] = PROJECT_VERSION
57+
if ql_fs.path_exists(self.__file):
58+
ql_fs.touch(self.__file, {})
59+
60+
# UserConfig init
61+
self.__data["user"] = {k: v for k, v in UserConfig.__dict__.items() if not k.startswith("_")}
62+
self.__data["user"]["ota_status"]["sys_current_version"] = FIRMWARE_VERSION
63+
self.__data["user"]["ota_status"]["app_current_version"] = PROJECT_VERSION
6464

65-
# CloudConfig init
66-
self.__data["server"] = {}
67-
if self.__data["user"]["server"] == UserConfig._server.AliIot:
68-
self.__data["server"] = {k: v for k, v in AliIotConfig.__dict__.items() if not k.startswith("_")}
69-
elif self.__data["user"]["server"] == UserConfig._server.ThingsBoard:
70-
self.__data["server"] = {k: v for k, v in ThingsBoardConfig.__dict__.items() if not k.startswith("_")}
65+
# CloudConfig init
66+
self.__data["server"] = {}
67+
if self.__data["user"]["server"] == UserConfig._server.AliIot:
68+
self.__data["server"] = {k: v for k, v in AliIotConfig.__dict__.items() if not k.startswith("_")}
69+
elif self.__data["user"]["server"] == UserConfig._server.ThingsBoard:
70+
self.__data["server"] = {k: v for k, v in ThingsBoardConfig.__dict__.items() if not k.startswith("_")}
7171

72-
# LocConfig init
73-
self.__data["loc"] = {k: v for k, v in LocConfig.__dict__.items() if not k.startswith("_")}
74-
ql_fs.touch(self.__file, self.__data)
75-
else:
76-
self.__data = ql_fs.read_json(self.__file)
72+
# LocConfig init
73+
self.__data["loc"] = {k: v for k, v in LocConfig.__dict__.items() if not k.startswith("_")}
74+
ql_fs.touch(self.__file, self.__data)
7775
except Exception as e:
7876
sys.print_exception(e)
7977

0 commit comments

Comments
 (0)