Any valid mJS code is a valid ES6 code.
Any valid ES6 code is not necessarily a valid mJS code.
The mJS scripting environment has the following restrictions:
No standard library. No String, Number, RegExp, Date, Function, etc.
JSON.parse() and JSON.stringify() are available.
No closures, only lexical scoping (i.e. nested functions are allowed).
No new. In order to create an object with a custom prototype, use Object.create(), which is available.
Strict mode only.
No var, only let.
No for..of, =>, destructors, generators, proxies, promises.
No getters, setters, valueOf, prototypes, classes, template strings.
No == or !=, only === and !==.
mJS strings are byte strings, not Unicode strings: ‘ы’.length === 2, ‘ы’ === ‘xd1’, ‘ы’ === ‘x8b’. mJS string can represent any binary data chunk.
The scripting environment is a powerful tool. If incorrectly used the scripting functions may cause the device to malfunction, or even permanently brick the device.
The mJS scripting environment provides low level access to the device’s memory and CPU. Running a script on the device is not without risk, some of which include:
Permanent filesystem damage rendering the device unable to boot.
Malfunction of other functions, such as regular reporting of data to the portal.
Memory corruption, causing incorrect reporting of data.
Memory leaks, which may present intermittently or after a period of time.
Loss of remote control over the device, if your Portal account is compromised.
A good understanding of the environment, language and best practices will help avoid or mitigate these risks.
Scripts can be written and securely downloaded to the device from the Senquip Portal. There are several requirements for access scripting on your device:
You must have ADMIN status on the Portal for the device.
Your Portal account must be granted SCRIPTING permissions. This can be granted by making a request to firstname.lastname@example.org
Once the requirements are met, you can access the scripting page at: https://portal.senquip.com/script/DEVICEID