pymammotion 0.4.0a3__py3-none-any.whl → 0.4.0a5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -695,7 +695,6 @@ class CloudIOTGateway:
695
695
  raise SetupException(response_body_dict.get("code"))
696
696
  if response_body_dict.get("code") == 6205:
697
697
  raise DeviceOfflineException(response_body_dict.get("code"))
698
- """Device is offline."""
699
698
 
700
699
  return message_id
701
700
 
@@ -7,7 +7,7 @@ import betterproto
7
7
  from mashumaro.mixins.orjson import DataClassORJSONMixin
8
8
 
9
9
  from pymammotion.data.model import HashList, RapidState
10
- from pymammotion.data.model.device_info import MowerInfo
10
+ from pymammotion.data.model.device_info import MowerInfo, DeviceFirmwares
11
11
  from pymammotion.data.model.location import Location
12
12
  from pymammotion.data.model.report_info import ReportData
13
13
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
@@ -16,7 +16,7 @@ from pymammotion.proto.mctrl_sys import (
16
16
  MowToAppInfoT,
17
17
  ReportInfoData,
18
18
  SystemRapidStateTunnelMsg,
19
- SystemUpdateBufMsg,
19
+ SystemUpdateBufMsg, DeviceFwInfo,
20
20
  )
21
21
  from pymammotion.utility.constant import WorkMode
22
22
  from pymammotion.utility.conversions import parse_double
@@ -33,6 +33,7 @@ class MowingDevice(DataClassORJSONMixin):
33
33
  location: Location = field(default_factory=Location)
34
34
  mowing_state: RapidState = field(default_factory=RapidState)
35
35
  report_data: ReportData = field(default_factory=ReportData)
36
+ device_firmwares: DeviceFirmwares = field(default_factory=DeviceFirmwares)
36
37
  err_code_list: list = field(default_factory=list)
37
38
  err_code_list_time: Optional[list] = field(default_factory=list)
38
39
  error_codes: dict[str, ErrorInfo] = field(default_factory=dict)
@@ -84,7 +85,7 @@ class MowingDevice(DataClassORJSONMixin):
84
85
  for index, location in enumerate(toapp_report_data.locations):
85
86
  if index == 0 and location.real_pos_y != 0:
86
87
  self.location.position_type = location.pos_type
87
- self.location.orientation = location.real_toward / 10000
88
+ self.location.orientation = int(location.real_toward / 10000)
88
89
  self.location.device = coordinate_converter.enu_to_lla(
89
90
  parse_double(location.real_pos_y, 4.0), parse_double(location.real_pos_x, 4.0)
90
91
  )
@@ -93,13 +94,16 @@ class MowingDevice(DataClassORJSONMixin):
93
94
  location.zone_hash if self.report_data.dev.sys_status == WorkMode.MODE_WORKING else 0
94
95
  )
95
96
 
97
+ if toapp_report_data.fw_info:
98
+ self.update_device_firmwares(toapp_report_data.fw_info)
99
+
96
100
  self.report_data.update(toapp_report_data.to_dict(casing=betterproto.Casing.SNAKE))
97
101
 
98
102
  def run_state_update(self, rapid_state: SystemRapidStateTunnelMsg) -> None:
99
103
  coordinate_converter = CoordinateConverter(self.location.RTK.latitude, self.location.RTK.longitude)
100
104
  self.mowing_state = RapidState().from_raw(rapid_state.rapid_state_data)
101
105
  self.location.position_type = self.mowing_state.pos_type
102
- self.location.orientation = self.mowing_state.toward / 10000
106
+ self.location.orientation = int(self.mowing_state.toward / 10000)
103
107
  self.location.device = coordinate_converter.enu_to_lla(
104
108
  parse_double(self.mowing_state.pos_y, 4.0), parse_double(self.mowing_state.pos_x, 4.0)
105
109
  )
@@ -113,3 +117,23 @@ class MowingDevice(DataClassORJSONMixin):
113
117
 
114
118
  def report_missing_data(self) -> None:
115
119
  """Report missing data so we can refetch it."""
120
+
121
+ def update_device_firmwares(self, fw_info: DeviceFwInfo) -> None:
122
+ """Sets firmware versions on all parts of the robot or RTK."""
123
+ for mod in fw_info.mod:
124
+ match mod.type:
125
+ case 1:
126
+ self.device_firmwares.main_controller = mod.version
127
+ case 3:
128
+ self.device_firmwares.left_motor_driver = mod.version
129
+ case 4:
130
+ self.device_firmwares.right_motor_driver = mod.version
131
+ case 5:
132
+ self.device_firmwares.rtk_rover_station = mod.version
133
+ case 101:
134
+ # RTK main board
135
+ self.device_firmwares.main_controller = mod.version
136
+ case 102:
137
+ self.device_firmwares.rtk_version = mod.version
138
+ case 103:
139
+ self.device_firmwares.lora_version = mod.version
@@ -23,3 +23,15 @@ class MowerInfo(DataClassORJSONMixin):
23
23
  swversion: str = ""
