Skip to content

Commit

Permalink
Merge pull request #6 from stianaske/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
dshokouhi authored Dec 10, 2018
2 parents 3b6c36e + a785511 commit 2d0ec40
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions pybotvac/robot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,23 +66,23 @@ def start_cleaning(self, mode=2, navigation_mode=1, category=None):
# navigation_mode: 1 normal, 2 extra care, 3 deep
# category: 2 non-persistent map, 4 persistent map

#Default to using the persistent map if we support basic-3.
# Default to using the persistent map if we support basic-3 or basic-4.
if category is None:
category = 4 if self.service_version == 'basic-3' else 2
category = 4 if self.service_version in ['basic-3', 'basic-4'] else 2

if self.service_version == 'basic-1':
json = {'reqId': "1",
'cmd': "startCleaning",
'params': {
'category': 2,
'category': category,
'mode': mode,
'modifier': 1}
}
elif self.service_version == 'basic-3' or 'basic-4':
json = {'reqId': "1",
'cmd': "startCleaning",
'params': {
'category': 2,
'category': category,
'mode': mode,
'modifier': 1,
"navigationMode": navigation_mode}
Expand All @@ -91,20 +91,27 @@ def start_cleaning(self, mode=2, navigation_mode=1, category=None):
json = {'reqId': "1",
'cmd': "startCleaning",
'params': {
'category': 2,
'category': category,
"navigationMode": navigation_mode}
}
else: # self.service_version == 'basic-2'
json = {'reqId': "1",
'cmd': "startCleaning",
'params': {
'category': 2,
'category': category,
'mode': mode,
'modifier': 1,
"navigationMode": navigation_mode}
}

return self._message(json)
try:
return self._message(json)
except Exception:
# Todo: catch specific exception that is causing this
# Fall back to category 2 if we tried and failed with category 4
if category == 4:
json['params']['category'] = 2
return self._message(json)

def start_spot_cleaning(self, spot_width=400, spot_height=400):
# Spot cleaning if applicable to version
Expand Down

0 comments on commit 2d0ec40

Please sign in to comment.