Sensorium

Sensorium

Sensorium is the only namespace of this repository

Members

SUPPORT

Get supported mainboard

Example
let sopport = sensorium.SUPPORT;
conosole.log(sopport); // ['auriga', 'mcore', 'megapi', 'orion', 'megapipro', 'arduino']

Methods

create(mainboardName, opts)

Create a mainboard instance

Parameters:
Name Type Description
mainboardName String

both upperCase and lowerCase are allowed: 'mcore', 'mCore'

opts Object

(optional)

Example
// create a mcore with a given mainboardName
let mcore1 = sensorium.create('mcore');
let mcore2 = sensorium.create('mCore');
console.log(mcore1 === mcore2) // true

doReceived(buff)

Receive data from bluetooth、serialport、wifi

Parameters:
Name Type Description
buff Buffer | Array
Example
// supposed the `socket.io.js` have been used as the communication method
socket.on('received', function (data) {
  // the format of the data should be adjusted to fit the interface
  sensorium.doReceived(JSON.parse(data));
});

async read(buf)

Read protocol buffer
This interface is just for debug the protocol

Parameters:
Name Type Description
buf Array
Example
sensorium.send([0xff, 0x55, 0x01...]);

async readFirmwareInfo() → {Promise}

Read firmware info,which contains the version and the name.
Usually we use this interface to get the hardware information,
and decide to switch current device or update current hardware to the latest one.

Returns:
Promise -

a promise

Example
sensorium.readFirmwareInfo()
            .then(val => console.log(val));

send(buf)

Write protocol buffer.
This interface is just for debug the protocol

Parameters:
Name Type Description
buf Array
Example
sensorium.send([0xff, 0x55, 0x01...]);

setSender(sender)

Set the sender from bluetooth、serialport、wifi

Parameters:
Name Type Description
sender function

the send method

Example
// supposed the `socket.io.js` have been used as the communication method
let sender = (buf) => {
  socket.emit('send', { buf });
}
sensorium.setSender(sender);