update: model object change

This commit is contained in:
JackSun-qc 2022-03-29 13:24:17 +08:00
parent ccbb3ede4f
commit 9291493e1b
8 changed files with 346 additions and 154 deletions

View File

@ -2,7 +2,7 @@
"schema": "https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
"profile": {
"version": "1.0",
"productKey": "guqqtu3edVY"
"productKey": "a1q1kmZPwU2"
},
"properties": [
{
@ -116,17 +116,42 @@
"accessMode": "rw",
"required": false,
"dataType": {
"type": "enum",
"specs": {
"0": "无",
"1": "GPS",
"2": "基站",
"3": "GPS_基站",
"4": "Wifi",
"5": "GPS_Wifi",
"6": "基站_Wifi",
"7": "GPS_基站_Wifi"
}
"type": "struct",
"specs": [
{
"identifier": "gps",
"name": "GPS",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "cell",
"name": "基站",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "wifi",
"name": "Wifi",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
}
]
}
},
{
@ -198,7 +223,7 @@
},
{
"identifier": "sw_ota",
"name": "OTA功能开关",
"name": "OTA功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -211,7 +236,7 @@
},
{
"identifier": "sw_ota_auto_upgrade",
"name": "OTA自动升级功能开关",
"name": "OTA自动升级功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -224,7 +249,7 @@
},
{
"identifier": "sw_voice_listen",
"name": "语音监听功能开关",
"name": "语音监听功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -237,7 +262,7 @@
},
{
"identifier": "sw_voice_record",
"name": "录音上报功能开关",
"name": "录音上报功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -250,7 +275,7 @@
},
{
"identifier": "sw_fault_alert",
"name": "故障报警功能开关",
"name": "故障报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -263,7 +288,7 @@
},
{
"identifier": "sw_low_power_alert",
"name": "低电报警功能开关",
"name": "低电报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -276,7 +301,7 @@
},
{
"identifier": "sw_over_speed_alert",
"name": "超速报警功能开关",
"name": "超速报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -289,7 +314,7 @@
},
{
"identifier": "sw_sim_abnormal_alert",
"name": "SIM卡异常报警功能开关",
"name": "SIM卡异常报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -302,7 +327,7 @@
},
{
"identifier": "sw_disassemble_alert",
"name": "拆卸报警功能开关",
"name": "拆卸报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -315,7 +340,7 @@
},
{
"identifier": "sw_drive_behavior_alert",
"name": "驾驶行为报警功能开关",
"name": "驾驶行为报警功能",
"accessMode": "rw",
"required": false,
"dataType": {
@ -490,6 +515,22 @@
"4": "升级失败"
}
}
},
{
"identifier": "voltage",
"name": "电池电压",
"accessMode": "r",
"required": false,
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "2147483647",
"unit": "mV",
"unitName": "毫伏",
"step": "1"
}
}
}
],
"events": [
@ -602,17 +643,42 @@
"identifier": "loc_method",
"name": "定位方式",
"dataType": {
"type": "enum",
"specs": {
"0": "无",
"1": "GPS",
"2": "基站",
"3": "GPS_基站",
"4": "Wifi",
"5": "GPS_Wifi",
"6": "基站_Wifi",
"7": "GPS_基站_Wifi"
}
"type": "struct",
"specs": [
{
"identifier": "gps",
"name": "GPS",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "cell",
"name": "基站",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "wifi",
"name": "Wifi",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
}
]
}
},
{
@ -674,7 +740,7 @@
},
{
"identifier": "sw_ota",
"name": "OTA功能开关",
"name": "OTA功能",
"dataType": {
"type": "bool",
"specs": {
@ -685,7 +751,7 @@
},
{
"identifier": "sw_ota_auto_upgrade",
"name": "OTA自动升级功能开关",
"name": "OTA自动升级功能",
"dataType": {
"type": "bool",
"specs": {
@ -696,7 +762,7 @@
},
{
"identifier": "sw_voice_listen",
"name": "语音监听功能开关",
"name": "语音监听功能",
"dataType": {
"type": "bool",
"specs": {
@ -707,7 +773,7 @@
},
{
"identifier": "sw_voice_record",
"name": "录音上报功能开关",
"name": "录音上报功能",
"dataType": {
"type": "bool",
"specs": {
@ -718,7 +784,7 @@
},
{
"identifier": "sw_fault_alert",
"name": "故障报警功能开关",
"name": "故障报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -729,7 +795,7 @@
},
{
"identifier": "sw_low_power_alert",
"name": "低电报警功能开关",
"name": "低电报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -740,7 +806,7 @@
},
{
"identifier": "sw_over_speed_alert",
"name": "超速报警功能开关",
"name": "超速报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -751,7 +817,7 @@
},
{
"identifier": "sw_sim_abnormal_alert",
"name": "SIM卡异常报警功能开关",
"name": "SIM卡异常报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -762,7 +828,7 @@
},
{
"identifier": "sw_disassemble_alert",
"name": "拆卸报警功能开关",
"name": "拆卸报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -773,7 +839,7 @@
},
{
"identifier": "sw_drive_behavior_alert",
"name": "驾驶行为报警功能开关",
"name": "驾驶行为报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -931,6 +997,20 @@
"4": "升级失败"
}
}
},
{
"identifier": "voltage",
"name": "电池电压",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "2147483647",
"unit": "mV",
"unitName": "毫伏",
"step": "1"
}
}
}
]
},
@ -1025,17 +1105,42 @@
"identifier": "loc_method",
"name": "定位方式",
"dataType": {
"type": "enum",
"specs": {
"0": "无",
"1": "GPS",
"2": "基站",
"3": "GPS_基站",
"4": "Wifi",
"5": "GPS_Wifi",
"6": "基站_Wifi",
"7": "GPS_基站_Wifi"
}
"type": "struct",
"specs": [
{
"identifier": "gps",
"name": "GPS",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "cell",
"name": "基站",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "wifi",
"name": "Wifi",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
}
]
}
},
{
@ -1089,7 +1194,7 @@
},
{
"identifier": "sw_ota",
"name": "OTA功能开关",
"name": "OTA功能",
"dataType": {
"type": "bool",
"specs": {
@ -1100,7 +1205,7 @@
},
{
"identifier": "sw_ota_auto_upgrade",
"name": "OTA自动升级功能开关",
"name": "OTA自动升级功能",
"dataType": {
"type": "bool",
"specs": {
@ -1111,7 +1216,7 @@
},
{
"identifier": "sw_voice_listen",
"name": "语音监听功能开关",
"name": "语音监听功能",
"dataType": {
"type": "bool",
"specs": {
@ -1122,7 +1227,7 @@
},
{
"identifier": "sw_voice_record",
"name": "录音上报功能开关",
"name": "录音上报功能",
"dataType": {
"type": "bool",
"specs": {
@ -1133,7 +1238,7 @@
},
{
"identifier": "sw_fault_alert",
"name": "故障报警功能开关",
"name": "故障报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1144,7 +1249,7 @@
},
{
"identifier": "sw_low_power_alert",
"name": "低电报警功能开关",
"name": "低电报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1155,7 +1260,7 @@
},
{
"identifier": "sw_over_speed_alert",
"name": "超速报警功能开关",
"name": "超速报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1166,7 +1271,7 @@
},
{
"identifier": "sw_sim_abnormal_alert",
"name": "SIM卡异常报警功能开关",
"name": "SIM卡异常报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1177,7 +1282,7 @@
},
{
"identifier": "sw_disassemble_alert",
"name": "拆卸报警功能开关",
"name": "拆卸报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1188,7 +1293,7 @@
},
{
"identifier": "sw_drive_behavior_alert",
"name": "驾驶行为报警功能开关",
"name": "驾驶行为报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1269,7 +1374,8 @@
"device_module_status",
"gps_mode",
"user_ota_action",
"ota_status"
"ota_status",
"voltage"
],
"outputData": [
{
@ -1373,17 +1479,42 @@
"identifier": "loc_method",
"name": "定位方式",
"dataType": {
"type": "enum",
"specs": {
"0": "无",
"1": "GPS",
"2": "基站",
"3": "GPS_基站",
"4": "Wifi",
"5": "GPS_Wifi",
"6": "基站_Wifi",
"7": "GPS_基站_Wifi"
}
"type": "struct",
"specs": [
{
"identifier": "gps",
"name": "GPS",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "cell",
"name": "基站",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
},
{
"identifier": "wifi",
"name": "Wifi",
"dataType": {
"type": "bool",
"specs": {
"0": "启用",
"1": "禁用"
}
}
}
]
}
},
{
@ -1445,7 +1576,7 @@
},
{
"identifier": "sw_ota",
"name": "OTA功能开关",
"name": "OTA功能",
"dataType": {
"type": "bool",
"specs": {
@ -1456,7 +1587,7 @@
},
{
"identifier": "sw_ota_auto_upgrade",
"name": "OTA自动升级功能开关",
"name": "OTA自动升级功能",
"dataType": {
"type": "bool",
"specs": {
@ -1467,7 +1598,7 @@
},
{
"identifier": "sw_voice_listen",
"name": "语音监听功能开关",
"name": "语音监听功能",
"dataType": {
"type": "bool",
"specs": {
@ -1478,7 +1609,7 @@
},
{
"identifier": "sw_voice_record",
"name": "录音上报功能开关",
"name": "录音上报功能",
"dataType": {
"type": "bool",
"specs": {
@ -1489,7 +1620,7 @@
},
{
"identifier": "sw_fault_alert",
"name": "故障报警功能开关",
"name": "故障报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1500,7 +1631,7 @@
},
{
"identifier": "sw_low_power_alert",
"name": "低电报警功能开关",
"name": "低电报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1511,7 +1642,7 @@
},
{
"identifier": "sw_over_speed_alert",
"name": "超速报警功能开关",
"name": "超速报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1522,7 +1653,7 @@
},
{
"identifier": "sw_sim_abnormal_alert",
"name": "SIM卡异常报警功能开关",
"name": "SIM卡异常报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1533,7 +1664,7 @@
},
{
"identifier": "sw_disassemble_alert",
"name": "拆卸报警功能开关",
"name": "拆卸报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1544,7 +1675,7 @@
},
{
"identifier": "sw_drive_behavior_alert",
"name": "驾驶行为报警功能开关",
"name": "驾驶行为报警功能",
"dataType": {
"type": "bool",
"specs": {
@ -1702,6 +1833,20 @@
"4": "升级失败"
}
}
},
{
"identifier": "voltage",
"name": "电池电压",
"dataType": {
"type": "int",
"specs": {
"min": "0",
"max": "2147483647",
"unit": "mV",
"unitName": "毫伏",
"step": "1"
}
}
}
]
}

View File

@ -68,6 +68,7 @@ object_model = {
'user_ota_action',
'ota_status',
'GeoLocation',
'voltage',
],
}

View File

@ -84,3 +84,6 @@ class Battery(object):
temp = 20
self.now_energy = get_soc(temp, volt_arg)
return self.now_energy
def voltage(self):
return Power.getVbatt()

View File

@ -52,6 +52,7 @@ object_model = [
(37, ('gps_mode', 'r')),
(38, ('user_ota_action', 'w')),
(39, ('ota_status', 'r')),
(41, ('voltage', 'r')),
# event
(6, ('sos_alert', 'r')),
@ -71,6 +72,11 @@ object_model_struct = {
'light_sensor_error': 4,
'move_sensor_error': 5,
'mike_error': 6,
},
'loc_method': {
'gps': 1,
'cell': 2,
'wifi': 3,
}
}
@ -174,7 +180,7 @@ class QuecThing(object):
return res
def eventCB(self, data):
log.info("event:", data)
log.info("event: %s" % str(data))
event = data[0]
errcode = data[1]
if len(data) > 2:

View File

@ -107,8 +107,16 @@ class DownLinkOption(object):
for arg in args:
if hasattr(settings.default_values_app, arg[0]):
set_res = settings.settings.set(arg[0], arg[1])
log.debug('key: %s, val: %s, set_res: %s', (arg[0], arg[1], set_res))
key = arg[0]
value = arg[1]
if key == 'loc_method':
v = '0b'
v += str(int(value.get(3, 0)))
v += str(int(value.get(2, 0)))
v += str(int(value.get(1, 0)))
value = int(v, 2)
set_res = settings.settings.set(key, value)
log.debug('key: %s, val: %s, set_res: %s' % (key, value, set_res))
if setting_flag == 0:
setting_flag = 1
if hasattr(self.controller, arg[0]):

View File

@ -207,7 +207,7 @@ class default_values_sys(object):
drive_behavior_code = 0
cloud = _cloud.AliYun
cloud = _cloud.quecIot
cloud_init_params = {}
@ -238,30 +238,14 @@ class default_values_sys(object):
# 'DS': '',
# }
# TrackerEC600N
# tracker_dev_jack
_AliYun = {
'PK': 'guqqtu3edVY',
'PS': 'xChL7HREtPyYCtPM',
'DK': 'TrackerEC600N',
'DS': 'a3153ed0c2f68db6e2f47e0769f966a2',
'PK': 'a1q1kmZPwU2',
'PS': 'HQraBqtV8WsfCEuy',
'DK': 'tracker_dev_jack',
'DS': 'bfdfcca5075715e8309eff8597663c4b',
}
# # alitrackerdemo0326
# _AliYun = {
# 'PK': 'guqqtu3edVY',
# 'PS': 'xChL7HREtPyYCtPM',
# 'DK': 'alitrackerdemo0326',
# 'DS': 'b01307100686698bbc71fc4af230baf9',
# }
# # ali_tracker_demo_0306_jun
# _AliYun = {
# 'PK': 'guqqtu3edVY',
# 'PS': 'xChL7HREtPyYCtPM',
# 'DK': 'ali_tracker_demo_0306_jun',
# 'DS': '38d78764407d08776c74e319a7802d88',
# }
_JTT808 = {
'PK': '',
'PS': '',

View File

@ -119,14 +119,29 @@ class Tracker(Singleton):
device_data.update({
'power_switch': power_switch,
'energy': energy,
'voltage': self.battery.voltage(),
'local_time': self.get_local_time(),
'ota_status': current_settings['sys']['ota_status'],
'drive_behavior_code': current_settings['sys']['drive_behavior_code'],
})
device_data.update(current_settings['app'])
device_data.update({'loc_method': self.format_loc_method(current_settings['app']['loc_method'])})
return device_data
def format_loc_method(self, data):
loc_method = '%04d' % int(bin(data)[2:])
gps = bool(int(loc_method[-1]))
cell = bool(int(loc_method[-2]))
wifi = bool(int(loc_method[-3]))
loc_method = {
'gps': gps,
'cell': cell,
'wifi': wifi,
}
return loc_method
def get_device_check(self):
alert_data = {}
device_module_status = []

View File

@ -2,7 +2,7 @@
"profile":{
"tslVersion":"1.1.0",
"productKey":"p11275",
"version":"20220328195506205"
"version":"20220329105723754"
},
"properties":[
{
@ -59,48 +59,62 @@
{
"specs":[
{
"dataType":"ENUM",
"name":"无",
"value":"0"
},
{
"dataType":"ENUM",
"specs":[
{
"dataType":"BOOL",
"name":"启用",
"value":"true"
},
{
"dataType":"BOOL",
"name":"禁用",
"value":"false"
}
],
"code":"gps",
"dataType":"BOOL",
"name":"GPS",
"value":"1"
"id":1
},
{
"dataType":"ENUM",
"specs":[
{
"dataType":"BOOL",
"name":"启用",
"value":"true"
},
{
"dataType":"BOOL",
"name":"禁用",
"value":"false"
}
],
"code":"cell",
"dataType":"BOOL",
"name":"基站",
"value":"2"
"id":2
},
{
"dataType":"ENUM",
"name":"GPS_基站",
"value":"3"
},
{
"dataType":"ENUM",
"specs":[
{
"dataType":"BOOL",
"name":"启用",
"value":"true"
},
{
"dataType":"BOOL",
"name":"禁用",
"value":"false"
}
],
"code":"wifi",
"dataType":"BOOL",
"name":"Wifi",
"value":"4"
},
{
"dataType":"ENUM",
"name":"GPS_Wifi",
"value":"5"
},
{
"dataType":"ENUM",
"name":"基站_Wifi",
"value":"6"
},
{
"dataType":"ENUM",
"name":"GPS_基站_Wifi",
"value":"7"
"id":3
}
],
"code":"loc_method",
"dataType":"ENUM",
"dataType":"STRUCT",
"name":"定位方式",
"subType":"RW",
"id":24,
@ -203,7 +217,7 @@
],
"code":"sw_ota",
"dataType":"BOOL",
"name":"OTA功能开关",
"name":"OTA功能",
"subType":"RW",
"id":12,
"sort":9,
@ -225,7 +239,7 @@
],
"code":"sw_ota_auto_upgrade",
"dataType":"BOOL",
"name":"OTA自动升级开关",
"name":"OTA自动升级",
"subType":"RW",
"id":13,
"sort":10,
@ -247,7 +261,7 @@
],
"code":"sw_voice_listen",
"dataType":"BOOL",
"name":"语音监听功能开关",
"name":"语音监听",
"subType":"RW",
"id":10,
"sort":11,
@ -269,7 +283,7 @@
],
"code":"sw_voice_record",
"dataType":"BOOL",
"name":"录音上报功能开关",
"name":"录音上报",
"subType":"RW",
"id":11,
"sort":12,
@ -291,7 +305,7 @@
],
"code":"sw_fault_alert",
"dataType":"BOOL",
"name":"故障报警功能开关",
"name":"故障报警功能",
"subType":"RW",
"id":27,
"sort":13,
@ -313,7 +327,7 @@
],
"code":"sw_low_power_alert",
"dataType":"BOOL",
"name":"低电报警功能开关",
"name":"低电报警功能",
"subType":"RW",
"id":28,
"sort":14,
@ -335,7 +349,7 @@
],
"code":"sw_over_speed_alert",
"dataType":"BOOL",
"name":"超速报警功能开关",
"name":"超速报警功能",
"subType":"RW",
"id":29,
"sort":15,
@ -357,7 +371,7 @@
],
"code":"sw_sim_abnormal_alert",
"dataType":"BOOL",
"name":"SIM卡异常报警功能开关",
"name":"SIM卡异常报警功能",
"subType":"RW",
"id":30,
"sort":16,
@ -379,7 +393,7 @@
],
"code":"sw_disassemble_alert",
"dataType":"BOOL",
"name":"拆卸报警功能开关",
"name":"拆卸报警功能",
"subType":"RW",
"id":31,
"sort":17,
@ -401,7 +415,7 @@
],
"code":"sw_drive_behavior_alert",
"dataType":"BOOL",
"name":"驾驶行为报警功能开关",
"name":"异常驾驶行为报警功能",
"subType":"RW",
"id":32,
"sort":18,
@ -684,6 +698,22 @@
"sort":32,
"type":"PROPERTY",
"desc":""
},
{
"specs":{
"unit":"mV",
"min":"0",
"max":"2147483647",
"step":"1"
},
"code":"voltage",
"dataType":"INT",
"name":"电池电压",
"subType":"R",
"id":41,
"sort":33,
"type":"PROPERTY",
"desc":""
}
],
"events":[