Skip to content
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

Added support for FW version 3 and Braava m6 #103

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ function cloud (username, password, version) {

function local (username, password, ip, version, interval) {
if (version === 1) return localV1(username, password, ip);
return localV2(username, password, ip, interval);
return localV2(username, password, ip, interval, version);
}

module.exports = {
Expand Down
36 changes: 30 additions & 6 deletions lib/v2/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,25 @@

const mqtt = require('mqtt');

var dorita980 = function localV2 (user, password, host, emitIntervalTime) {
var dorita980 = function localV2 (user, password, host, emitIntervalTime, version) {
if (!user) throw new Error('robotID is required.');
if (!password) throw new Error('password is required.');
if (!host) throw new Error('host is required.');

const posibleCap = ['pose', 'ota', 'multiPass', 'carpetBoost', 'pp', 'binFullDetect', 'langOta', 'maps', 'edge', 'eco', 'svcConf'];
const versionProps = {
2: ['audio', 'soundVer', 'cleanSchedule', 'uiSwVer', 'navSwVer', 'wifiSwVer', 'mobilityVer', 'bootloaderVer', 'umiVer'],
3: ['subModSwVer', 'cleanSchedule2']
};
const modelProps = {
'roomba': ['bin'],
'braava': ['detectedPad', 'mopReady', 'padWetness']
};
version = version || 2;
emitIntervalTime = emitIntervalTime || 800;
var robotState = {};
var cap = null;
var model = 'roomba';
var missionInterval;

const url = 'tls://' + host;
Expand Down Expand Up @@ -56,6 +66,9 @@ var dorita980 = function localV2 (user, password, host, emitIntervalTime) {
cap = {};
cap = Object.assign(cap, robotState.cap);
}
if (robotState.sku && robotState.sku.toLowerCase().startsWith('m6')) {
model = 'braava';
}
} catch (e) {}
}
});
Expand All @@ -81,6 +94,16 @@ var dorita980 = function localV2 (user, password, host, emitIntervalTime) {
if (posibleCap.indexOf(properties[p]) > -1 && cap && Object.keys(cap).indexOf(properties[p]) === -1) {
obj[properties[p]] = undefined; // asking for a non available capability, just set to undefined
}
for (var ver in versionProps) {
if (ver !== version && versionProps[ver].indexOf(properties[p]) > -1) {
obj[properties[p]] = undefined; // this is a property for a different version of API
}
}
for (var mod in modelProps) {
if (mod !== model && modelProps[mod].indexOf(properties[p]) > -1) {
obj[properties[p]] = undefined; // this is a property for a different model
}
}
if (!obj.hasOwnProperty(properties[p])) {
return false;
}
Expand Down Expand Up @@ -113,15 +136,16 @@ var dorita980 = function localV2 (user, password, host, emitIntervalTime) {
getTime: () => waitPreferences(false, ['utctime'], true),
getBbrun: () => waitPreferences(false, ['bbrun'], true),
getLangs: () => waitPreferences(false, ['langs'], true),
getSys: () => waitPreferences(false, ['bbrstinfo', 'cap', 'sku', 'batteryType', 'soundVer', 'uiSwVer', 'navSwVer', 'wifiSwVer', 'mobilityVer', 'bootloaderVer', 'umiVer', 'softwareVer', 'audio', 'bin'], true),
getSys: () => waitPreferences(false, ['bbrstinfo', 'cap', 'sku', 'batteryType', 'soundVer', 'uiSwVer', 'navSwVer', 'wifiSwVer', 'mobilityVer', 'bootloaderVer', 'umiVer', 'softwareVer', 'audio', 'bin', 'subModSwVer', 'secureBoot', 'detectedPad'], true),
getWirelessLastStatus: () => waitPreferences(false, ['wifistat', 'wlcfg'], true),
getWeek: () => waitPreferences(false, ['cleanSchedule'], true),
getPreferences: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'cleanSchedule', 'name', 'vacHigh', 'signal'], false),
getWeek: () => waitPreferences(false, ['cleanSchedule', 'cleanSchedule2'], true),
getPreferences: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'cleanSchedule', 'cleanSchedule2', 'name', 'vacHigh', 'signal'], false),
getRobotState: (fields) => waitPreferences(false, fields, false),
getMission: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'pose', 'bin', 'batPct'], true),
getBasicMission: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'bin', 'batPct'], true),
getMission: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'pose', 'bin', 'batPct', 'detectedPad', 'mopReady', 'padWetness'], true),
getBasicMission: (decode) => waitPreferences(decode, ['cleanMissionStatus', 'bin', 'batPct', 'detectedPad', 'mopReady', 'padWetness'], true),
getWirelessConfig: () => waitPreferences(false, ['wlcfg', 'netinfo'], true),
getWirelessStatus: () => waitPreferences(false, ['wifistat', 'netinfo'], true),
getModel: () => new Promise((resolve) => resolve(model)),
getCloudConfig: () => waitPreferences(false, ['cloudEnv'], true),
getSKU: () => waitPreferences(false, ['sku'], true),
start: () => _apiCall('cmd', 'start'),
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dorita980",
"version": "3.1.7",
"version": "3.2.0",
"description": "Unofficial iRobot Roomba 980 and wifi other enabled series library sdk",
"main": "./index.js",
"directories": {
Expand Down Expand Up @@ -39,13 +39,15 @@
"unofficial",
"iRobot",
"Roomba",
"Braava",
"980",
"wifi",
"i7",
"e5",
"960",
"690",
"675",
"m6",
"library",
"sdk",
"robot",
Expand Down