24
24
  product_key: str = ""
25
25
  model_id: str = ""
26
+
27
+ @dataclass
28
+ class DeviceFirmwares(DataClassORJSONMixin):
29
+ device_version: str = ""
30
+ left_motor_driver: str = ""
31
+ lora_version: str = ""
32
+ main_controller: str = ""
33
+ model_name: str = ""
34
+ right_motor_driver: str = ""
35
+ rtk_rover_station: str = ""
36
+ rtk_version: str = ""
37
+ version: str = ""
@@ -10,7 +10,7 @@ from pymammotion.data.model.device import MowingDevice
10
10
  from pymammotion.data.model.device_info import SideLight
11
11
  from pymammotion.data.model.hash_list import AreaHashNameList
12
12
  from pymammotion.data.mqtt.properties import ThingPropertiesMessage
13
- from pymammotion.proto.dev_net import WifiIotStatusReport
13
+ from pymammotion.proto.dev_net import WifiIotStatusReport, DrvDevInfoResp
14
14
  from pymammotion.proto.luba_msg import LubaMsg
15
15
  from pymammotion.proto.mctrl_nav import AppGetAllAreaHashName, NavGetCommDataAck, NavGetHashListAck, SvgMessageAckT
16
16
  from pymammotion.proto.mctrl_sys import DeviceProductTypeInfoT, TimeCtrlLight
@@ -121,6 +121,12 @@ class StateManager:
121
121
  case "toapp_wifi_iot_status":
122
122
  wifi_iot_status: WifiIotStatusReport = net_msg[1]
123
123
  self._device.mower_state.product_key = wifi_iot_status.productkey
124
+ case "toapp_devinfo_resp":
125
+ toapp_devinfo_resp: DrvDevInfoResp = net_msg[1]
126
+ for resp in toapp_devinfo_resp.resp_ids:
127
+ if resp.res is "DRV_RESULT_SUC":
128
+ self._device.mower_state.swversion = resp.info
129
+ self._device.device_firmwares.device_version = resp.info
124
130
 
125
131
  def _update_mul_data(self, message) -> None:
126
132
  pass
@@ -169,7 +169,7 @@ class Mammotion:
169
169
  self, ble_device: BLEDevice, preference: ConnectionPreference = ConnectionPreference.BLUETOOTH
170
170
  ) -> None:
171
171
  if ble_device:
172
- self.devices.add_device(
172
+ self.device_manager.add_device(
173
173
  MammotionMixedDeviceManager(name=ble_device.name, ble_device=ble_device, preference=preference)
174
174
  )
175
175
 
@@ -205,9 +205,9 @@ class Mammotion:
205
205
 
206
206
  def add_cloud_devices(self, mqtt_client: MammotionCloud) -> None:
207
207
  for device in mqtt_client.cloud_client.devices_by_account_response.data.data:
208
- mower_device = self.devices.get_device(device.deviceName)
208
+ mower_device = self.device_manager.get_device(device.deviceName)
209
209
  if device.deviceName.startswith(("Luba-", "Yuka-")) and mower_device is None:
210
- self.devices.add_device(
210
+ self.device_manager.add_device(
211
211
  MammotionMixedDeviceManager(
212
212
  name=device.deviceName,
213
213
  cloud_device=device,
@@ -222,7 +222,7 @@ class Mammotion:
222
222
  mower_device.replace_mqtt(mqtt_client)
223
223
 
224
224
  def set_disconnect_strategy(self, disconnect: bool) -> None:
225
- for device_name, device in self.devices.devices.items():
225
+ for device_name, device in self.device_manager.devices.items():
226
226
  if device.ble() is not None:
227
227
  ble_device: MammotionBaseBLEDevice = device.ble()
228
228
  ble_device.set_disconnect_strategy(disconnect)
@@ -249,10 +249,10 @@ class Mammotion:
249
249
  return cloud_client
250
250
 
251
251
  async def remove_device(self, name: str) -> None:
252
- await self.devices.remove_device(name)
252
+ await self.device_manager.remove_device(name)
253
253
 
254
254
  def get_device_by_name(self, name: str) -> MammotionMixedDeviceManager:
255
- return self.devices.get_device(name)
255
+ return self.device_manager.get_device(name)
256
256
 
257
257
  async def send_command(self, name: str, key: str):
258
258
  """Send a command to the device."""
@@ -0,0 +1,5 @@
1
+ """Package for linkkit."""
2
+
3
+ from .linkkit import LinkKit
4
+
5
+ __all__ = ["LinkKit"]