This repository has been archived by the owner on May 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'sc/matrix-protos' into dev
- Loading branch information
Showing
41 changed files
with
1,982 additions
and
1,961 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,8 @@ To exclude engine-io from the output, do | |
``` | ||
MATRIX_API_SERVER https://dev-api.admobilize.com | ||
MATRIX_STREAMING_SERVER http://dev-mxss.admobilize.com:80 | ||
MATRIX_NOMXSS - don't use streaming server | ||
NO_INSTALL - disable auto install from firebase for apps | ||
``` | ||
|
||
## Device Specific Server Configurations | ||
|
@@ -54,7 +56,7 @@ Run with `MATRIX_MODE=service` to have the system look for `apps` and `db` in `v | |
``` | ||
## Start your MATRIX OS with an installed App | ||
Please note that the application must be registered with the infrastructure to launch. Internet connectivity is only required on boot. | ||
Please note that the application must be registered with the infrastructure to launch. Internet connectivity is only required on boot. It can be disconnected, so long as an app doesn't use GRPC services or tries to save data. | ||
``` | ||
START_APP=monitor node index.js | ||
``` | ||
|
@@ -263,6 +265,13 @@ vim -nb or :nbs from inside vim | |
Be sure to deploy `test/fixtures/test.matrix` to the device you are going to use. You can run `matrix deploy` from inside the folder. We have to install the application vs manually copy it so there are firebase records created. | ||
``` | ||
cd test/fixtures/test.matrix/ | ||
matrix deploy | ||
cd ../../../ | ||
npm test | ||
``` | ||
## Maintainers | ||
Sean Canton <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
|
||
module.exports = { | ||
/** | ||
* Is this application configured for this event? | ||
* @param {string} ev - event name to test for | ||
* @return {Boolean} - is in the config | ||
*/ | ||
hasEvent: (ev) => { | ||
return ( matrix.config.hasOwnProperty('events') && | ||
matrix.config.events.indexOf(ev) > -1 ) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,15 @@ | ||
// Welcome to MatrixOS - A JavaScript environment for IoT Applications | ||
/** | ||
* MATRIX OS - is an orchestration system for IoT applications. It uses ZeroMQ and Protocol buffers to communicate with the hardware layer via MALOS/CORE | ||
* @see https://github.com/matrix-io/matrix-malos-lib MALOS + HAL is otherwise known as CORE | ||
* @see https://github.com/matrix-io/matrix-cli MATRIX CLI enables user configuration via command line | ||
* @see https://matrix-io.github.io/matrix-documentation/ System documentation | ||
* | ||
* We welcome feedback on github or via email. -> [email protected] | ||
*/ | ||
|
||
var optional = require('optional'); | ||
var bleno = optional('bleno'); | ||
// bluetooth lib, doesn't work on non bt platforms, so optional | ||
const bleno = optional('bleno'); | ||
|
||
const mosRepoURL = 'https://raw.githubusercontent.com/matrix-io/matrix-os/master/package.json'; | ||
// check gh | ||
|
@@ -21,30 +30,34 @@ var checks = { | |
}; | ||
|
||
/* GLOBALS */ | ||
require('colors'); | ||
_ = require('lodash'); | ||
async = require('async'); | ||
exec = require('child_process').exec; | ||
execSync = require('child_process').execSync; | ||
os = require('os'); | ||
|
||
require('colors'); | ||
|
||
var fs = require('fs'); | ||
|
||
warn = console.log; | ||
log = console.log; | ||
error = console.error; | ||
|
||
// local system vars | ||
var fs = require('fs'); | ||
|
||
// based on NODE_ENV, set sensible defaults | ||
var envSettings = getEnvSettings(); | ||
// if NODE_ENV=dev then set sane debug | ||
|
||
// if NODE_ENV=dev then set sane debug settings | ||
if (envSettings.debug === true && !_.has(process.env, 'DEBUG')) { | ||
process.env.DEBUG = '*,-engine*,-Component*,-*led*,-gatt,-bleno,-bt-characteristic,-hci'; | ||
// process.env.DEBUG = '*,-engine*'; | ||
} | ||
|
||
// system wide debug setup function | ||
debugLog = require('debug'); | ||
debug = debugLog('matrix'); | ||
|
||
// debug for this file | ||
const debug = debugLog('matrix'); | ||
|
||
// Core Library - Creates Matrix.device, Matrix.event, Matrix.service | ||
Matrix = require('./lib/index.js'); | ||
|
@@ -94,7 +107,6 @@ for (let i = 0; i < 24; i++) { | |
Matrix.dailyDPCount[i] = 0; | ||
} | ||
|
||
debug('', 'ENV:'.grey, Matrix.env.blue, 'API:'.grey, Matrix.apiServer.blue, 'MXSS:'.grey, Matrix.streamingServer.blue); | ||
debug('', 'ENV:'.grey, Matrix.env.blue, 'API:'.grey, Matrix.apiServer.blue, 'MXSS:'.grey, Matrix.streamingServer.blue); | ||
|
||
var events = require('events'); | ||
|
@@ -142,8 +154,9 @@ Matrix.api.makeUrls(Matrix.apiServer); | |
|
||
var malosInfoOut = ''; | ||
Matrix.device.malos.info(function (data) { | ||
// console.log(data); | ||
_.each(data.info, function (i) { | ||
malosInfoOut += ' ⚙ '.yellow + i.driver_name.blue + ':' + i.base_port + ' | ' + i.notes_for_human.grey + '\n'; | ||
malosInfoOut += ' ⚙ '.yellow + i.driverName.blue + ':' + i.basePort + ' | ' + i.notesForHuman.grey + '\n'; | ||
}); | ||
}); | ||
|
||
|
@@ -372,6 +385,7 @@ function onlineSetup(callback) { | |
// Lets login to the streaming server | ||
function mxssInit(cb) { | ||
|
||
// for debugging use MATRIX_NOMXSS env var to avoid MXSS . still needs internet tho. | ||
if (!process.env.hasOwnProperty('MATRIX_NOMXSS')) { | ||
Matrix.service.stream.initSocket(cb); | ||
} else { | ||
|
@@ -548,7 +562,7 @@ function onlineSetup(callback) { | |
}); | ||
}); | ||
|
||
//App install update | ||
//When application status changes on firebase, install on device | ||
Matrix.service.firebase.user.watchAppInstall(Matrix.deviceId, function (app, appId) { | ||
if (!_.isUndefined(app) && !_.isUndefined(appId)) { | ||
Matrix.localApps[appId] = app; | ||
|
@@ -562,6 +576,7 @@ function onlineSetup(callback) { | |
name: appName, | ||
version: app.meta.version || app.version, //TODO only use meta | ||
id: appId, | ||
// is this application running or not | ||
running: Matrix.activeApplications.some((a) => { | ||
return (a.name === appName); | ||
}) | ||
|
@@ -570,10 +585,7 @@ function onlineSetup(callback) { | |
debug('Trying to install: ' + appName.yellow); | ||
Matrix.service.manager.stop(appName, function (err, appStopped) { | ||
Matrix.service.manager.install(installOptions, function (err) { | ||
debug('Finished index install'); | ||
console.log(appName, installOptions.version, 'installed from', installOptions.url); | ||
//TODO Start the app if it was running before deployment? | ||
//if (appStopped) Matrix.service.manager.start(appName); | ||
}); | ||
}); | ||
}); | ||
|
@@ -582,6 +594,7 @@ function onlineSetup(callback) { | |
} | ||
}); | ||
|
||
// continue setup | ||
cb(); | ||
}, | ||
|
||
|
@@ -621,8 +634,8 @@ function onlineSetup(callback) { | |
else error('MXSS Unavailable'.red); | ||
|
||
// MALOS | ||
if (malosInfoOut.length > 0) log('MALOS COMPONENTS', malosInfoOut); | ||
else error('MALOS Unavailable'.red); | ||
if (malosInfoOut.length > 0) log('CORE COMPONENTS', malosInfoOut); | ||
else error('MALOS/CORE Unavailable'.red); | ||
|
||
// MOS | ||
log(Matrix.is.green.bold, '['.grey + Matrix.deviceId.grey + ']'.grey, 'ready'.yellow.bold); | ||
|
@@ -638,7 +651,7 @@ function onlineSetup(callback) { | |
console.log('MATRIX OS can be upgraded.'.yellow, Matrix.latestVersion, 'available!'.yellow, Matrix.version); | ||
} | ||
|
||
// CLI uses IPC for tests | ||
// CLI uses IPC for tests, will boot MOS with send method | ||
if (process.hasOwnProperty('send')) process.send({ 'matrix-ready': true }); | ||
|
||
if (process.env.hasOwnProperty('REPL')) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.