Skip to content

update solution-tracker files #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
88 changes: 88 additions & 0 deletions QPY_OCPU_BETA0001_EC200U_EUAA_FW/changelog - EC200UEU_AA_BETA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
## Release History
**[QPY_OCPU_EC200UEU_AA_BETA] 2024-04-18**
* ZH
* 支持功能list
1. app_fota
2. PWM
3. dataCall
4. fota
5. log
6. net
7. ntptime
8. pm
9. queue
10. sim
11. sys_bus
12. uio
13. ujson
14. BLE
15. usocket
16. utime
17. _thread
18. Timer
19. RTC
20. WDT
21. Pin
22. ExtInt
23. UART
24. SPI
25. IIC
26. Key
27. Power
28. ADC
29. PowerKey
30. TencentYun
31. voicecall
32. wifiscan
33. wifilocator
34. SMS
35. Audio
36. Ethernet
37. AliYun
38. GNSS
39. USSD




* EN
* Support function list
1. app_fota
2. PWM
3. dataCall
4. fota
5. log
6. net
7. ntptime
8. pm
9. queue
10. sim
11. sys_bus
12. uio
13. ujson
14. BLE
15. usocket
16. utime
17. _thread
18. Timer
19. RTC
20. WDT
21. Pin
22. ExtInt
23. UART
24. SPI
25. IIC
26. Key
27. Power
28. ADC
29. PowerKey
30. TencentYun
31. voicecall
32. wifiscan
33. wifilocator
34. SMS
35. Audio
36. Ethernet
37. AliYun
38. GNSS
39. USSD
120 changes: 120 additions & 0 deletions code/_main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
# Copyright (c) Quectel Wireless Solution, Co., Ltd.All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""
@file :_main.py
@author :Jack Sun ([email protected])
@brief :Project start.
@version :2.2.0
@date :2022-10-31 14:42:25
@copyright :Copyright (c) 2022
"""

import _thread
try:
from modules.battery import Battery
from modules.history import History
from modules.logging import getLogger
from modules.net_manage import NetManager
from modules.thingsboard import TBDeviceMQTTClient
from modules.power_manage import PowerManage
from modules.aliIot import AliIot, AliIotOTA
from modules.location import GNSS, CellLocator, WiFiLocator, CoordinateSystemConvert
from settings_user import UserConfig
from tracker_tb import Tracker as TBTracker
from tracker_ali import Tracker as AliTracker
from settings import Settings, PROJECT_NAME, PROJECT_VERSION, FIRMWARE_NAME, FIRMWARE_VERSION
except ImportError:
from usr.modules.battery import Battery
from usr.modules.history import History
from usr.modules.logging import getLogger
from usr.modules.net_manage import NetManager
from usr.modules.thingsboard import TBDeviceMQTTClient
from usr.modules.power_manage import PowerManage
from usr.modules.aliIot import AliIot, AliIotOTA
from usr.modules.location import GNSS, CellLocator, WiFiLocator, CoordinateSystemConvert
from usr.settings_user import UserConfig
from usr.tracker_tb import Tracker as TBTracker
from usr.tracker_ali import Tracker as AliTracker
from usr.settings import Settings, PROJECT_NAME, PROJECT_VERSION, FIRMWARE_NAME, FIRMWARE_VERSION

log = getLogger(__name__)

def main():
log.debug("[x] Main start.")
log.info("PROJECT_NAME: %s, PROJECT_VERSION: %s" % (PROJECT_NAME, PROJECT_VERSION))
log.info("DEVICE_FIRMWARE_NAME: %s, DEVICE_FIRMWARE_VERSION: %s" % (FIRMWARE_NAME, FIRMWARE_VERSION))

# Init settings.
settings = Settings()
# Init battery.
battery = Battery()
# Init history
history = History()
# Init power manage and set device low energy.
power_manage = PowerManage()
power_manage.autosleep(1)
# Init net modules and start net connect.
net_manager = NetManager()
_thread.stack_size(0x1000)
_thread.start_new_thread(net_manager.net_connect, ())
# Init GNSS modules and start reading and parsing gnss data.
loc_cfg = settings.read("loc")
gnss = GNSS(**loc_cfg["gps_cfg"])
gnss.set_trans(0)
gnss.start()
# Init cell and wifi location modules.
cell = CellLocator(**loc_cfg["cell_cfg"])
wifi = WiFiLocator(**loc_cfg["wifi_cfg"])
cyc = CoordinateSystemConvert()
# Init tracker business modules.
user_cfg = settings.read("user")
server_cfg = settings.read("server")
# Init coordinate system convert modules.
if user_cfg["server"] == UserConfig._server.AliIot:
server = AliIot(**server_cfg)
server_ota = AliIotOTA(PROJECT_NAME, FIRMWARE_NAME)
server_ota.set_server(server)
tracker = AliTracker()
elif user_cfg["server"] == UserConfig._server.ThingsBoard:
# Init server modules.
server = TBDeviceMQTTClient(**server_cfg)
tracker = TBTracker()
else:
raise ValueError("User config server is not compared.")
tracker.add_module(settings)
tracker.add_module(battery)
tracker.add_module(history)
tracker.add_module(net_manager)
tracker.add_module(server)
tracker.add_module(server_ota)
tracker.add_module(gnss)
tracker.add_module(cell)
tracker.add_module(wifi)
tracker.add_module(cyc)
server.add_event("over_speed_alert")
server.add_event("sim_abnormal_alert")
server.add_event("low_power_alert")
server.add_event("fault_alert")
# Set net modules callback.
net_manager.set_callback(tracker.net_callback)
# Set server modules callback.
server.set_callback(tracker.server_callback)
# Start tracker business.
tracker.running()

log.debug("[x] Main over.")

if __name__ == "__main__":
main()
97 changes: 0 additions & 97 deletions code/main.py

This file was deleted.

42 changes: 20 additions & 22 deletions code/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,13 @@
import usys as sys

try:
from usr.dev_settings_server import AliIotConfig, ThingsBoardConfig
from settings_server import AliIotConfig, ThingsBoardConfig
from settings_loc import LocConfig
from settings_user import UserConfig
except ImportError:
from usr.settings_server import AliIotConfig, ThingsBoardConfig
try:
from usr.dev_settings_loc import LocConfig
except ImportError:
from usr.settings_loc import LocConfig
from usr.settings_user import UserConfig
from usr.settings_user import UserConfig

PROJECT_NAME = "QuecPython-Tracker"

Expand All @@ -45,7 +44,6 @@

FIRMWARE_VERSION = modem.getDevFwVersion()


class Settings:

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

def __init_config(self):
try:
if not ql_fs.path_exists(self.__file):
# UserConfig init
self.__data["user"] = {k: v for k, v in UserConfig.__dict__.items() if not k.startswith("_")}
self.__data["user"]["ota_status"]["sys_current_version"] = FIRMWARE_VERSION
self.__data["user"]["ota_status"]["app_current_version"] = PROJECT_VERSION
if ql_fs.path_exists(self.__file):
ql_fs.touch(self.__file, {})

# UserConfig init
self.__data["user"] = {k: v for k, v in UserConfig.__dict__.items() if not k.startswith("_")}
self.__data["user"]["ota_status"]["sys_current_version"] = FIRMWARE_VERSION
self.__data["user"]["ota_status"]["app_current_version"] = PROJECT_VERSION

# CloudConfig init
self.__data["server"] = {}
if self.__data["user"]["server"] == UserConfig._server.AliIot:
self.__data["server"] = {k: v for k, v in AliIotConfig.__dict__.items() if not k.startswith("_")}
elif self.__data["user"]["server"] == UserConfig._server.ThingsBoard:
self.__data["server"] = {k: v for k, v in ThingsBoardConfig.__dict__.items() if not k.startswith("_")}
# CloudConfig init
self.__data["server"] = {}
if self.__data["user"]["server"] == UserConfig._server.AliIot:
self.__data["server"] = {k: v for k, v in AliIotConfig.__dict__.items() if not k.startswith("_")}
elif self.__data["user"]["server"] == UserConfig._server.ThingsBoard:
self.__data["server"] = {k: v for k, v in ThingsBoardConfig.__dict__.items() if not k.startswith("_")}

# LocConfig init
self.__data["loc"] = {k: v for k, v in LocConfig.__dict__.items() if not k.startswith("_")}
ql_fs.touch(self.__file, self.__data)
else:
self.__data = ql_fs.read_json(self.__file)
# LocConfig init
self.__data["loc"] = {k: v for k, v in LocConfig.__dict__.items() if not k.startswith("_")}
ql_fs.touch(self.__file, self.__data)
except Exception as e:
sys.print_exception(e)

Expand Down
Loading