Lots of work done.
47
.gitignore
vendored
@ -181,3 +181,50 @@ dist
|
||||
www/libs
|
||||
/www/
|
||||
/app/libs/
|
||||
### Android template
|
||||
# Built application files
|
||||
*.apk
|
||||
*.ap_
|
||||
|
||||
# Files for the ART/Dalvik VM
|
||||
*.dex
|
||||
|
||||
# Java class files
|
||||
*.class
|
||||
|
||||
# Generated files
|
||||
bin/
|
||||
gen/
|
||||
out/
|
||||
|
||||
# Gradle files
|
||||
.gradle/
|
||||
build/
|
||||
|
||||
# Local configuration file (sdk path, etc)
|
||||
local.properties
|
||||
|
||||
# Proguard folder generated by Eclipse
|
||||
proguard/
|
||||
|
||||
# Log Files
|
||||
*.log
|
||||
|
||||
# Android Studio Navigation editor temp files
|
||||
.navigation/
|
||||
|
||||
# Android Studio captures folder
|
||||
captures/
|
||||
|
||||
# Intellij
|
||||
*.iml
|
||||
.idea/workspace.xml
|
||||
|
||||
# Keystore files
|
||||
*.jks
|
||||
### Dropbox template
|
||||
# Dropbox settings and caches
|
||||
.dropbox
|
||||
.dropbox.attr
|
||||
.dropbox.cache
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
@import "www/libs/mui/src/sass/mui/colors";
|
||||
@import "app/libs/mui/src/sass/mui/colors";
|
||||
|
||||
|
||||
$mui-body-bg-color: mui-color('grey', '100');
|
||||
@ -12,4 +12,4 @@ $mui-tab-font-color: rgba(255, 255, 255, 0.87);
|
||||
$mui-appbar-bg-color: #004c6d;
|
||||
|
||||
// import MUI SASS
|
||||
@import "www/libs/mui/src/sass/mui";
|
||||
@import "app/libs/mui/src/sass/mui";
|
@ -33,20 +33,18 @@
|
||||
<meta name="msapplication-tap-highlight" content="no">
|
||||
<meta name="viewport"
|
||||
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
||||
<link rel="stylesheet"
|
||||
href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700"
|
||||
type="text/css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Ubuntu+Condensed'
|
||||
rel='stylesheet' type='text/css'>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
rel="stylesheet">
|
||||
<!-- build:fonts -->
|
||||
<link rel="stylesheet" href="fonts/fonts.css">
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:mui -->
|
||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||
<!-- endbuild -->
|
||||
<!-- build:css -->
|
||||
<link rel="stylesheet" href="fonts/fonts.css">
|
||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/app.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/ripple.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/progress.css" rel="stylesheet" type="text/css"/>
|
||||
<!-- endbuild -->
|
||||
<title>Sensor Toy</title>
|
||||
</head>
|
||||
<body class="mui--no-user-select">
|
||||
@ -56,10 +54,6 @@
|
||||
<li class="mui--is-active"><a data-mui-toggle="tab"
|
||||
data-mui-controls="pane-default-1">Devices</a>
|
||||
</li>
|
||||
<!--<li><a data-mui-toggle="tab" data-mui-controls="pane-default-2">Tab-2</a>
|
||||
</li>
|
||||
<li><a data-mui-toggle="tab" data-mui-controls="pane-default-3">Tab-3</a>
|
||||
</li>-->
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
@ -94,16 +88,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="cordova.js"></script>
|
||||
|
||||
<!-- build:vendor -->
|
||||
<script type="text/javascript" src="libs/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="libs/mui/packages/cdn/js/mui.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="libs/bluebird/js/browser/bluebird.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:standards -->
|
||||
<script type="text/javascript"
|
||||
src="js/standards/bluetooth_company_identifiers.js"></script>
|
||||
<script type="text/javascript" src="js/standards/capability.js"></script>
|
||||
<script type="text/javascript" src="js/standards/battery.js"></script>
|
||||
<script type="text/javascript" src="js/standards/button.js"></script>
|
||||
<script type="text/javascript" src="js/mandecoder.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:cc2650 -->
|
||||
<script type="text/javascript"
|
||||
src="js/device/CC2650/cc2650_accelerometer.js"></script>
|
||||
<script type="text/javascript"
|
||||
@ -114,6 +116,10 @@
|
||||
src="js/device/CC2650/cc2650_thermopile.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="js/device/CC2650/cc2650_humidity.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:js -->
|
||||
<script type="text/javascript" src="js/index.js"></script>
|
||||
<!-- endbuild -->
|
||||
</body>
|
||||
</html>
|
||||
|
@ -9,7 +9,8 @@
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
var CC2650_ACCEL = function(p) {
|
||||
var CC2650_ACCEL;
|
||||
CC2650_ACCEL = function(p) {
|
||||
'use strict';
|
||||
this.name = 'Accelerometer';
|
||||
this.deviceID = p.deviceID || null;
|
||||
@ -17,155 +18,386 @@ var CC2650_ACCEL = function(p) {
|
||||
|
||||
this.capabilityID = 'F000AA80-0451-4000-B000-000000000000';
|
||||
this.serviceDef = {
|
||||
service: 'F000AA80-0451-4000-B000-000000000000',
|
||||
data: 'F000AA81-0451-4000-B000-000000000000', // Read/notify 3 bytes X : Y : Z
|
||||
notification: 'F0002902-0451-4000-B000-000000000000',
|
||||
configuration: 'F000AA82-0451-4000-B000-000000000000', // Read/write 1 byte
|
||||
period: 'F000AA83-0451-4000-B000-000000000000' // Read/write 1 byte Period = [Input*10]ms
|
||||
};
|
||||
service: 'F000AA80-0451-4000-B000-000000000000',
|
||||
data: 'F000AA81-0451-4000-B000-000000000000', // Read/notify 3 bytes X : Y : Z
|
||||
notification: 'F0002902-0451-4000-B000-000000000000',
|
||||
configuration: 'F000AA82-0451-4000-B000-000000000000', // Read/write 1 byte
|
||||
period: 'F000AA83-0451-4000-B000-000000000000' // Read/write 1 byte Period = [Input*10]ms
|
||||
};
|
||||
this.frames = {};
|
||||
|
||||
this.$id = {};
|
||||
this.$result = {};
|
||||
this.data = {
|
||||
gyro: {x: [], y: [], z: []},
|
||||
accel: {x: [], y: [], z: []},
|
||||
mag: {x: [], y: [], z: []}
|
||||
};
|
||||
|
||||
this.setFrame();
|
||||
|
||||
this.sensorMpu9250GyroConvert = function(data) {
|
||||
return data / (65536 / 500);
|
||||
};
|
||||
return (data * 1.0) / (65536 / 500);
|
||||
};
|
||||
|
||||
this.sensorMpu9250AccConvert = function(data) {
|
||||
// Change /2 to match accel range...i.e. 16 g would be /16
|
||||
return data / (32768 / 2);
|
||||
// Change /2 to match accel range...i.e. 16 g would be /16
|
||||
return (data * 1.0) / (32768 / 2);
|
||||
};
|
||||
|
||||
this.processData = function(data) {
|
||||
var a = new Int16Array(data);
|
||||
var calcData = {
|
||||
gyro: {
|
||||
x: this.sensorMpu9250GyroConvert(a[0]),
|
||||
y: this.sensorMpu9250GyroConvert(a[1]),
|
||||
z: this.sensorMpu9250GyroConvert(a[2])
|
||||
}, accel: {
|
||||
x: this.sensorMpu9250AccConvert(a[3]),
|
||||
y: this.sensorMpu9250AccConvert(a[4]),
|
||||
z: this.sensorMpu9250AccConvert(a[5])
|
||||
}, mag: {
|
||||
x: a[6], y: a[7], z: a[8]
|
||||
}
|
||||
};
|
||||
|
||||
return calcData;
|
||||
};
|
||||
this.onAccelerometerData = function(data) {
|
||||
// Console.log(data);
|
||||
var message;
|
||||
var a = new Int16Array(data);
|
||||
// Console.log(data);
|
||||
var message;
|
||||
var calcData;
|
||||
|
||||
// 0 gyro x
|
||||
// 1 gyro y
|
||||
// 2 gyro z
|
||||
// 3 accel x
|
||||
// 4 accel y
|
||||
// 5 accel z
|
||||
// 6 mag x
|
||||
// 7 mag y
|
||||
// 8 mag z
|
||||
function gString(v) {
|
||||
return [v.toFixed(3),'G'].join('');
|
||||
}
|
||||
|
||||
// TODO get a template to line this up
|
||||
// TODO round or format numbers for better display
|
||||
message = 'Gyro <br/>' +
|
||||
'X: ' + this.sensorMpu9250GyroConvert(a[0]).toFixed(5) + '<br/>' +
|
||||
'Y: ' + this.sensorMpu9250GyroConvert(a[1]) + '<br/>' +
|
||||
'Z: ' + this.sensorMpu9250GyroConvert(a[2]) + '<br/>' +
|
||||
'Accel <br/>' +
|
||||
'X: ' + this.sensorMpu9250AccConvert(a[3]) + '<br/>' +
|
||||
'Y: ' + this.sensorMpu9250AccConvert(a[4]) + '<br/>' +
|
||||
'Z: ' + this.sensorMpu9250AccConvert(a[5]) + '<br/>' +
|
||||
'Mag <br/>' +
|
||||
'X: ' + a[3] + '<br/>' +
|
||||
'Y: ' + a[4] + '<br/>' +
|
||||
'Z: ' + a[5] + '<br/>' ;
|
||||
function aString(v) {
|
||||
return [v.toFixed(3),'\'/s'].join('');
|
||||
}
|
||||
|
||||
this.state = message;
|
||||
function mString(v) {
|
||||
return [v.toFixed(3),'mT'].join('');
|
||||
}
|
||||
calcData = this.processData(data);
|
||||
|
||||
this.$result[this.frames.gyroID + '-x'].text(this.sensorMpu9250GyroConvert(a[0]).toFixed(5));
|
||||
this.$result[this.frames.gyroID + '-y'].text(this.sensorMpu9250GyroConvert(a[1]).toFixed(5));
|
||||
this.$result[this.frames.gyroID + '-z'].text(this.sensorMpu9250GyroConvert(a[2]).toFixed(5));
|
||||
message = 'Gyro <br/>' + 'X: ' + calcData.gyro.x + '<br/>' + 'Y: ' + calcData.gyro.y + '<br/>' + 'Z: ' + calcData.gyro.z + '<br/>' + 'Accel <br/>' + 'X: ' + calcData.accel.x + '<br/>' + 'Y: ' + calcData.accel.y + '<br/>' + 'Z: ' + calcData.accel.z + '<br/>' + 'Mag <br/>' + 'X: ' + calcData.mag.x + '<br/>' + 'Y: ' + calcData.mag.y + '<br/>' + 'Z: ' + calcData.mag.z + '<br/>';
|
||||
|
||||
this.$result[this.frames.accelID + '-x'].text(this.sensorMpu9250AccConvert(a[3]).toFixed(5));
|
||||
this.$result[this.frames.accelID + '-y'].text(this.sensorMpu9250AccConvert(a[4]).toFixed(5));
|
||||
this.$result[this.frames.accelID + '-z'].text(this.sensorMpu9250AccConvert(a[5]).toFixed(5));
|
||||
this.state = message;
|
||||
|
||||
this.$result[this.frames.magID + '-x'].text(a[3]);
|
||||
this.$result[this.frames.magID + '-y'].text(a[4]);
|
||||
this.$result[this.frames.magID + '-z'].text(a[5]);
|
||||
this.$result[this.frames.gyroID + '-x'].text(gString(calcData.gyro.x));
|
||||
this.$result[this.frames.gyroID + '-y'].text(gString(calcData.gyro.y));
|
||||
this.$result[this.frames.gyroID + '-z'].text(gString(calcData.gyro.z));
|
||||
|
||||
// Console.log(this.state);
|
||||
};
|
||||
this.$result[this.frames.accelID + '-x'].text(aString(calcData.accel.x));
|
||||
this.$result[this.frames.accelID + '-y'].text(aString(calcData.accel.y));
|
||||
this.$result[this.frames.accelID + '-z'].text(aString(calcData.accel.z));
|
||||
|
||||
this.$result[this.frames.magID + '-x'].text(mString(calcData.mag.x));
|
||||
this.$result[this.frames.magID + '-y'].text(mString(calcData.mag.y));
|
||||
this.$result[this.frames.magID + '-z'].text(mString(calcData.mag.z));
|
||||
|
||||
this.data.gyro.x = this.storeData(calcData.gyro.x, this.data.gyro.x);
|
||||
this.data.gyro.y = this.storeData(calcData.gyro.y, this.data.gyro.y);
|
||||
this.data.gyro.z = this.storeData(calcData.gyro.z, this.data.gyro.z);
|
||||
|
||||
this.data.accel.x = this.storeData(calcData.accel.x, this.data.accel.x);
|
||||
this.data.accel.y = this.storeData(calcData.accel.y, this.data.accel.y);
|
||||
this.data.accel.z = this.storeData(calcData.accel.z, this.data.accel.z);
|
||||
|
||||
this.data.mag.x = this.storeData(calcData.mag.x, this.data.mag.x);
|
||||
this.data.mag.y = this.storeData(calcData.mag.y, this.data.mag.y);
|
||||
this.data.mag.z = this.storeData(calcData.mag.z, this.data.mag.z);
|
||||
|
||||
// Console.log(JSON.stringify(this.data));
|
||||
// Console.log(this.state);
|
||||
};
|
||||
|
||||
this.startService = function() {
|
||||
|
||||
if (this.deviceID !== null) {
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
||||
console.log(this.serviceDef);
|
||||
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
||||
console.log(this.serviceDef);
|
||||
|
||||
ble.startNotification(this.deviceID, this.serviceDef.service, this.serviceDef.data, this.onAccelerometerData.bind(this), this.onError);
|
||||
this.setInternalID();
|
||||
this.insertFrame('gyro');
|
||||
this.insertFrame('accel');
|
||||
this.insertFrame('mag');
|
||||
|
||||
// Turn accelerometer on
|
||||
var configData = new Uint16Array(1);
|
||||
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
||||
configData[0] = 0x007F;
|
||||
ble.write(this.deviceID, this.serviceDef.service, this.serviceDef.configuration, configData.buffer,
|
||||
function() { console.log('Started accelerometer.'); }, this.onError);
|
||||
ble.startNotification(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.data,
|
||||
this.onAccelerometerData.bind(this),
|
||||
this.onError);
|
||||
|
||||
var periodData = new Uint8Array(1);
|
||||
periodData[0] = 0x0A;
|
||||
// Ble.write(deviceId, accelerometer.service, accelerometer.period, periodData.buffer,
|
||||
// function() { console.log("Configured accelerometer period."); },app.onError);
|
||||
// Turn accelerometer on
|
||||
var configData = new Uint16Array(1);
|
||||
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
||||
configData[0] = 0x007F;
|
||||
ble.write(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.configuration,
|
||||
configData.buffer,
|
||||
function() { console.log('Started accelerometer.'); },
|
||||
this.onError);
|
||||
|
||||
var periodData = new Uint8Array(1);
|
||||
periodData[0] = 0x0A;
|
||||
ble.write(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.period,
|
||||
periodData.buffer,
|
||||
function() { console.log('Configured accelerometer period.'); },
|
||||
this.onError);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.advancedGraph = function(mode, data, subID) {
|
||||
|
||||
var lm;
|
||||
var ceiling;
|
||||
var elm;
|
||||
var text2ID;
|
||||
var ceilingLimit;
|
||||
var calcArray;
|
||||
var floor;
|
||||
var _subID;
|
||||
var _data;
|
||||
var text1ID;
|
||||
var lineID;
|
||||
var max;
|
||||
|
||||
|
||||
var parts = ['x', 'y', 'z'];
|
||||
|
||||
_data = data || this.data;
|
||||
|
||||
_subID = subID || '';
|
||||
|
||||
// LineID = [this.frameID , _subID , '-line'].join('');
|
||||
text1ID = [this.frameID, _subID, '-txt1'].join('');
|
||||
text2ID = [this.frameID, _subID, '-txt2'].join('');
|
||||
|
||||
if (_data.x.length > 0) {
|
||||
|
||||
max = 2;
|
||||
|
||||
for (var lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||
lm = parts[lineMode];
|
||||
ceiling = _data[lm].reduce(function(p, v) {
|
||||
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||
});
|
||||
|
||||
|
||||
if (ceiling > 500) {
|
||||
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 50) * 50) : max;
|
||||
} else {
|
||||
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 10) * 10) : max;
|
||||
}
|
||||
}
|
||||
|
||||
ceiling = max;
|
||||
|
||||
floor = ceiling * -1;
|
||||
ceilingLimit = ceiling;
|
||||
|
||||
var scalePos = (124 / 2) / ceiling;
|
||||
var scaleNeg = (124 / 2) / floor;
|
||||
var xstep = (680 - 46) / 100;
|
||||
|
||||
//Var xstep = 2.34;
|
||||
|
||||
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||
|
||||
lm = parts[lineMode];
|
||||
var startX = 46 + (100 - _data[lm].length) * xstep;
|
||||
|
||||
calcArray = [];
|
||||
|
||||
lineID = this.frameID + _subID + '-' + lm + '-line';
|
||||
for (var x = 0; x < _data[lm].length; x++) {
|
||||
|
||||
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (71 - ((_data[lm][x]) * scalePos)).toFixed(
|
||||
2));
|
||||
|
||||
}
|
||||
|
||||
elm = document.getElementById(lineID);
|
||||
|
||||
elm.setAttribute('points', calcArray.join(' '));
|
||||
|
||||
}
|
||||
|
||||
elm = document.getElementById(text1ID);
|
||||
elm.textContent = ceilingLimit;
|
||||
|
||||
elm = document.getElementById(text2ID);
|
||||
elm.textContent = floor;
|
||||
|
||||
this.setInternalID();
|
||||
this.insertFrame('gyro');
|
||||
this.insertFrame('accel');
|
||||
this.insertFrame('mag');
|
||||
}
|
||||
|
||||
this.previousCeil = ceiling;
|
||||
};
|
||||
|
||||
this.animateGraph = function() {
|
||||
// Nothing to animate yet
|
||||
// Nothing to animate yet
|
||||
|
||||
return -1;
|
||||
};
|
||||
// return -1;
|
||||
this.advancedGraph(0, this.data.gyro, 'gyro');
|
||||
this.advancedGraph(0, this.data.accel, 'accel');
|
||||
this.advancedGraph(0, this.data.mag, 'mag');
|
||||
// This.simpleGraph(this.data.temp, 'temp');
|
||||
// this.simpleGraph(this.data.pressure, 'pressure');
|
||||
|
||||
};
|
||||
|
||||
this.generateBlankGraphBase = function(subID, settings) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
|
||||
var svgID = this.frameID + _subID + '-svg';
|
||||
var text1ID = this.frameID + _subID + '-txt1';
|
||||
var text2ID = this.frameID + _subID + '-txt2';
|
||||
|
||||
var _width = settings.width || 300;
|
||||
var _height = settings.height || 150;
|
||||
var _fill = settings.fill || 'blue';
|
||||
|
||||
var svg = document.createElementNS(xmlns, 'svg');
|
||||
|
||||
svg.setAttribute('id', svgID);
|
||||
// Svg.setAttribute(xmlns, 'version', '1.1');
|
||||
svg.setAttribute('width', _width.toString());
|
||||
svg.setAttribute('height', _height.toString());
|
||||
svg.setAttribute('fill', _fill);
|
||||
|
||||
|
||||
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
|
||||
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
|
||||
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
|
||||
|
||||
|
||||
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
|
||||
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
|
||||
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
this.generateBlankGraph = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xlineID = this.frameID + _subID + '-x-line';
|
||||
var ylineID = this.frameID + _subID + '-y-line';
|
||||
var zlineID = this.frameID + _subID + '-z-line';
|
||||
|
||||
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
|
||||
|
||||
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
||||
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
||||
svg = this.graphAddLine(svg, zlineID, 'rgba(0,0,255,0.5)');
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
this.startCalibrate = function() {
|
||||
console.log('Start calibrate');
|
||||
|
||||
alert('Mag Calibration: Wave device in a figure eight until done!');
|
||||
};
|
||||
|
||||
this.insertFrame = function(mode) {
|
||||
|
||||
var frame;
|
||||
var title;
|
||||
var modeID = mode + 'ID';
|
||||
this.frames[modeID] = this.frameID + '-' + mode;
|
||||
var frame;
|
||||
var title;
|
||||
var modeID = mode + 'ID';
|
||||
this.frames[modeID] = this.frameID + '-' + mode;
|
||||
|
||||
var titles = {gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'};
|
||||
|
||||
console.log('FrameID: ' , this.frames[modeID]);
|
||||
|
||||
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
||||
|
||||
frame = $('<div />', {
|
||||
class: 'mui-panel', id: this.frames[modeID]
|
||||
});
|
||||
|
||||
$('<div />', { class: 'mui-row'}).append($('<div />', { class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title})).appendTo(frame);
|
||||
|
||||
this.$frame.append(frame);
|
||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||
|
||||
// Call the parent displayForm first...
|
||||
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'X'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Y'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Z'}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-x' }).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-y'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-z'}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
this.$result[this.frames[modeID] + '-x'] = $('#' + this.frames[modeID] + '-x');
|
||||
this.$result[this.frames[modeID] + '-y'] = $('#' + this.frames[modeID] + '-y');
|
||||
this.$result[this.frames[modeID] + '-z'] = $('#' + this.frames[modeID] + '-z');
|
||||
var titles = {
|
||||
gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'
|
||||
};
|
||||
var modes = ['gyro', 'accel', 'mag'];
|
||||
|
||||
console.log('FrameID: ', this.frames[modeID]);
|
||||
|
||||
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
||||
|
||||
frame = $('<div />', {
|
||||
class: 'mui-panel', id: this.frames[modeID]
|
||||
});
|
||||
|
||||
if (mode === 'mag') {
|
||||
var elm = $('<div />', {class: 'mui-row'});
|
||||
var button = $('<button />',{class: 'mui-btn mui-btn--raised', id: modeID + '-cal', text: 'Calibrate', click: this.startCalibrate.bind(this)});
|
||||
|
||||
elm.append($('<div />', { class: 'mui-col-xs-8 mui--text-title mui-ellipsis-2', text: title}));
|
||||
|
||||
// elm.append($('<div />', {class: 'mui-col-xs-4 mui--text-right'}).append(button));
|
||||
|
||||
frame.append(elm);
|
||||
|
||||
} else {
|
||||
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
||||
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
||||
})).appendTo(frame);
|
||||
|
||||
}
|
||||
this.$frame.append(frame);
|
||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||
|
||||
// Call the parent displayForm first...
|
||||
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'X'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Y'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Z'
|
||||
}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-x'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-y'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-z'
|
||||
}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
this.$result[this.frames[modeID] + '-x'] = $('#' + this.frames[modeID] + '-x');
|
||||
this.$result[this.frames[modeID] + '-y'] = $('#' + this.frames[modeID] + '-y');
|
||||
this.$result[this.frames[modeID] + '-z'] = $('#' + this.frames[modeID] + '-z');
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
var _graph = this.generateBlankGraph(mode);
|
||||
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -101,29 +101,56 @@ var CC2650_BAR = function(p) {
|
||||
var pressure = this.frameID + '-p';
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Pressure:'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Pressure:'}).appendTo(row);
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: pressure}).appendTo(row);
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{text: 'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>',{class: 'tabOnWhite'}).append($('<a>',{text: 'Pressure','data-mui-toggle': 'tab', 'data-mui-controls': (pressure + '-pane')})).appendTo(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
this.$id.append(tabBody);
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('pressure'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
} else {
|
||||
|
||||
blankChart = this.generateBlankGraph('pressure');
|
||||
var tabBody = $('<ul>',
|
||||
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Pressure',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (pressure + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (pressure + '-pane')}).append(blankChart));
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
|
||||
blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('pressure');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{
|
||||
class: 'mui-tabs__pane',
|
||||
id: (pressure + '-pane')
|
||||
}).append(blankChart));
|
||||
}
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.pressure = $('#' + pressure);
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -105,13 +105,13 @@ var CC2650_HUM = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
$('<div />',
|
||||
{
|
||||
class: 'mui-col-xs-3 mui--text-accent',
|
||||
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
|
||||
text: 'Humidity:'
|
||||
}).appendTo(row);
|
||||
|
||||
@ -120,18 +120,44 @@ var CC2650_HUM = function(p) {
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{text: 'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>',{class: 'tabOnWhite'}).append($('<a>',{text: 'Humidity','data-mui-toggle': 'tab', 'data-mui-controls': (humidity + '-pane')})).appendTo(tabBody);
|
||||
this.$id.append(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('humidity'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('humidity');
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (humidity + '-pane')}).append(blankChart));
|
||||
} else {
|
||||
var tabBody = $('<ul>',
|
||||
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Humidity',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (humidity + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
|
||||
blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('humidity');
|
||||
this.$id.append($('<div>',
|
||||
{
|
||||
class: 'mui-tabs__pane',
|
||||
id: (humidity + '-pane')
|
||||
}).append(blankChart));
|
||||
}
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.humidity = $('#' + humidity);
|
||||
|
||||
|
@ -91,7 +91,7 @@ var CC2650_LUX = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-4 mui--text-accent', text: 'Luminosity:'}).appendTo(
|
||||
{class: 'mui-col-xs-4 mui--text-accent mui--text-right', text: 'Luminosity:'}).appendTo(
|
||||
row);
|
||||
|
||||
$('<div />',
|
||||
|
@ -91,10 +91,10 @@ var CC2650_TMP = function(p) {
|
||||
this.simpleGraph(this.data.ambient, 'ambient');
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.insertFrame = function() {
|
||||
|
||||
var liSetting;
|
||||
var tabBody;
|
||||
var blankChart;
|
||||
var self = this;
|
||||
// Console.log('Overloading...');
|
||||
@ -107,13 +107,13 @@ var CC2650_TMP = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-dark mui--text-left', id: temp}).appendTo(row);
|
||||
$('<div />',
|
||||
{
|
||||
class: 'mui-col-xs-3 mui--text-accent',
|
||||
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
|
||||
text: 'Ambient:'
|
||||
}).appendTo(row);
|
||||
|
||||
@ -122,19 +122,38 @@ var CC2650_TMP = function(p) {
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{ text: 'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',{ text: 'Ambient','data-mui-toggle': 'tab', 'data-mui-controls': (amb + '-pane')})).appendTo(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
this.$id.append(tabBody);
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('ambient'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
} else {
|
||||
tabBody = $('<ul>', {class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
liSetting = {
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
};
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',liSetting)).appendTo(tabBody);
|
||||
liSetting = { text: 'Ambient','data-mui-toggle': 'tab', 'data-mui-controls': (amb + '-pane')};
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',liSetting)).appendTo(tabBody);
|
||||
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('ambient');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (amb + '-pane')}).append(blankChart));
|
||||
}
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('ambient');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (amb + '-pane')}).append(blankChart));
|
||||
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.ambient = $('#' + amb);
|
||||
|
514
app/js/index.js
@ -19,36 +19,37 @@
|
||||
|
||||
/* global mui, bt_company_ids, ble, LocalFileSystem, capabilityManager, MANUFACTUREDECODER */
|
||||
|
||||
var app = {
|
||||
stop: false,
|
||||
log: {},
|
||||
activeServices: {},
|
||||
var app;
|
||||
app = {
|
||||
mode: 0, stop: false, log: {}, activeServices: {},
|
||||
|
||||
list: {},
|
||||
foundDevices: {},
|
||||
list: {}, foundDevices: {},
|
||||
|
||||
manufactureDecoder: new MANUFACTUREDECODER(),
|
||||
// Application Constructor
|
||||
manufactureDecoder: new MANUFACTUREDECODER(), // Application Constructor
|
||||
initialize: function() {
|
||||
this.bindEvents();
|
||||
},
|
||||
|
||||
arrayBufferToIntArray: function(buffer) {
|
||||
var result;
|
||||
var result;
|
||||
|
||||
if (buffer) {
|
||||
var typedArray = new Uint8Array(buffer);
|
||||
result = [];
|
||||
for (var i = 0; i < typedArray.length; i++) {
|
||||
result[i] = typedArray[i];
|
||||
}
|
||||
if (buffer) {
|
||||
var typedArray = new Uint8Array(buffer);
|
||||
result = [];
|
||||
for (var i = 0; i < typedArray.length; i++) {
|
||||
result[i] = typedArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
return result;
|
||||
},
|
||||
|
||||
parseAdvertisingData: function(bytes) {
|
||||
var length, type, data, i = 0, advertisementData = {};
|
||||
var length;
|
||||
var type;
|
||||
var data;
|
||||
var i = 0;
|
||||
var advertisementData = {};
|
||||
|
||||
while (length !== 0) {
|
||||
|
||||
@ -66,8 +67,7 @@ var app = {
|
||||
}
|
||||
|
||||
return advertisementData;
|
||||
},
|
||||
handle255: function(buffer) {
|
||||
}, handle255: function(buffer) {
|
||||
'use strict';
|
||||
|
||||
var company;
|
||||
@ -77,14 +77,6 @@ var app = {
|
||||
var decoded = {};
|
||||
|
||||
console.log('Block255', bin);
|
||||
/*
|
||||
var manSpec = bin.map(function(i) {
|
||||
|
||||
return i.toString(16) + ' ';
|
||||
});
|
||||
|
||||
console.log('manSpec: ', manSpec);
|
||||
*/
|
||||
manID = app.manufactureDecoder.getManID(bin);
|
||||
|
||||
console.log('ManID:', manID);
|
||||
@ -94,7 +86,7 @@ var app = {
|
||||
company = bt_company_ids.find(cid);
|
||||
|
||||
switch (manID) {
|
||||
case '004c': {
|
||||
case '004C': {
|
||||
decoded = app.manufactureDecoder.decodeIbeacon(bin);
|
||||
decoded.company = company;
|
||||
break;
|
||||
@ -118,60 +110,97 @@ var app = {
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
},
|
||||
makeHexBuffer: function(buffer) {
|
||||
}, makeHexBuffer: function(buffer) {
|
||||
'use strict';
|
||||
var hexBuffer = buffer.map(function(i) {
|
||||
return ('00' + i.toString(16)).slice(-2) + ',';
|
||||
});
|
||||
return hexBuffer;
|
||||
},
|
||||
makeChars: function(buffer) {
|
||||
return buffer.map(function(i) {
|
||||
return ('00' + i.toString(16)).slice(-2) + ',';
|
||||
});
|
||||
}, makeChars: function(buffer) {
|
||||
'use strict';
|
||||
var output = buffer.map(function(i) {
|
||||
return buffer.map(function(i) {
|
||||
return String.fromCharCode(i);
|
||||
});
|
||||
}, calculateDistance: function(txPower, rssi) {
|
||||
|
||||
return String.fromCharCode(i);
|
||||
});
|
||||
// If there is 0 txPower then default it to -12dBm which appears to be a general default.
|
||||
|
||||
var _txPower = (txPower !== 0) ? txPower : -12;
|
||||
|
||||
var ratio_db = _txPower - rssi;
|
||||
var ratio_linear = Math.pow(10, ratio_db / 10);
|
||||
|
||||
return Math.sqrt(ratio_linear);
|
||||
|
||||
}, /**
|
||||
*
|
||||
* @param device
|
||||
* @param device.rssi
|
||||
* @param device.otherData
|
||||
* @param device.id
|
||||
* @param device.name
|
||||
* @param device.rssiBuffer
|
||||
* @returns {jQuery|HTMLElement|*}
|
||||
*/
|
||||
|
||||
return output;
|
||||
},
|
||||
buildNewDeviceResultPanel: function(device) {
|
||||
'use strict';
|
||||
var dString;
|
||||
var accuracy;
|
||||
var avg;
|
||||
var sum;
|
||||
var newPanel, newRow;
|
||||
var otherData = device.otherData;
|
||||
var newId = 'd-' + device.id.replace(/:/g, '');
|
||||
var newId = 'd-' + device.id.replace(/:/g, '').split('-')[0];
|
||||
var title = device.hasOwnProperty('name') ? device.name : '*** Unknown';
|
||||
|
||||
newPanel = $('<div>',{id: newId,class: 'mui-panel deviceRow', style: 'min-height:75px;'});
|
||||
newPanel = $('<div>',
|
||||
{id: newId, class: 'mui-panel deviceRow', style: 'min-height:75px;'});
|
||||
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-12 mui--text-title',text: device.id}));
|
||||
newRow.append($('<div>',
|
||||
{class: 'mui-col-xs-12 mui--text-title', text: device.id}));
|
||||
|
||||
newPanel.append(newRow);
|
||||
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Name:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: title}));
|
||||
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'Title:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: title}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'RSSI:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: device.rssi}));
|
||||
if (typeof otherData !== 'undefined' && otherData !== null && otherData.hasOwnProperty(
|
||||
'txpower')) {
|
||||
if (device.hasOwnProperty('rssiBuffer') && (device.rssiBuffer.length > 0)) {
|
||||
sum = device.rssiBuffer.reduce(function(a, b) { return a + b; });
|
||||
avg = sum / device.rssiBuffer.length;
|
||||
accuracy = app.calculateDistance(otherData.txpower, avg);
|
||||
} else {
|
||||
accuracy = app.calculateDistance(otherData.txpower, device.rssi);
|
||||
}
|
||||
|
||||
dString = (accuracy <= 30.00) ? accuracy.toFixed(2) + ' m' : 'Far';
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Distance:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: dString}));
|
||||
|
||||
} else {
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'RSSI:'}));
|
||||
newRow.append($('<div>',
|
||||
{class: 'mui-col-xs-3', text: device.rssi + ' dB'}));
|
||||
|
||||
}
|
||||
|
||||
newPanel.append(newRow);
|
||||
|
||||
if (typeof otherData !== 'undefined' && otherData !== null) {
|
||||
if (otherData.hasOwnProperty('msg')) {
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'Data:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-8',text: otherData.msg}));
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Details:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-8', text: otherData.msg}));
|
||||
newPanel.append(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
return newPanel;
|
||||
},
|
||||
extractPData: function(prev) {
|
||||
}, extractPData: function(prev) {
|
||||
'use strict';
|
||||
|
||||
if (typeof prev === 'undefined' || prev === null) {
|
||||
@ -179,13 +208,21 @@ var app = {
|
||||
}
|
||||
return prev.pData;
|
||||
|
||||
}, extractRSSIBuffer: function(prev) {
|
||||
'use strict';
|
||||
|
||||
if (typeof prev === 'undefined' || prev === null) {
|
||||
return [];
|
||||
}
|
||||
return prev.rssiBuffer;
|
||||
|
||||
},
|
||||
|
||||
processPData: function(newData, oldData) {
|
||||
'use strict';
|
||||
var output = {};
|
||||
var wa = [];
|
||||
if (newData.data === null) {
|
||||
if (newData === null || newData.data === null) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -208,167 +245,200 @@ var app = {
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
doScan: function(mode) {
|
||||
}, processRSSIData: function(rssi, oldBuffer) {
|
||||
'use strict';
|
||||
if (typeof oldBuffer === 'undefined' || oldBuffer === null) {
|
||||
return [];
|
||||
}
|
||||
var wa = oldBuffer;
|
||||
|
||||
$('#ripple').show();
|
||||
if (mode !== 2) {
|
||||
$('#tbody').empty();
|
||||
if (wa.length === 10) {
|
||||
wa = wa.slice(1);
|
||||
}
|
||||
|
||||
var otherData = null;
|
||||
var msgText = '';
|
||||
ble.startScan([], function(device) {
|
||||
var parsed;
|
||||
var hexBuffer;
|
||||
var advertBuffer;
|
||||
var newTR;
|
||||
var newId;
|
||||
var _device = device;
|
||||
var $newID;
|
||||
wa.push(rssi);
|
||||
|
||||
_device.pData = {};
|
||||
|
||||
otherData = null;
|
||||
msgText = '';
|
||||
|
||||
newId = 'd-' + _device.id.replace(/:/g, '');
|
||||
|
||||
this.list[newId] = _device.id;
|
||||
|
||||
if (_device.hasOwnProperty('advertising')) {
|
||||
|
||||
advertBuffer = app.arrayBufferToIntArray(_device.advertising);
|
||||
|
||||
hexBuffer = app.makeHexBuffer(advertBuffer);
|
||||
|
||||
parsed = app.parseAdvertisingData(advertBuffer);
|
||||
|
||||
// Console.log(parsed);
|
||||
|
||||
if (parsed.hasOwnProperty('9')) {
|
||||
|
||||
var name = app.makeChars(parsed['9']);
|
||||
|
||||
_device.name = name.join('');
|
||||
console.log('Name: ', name.join(''));
|
||||
|
||||
}
|
||||
|
||||
if (parsed.hasOwnProperty('255')) {
|
||||
|
||||
otherData = app.handle255(parsed['255']);
|
||||
console.log(otherData);
|
||||
_device.otherData = otherData;
|
||||
}
|
||||
_device.advertBuffer = advertBuffer;
|
||||
_device.hexBuffer = hexBuffer;
|
||||
_device.parsed = parsed;
|
||||
return wa;
|
||||
}, doScan: function(mode) {
|
||||
'use strict';
|
||||
app.mode = mode;
|
||||
$('#ripple').show();
|
||||
if (mode !== 2) {
|
||||
$('#tbody').empty();
|
||||
}
|
||||
|
||||
newTR = app.buildNewDeviceResultPanel(device);
|
||||
ble.startScan([], app.foundDevice.bind(this), function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
$newID = $('div#' + newId);
|
||||
if ($newID.length > 0) {
|
||||
$newID.replaceWith(newTR);
|
||||
} else {
|
||||
$('#scanResults').append(newTR);
|
||||
}
|
||||
var _t = [5000, 60000, 200][mode];
|
||||
|
||||
// $('#output').append(JSON.stringify(device) + '<br/>');
|
||||
|
||||
var oldPdata = app.extractPData(app.log[newId]);
|
||||
|
||||
var newPData = app.processPData(otherData, oldPdata);
|
||||
|
||||
// Console.log(newPData);
|
||||
_device.pData = newPData;
|
||||
|
||||
app.log[newId] = _device;
|
||||
app.foundDevices[newId] = _device;
|
||||
|
||||
// Console.log(JSON.stringify(_device));
|
||||
|
||||
}.bind(this), function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
var _t = [5000,60000,200][mode];
|
||||
|
||||
setTimeout(ble.stopScan,
|
||||
_t,
|
||||
function() { console.log('Scan complete');
|
||||
|
||||
if (mode === 1) {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
if (mode === 2) {
|
||||
if (!app.stop) {
|
||||
setTimeout(function() {
|
||||
app.doScan(2);
|
||||
}.bind(this), 200);
|
||||
} else {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
function() { console.log('stopScan failed');
|
||||
setTimeout(ble.stopScan, _t, app.scanComplete, function() {
|
||||
console.log('stopScan failed');
|
||||
$('#ripple').hide();
|
||||
});
|
||||
|
||||
}, populateObject: function(source, dest) {
|
||||
var rObj = dest;
|
||||
for (var item in source) {
|
||||
if (source.hasOwnProperty(item)) {
|
||||
rObj[item] = source[item];
|
||||
}
|
||||
}
|
||||
|
||||
return rObj;
|
||||
},
|
||||
writeFile: function(fileEntry, dataObj) {
|
||||
// Create a FileWriter object for our FileEntry (log.txt).
|
||||
fileEntry.createWriter(function(fileWriter) {
|
||||
/**
|
||||
*
|
||||
* @param device
|
||||
* @param device.advertising
|
||||
* @param device.rssi
|
||||
* @param device.id
|
||||
*/
|
||||
|
||||
fileWriter.onwriteend = function() {
|
||||
console.log('Successful file write...');
|
||||
// ReadFile(fileEntry);
|
||||
};
|
||||
foundDevice: function(device) {
|
||||
var rssiBuffer;
|
||||
var oldRSSIBuffer;
|
||||
var newPData;
|
||||
var oldPdata;
|
||||
var parsed;
|
||||
var hexBuffer;
|
||||
var advertBuffer;
|
||||
var newTR;
|
||||
var newId = 'd-' + device.id.replace(/:/g, '').split('-')[0];
|
||||
var _device = app.foundDevices[newId] || {};
|
||||
var $newID;
|
||||
var otherData;
|
||||
|
||||
fileWriter.onerror = function(e) {
|
||||
console.error('Failed file write: ' + e.toString());
|
||||
};
|
||||
_device = app.populateObject(device, _device);
|
||||
// _device.pData = {};
|
||||
|
||||
// If data object is not passed in,
|
||||
// create a new Blob instead.
|
||||
if (!dataObj) {
|
||||
dataObj = new Blob(['some file data'], { type: 'text/plain' });
|
||||
}
|
||||
otherData = null;
|
||||
this.list[newId] = _device.id;
|
||||
|
||||
fileWriter.write(dataObj);
|
||||
});
|
||||
},
|
||||
saveLog: function() {
|
||||
if (_device.hasOwnProperty('advertising')) {
|
||||
|
||||
advertBuffer = app.arrayBufferToIntArray(_device.advertising);
|
||||
|
||||
hexBuffer = app.makeHexBuffer(advertBuffer);
|
||||
|
||||
parsed = app.parseAdvertisingData(advertBuffer);
|
||||
|
||||
if (parsed.hasOwnProperty('9')) {
|
||||
|
||||
var name = app.makeChars(parsed['9']);
|
||||
|
||||
_device.name = name.join('');
|
||||
console.log('Name: ', name.join(''));
|
||||
|
||||
}
|
||||
|
||||
if (parsed.hasOwnProperty('255')) {
|
||||
|
||||
otherData = app.handle255(parsed['255']);
|
||||
console.log(otherData);
|
||||
_device.otherData = otherData;
|
||||
}
|
||||
_device.advertBuffer = advertBuffer;
|
||||
_device.hexBuffer = hexBuffer;
|
||||
_device.parsed = parsed;
|
||||
}
|
||||
|
||||
// OldPdata = app.extractPData(app.log[newId]);
|
||||
oldPdata = app.extractPData(_device);
|
||||
|
||||
newPData = app.processPData(otherData, oldPdata);
|
||||
|
||||
// OldRSSIBuffer = app.extractRSSIBuffer(app.log[newId]);
|
||||
oldRSSIBuffer = app.extractRSSIBuffer(_device);
|
||||
rssiBuffer = app.processRSSIData(_device.rssi, oldRSSIBuffer);
|
||||
|
||||
_device.pData = newPData;
|
||||
_device.rssiBuffer = rssiBuffer;
|
||||
|
||||
newTR = app.buildNewDeviceResultPanel(_device);
|
||||
|
||||
$newID = $('div#' + newId);
|
||||
if ($newID.length > 0) {
|
||||
$newID.replaceWith(newTR);
|
||||
} else {
|
||||
$('#scanResults').append(newTR);
|
||||
}
|
||||
|
||||
app.log[newId] = _device;
|
||||
app.foundDevices[newId] = _device;
|
||||
|
||||
console.log(JSON.stringify(_device));
|
||||
|
||||
}, scanComplete: function() {
|
||||
console.log('Scan complete');
|
||||
|
||||
if (app.mode === 1) {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
if (app.mode === 2) {
|
||||
if (!app.stop) {
|
||||
setTimeout(function() {
|
||||
app.doScan(2);
|
||||
}.bind(this), 200);
|
||||
} else {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, writeFile: function(fileEntry, dataObj) {
|
||||
// Create a FileWriter object for our FileEntry (log.txt).
|
||||
fileEntry.createWriter(function(fileWriter) {
|
||||
|
||||
fileWriter.onwriteend = function() {
|
||||
console.log('Successful file write...');
|
||||
// ReadFile(fileEntry);
|
||||
};
|
||||
|
||||
fileWriter.onerror = function(e) {
|
||||
console.error('Failed file write: ' + e.toString());
|
||||
};
|
||||
|
||||
// If data object is not passed in,
|
||||
// create a new Blob instead.
|
||||
if (!dataObj) {
|
||||
dataObj = new Blob(['some file data'], {type: 'text/plain'});
|
||||
}
|
||||
|
||||
fileWriter.write(dataObj);
|
||||
});
|
||||
}, saveLog: function() {
|
||||
'use strict';
|
||||
var dt = new Date().toISOString().replace(/:|-/g,'').replace(/(\.\w+)/g,'');
|
||||
var dt = new Date().toISOString().replace(/:|-/g, '').replace(/(\.\w+)/g,
|
||||
'');
|
||||
var payload = JSON.stringify(app.log);
|
||||
var filename = 'sensortoy-' + dt + '.json';
|
||||
|
||||
// Var dataObj = new Blob(payload, { type: 'text/plain' });
|
||||
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
|
||||
|
||||
console.log('file system open: ' + fs.name);
|
||||
fs.root.getFile(filename, { create: true, exclusive: false }, function(fileEntry) {
|
||||
console.log('file system open: ' + fs.name);
|
||||
fs.root.getFile(filename,
|
||||
{create: true, exclusive: false},
|
||||
function(fileEntry) {
|
||||
|
||||
console.log('fileEntry is file?' + fileEntry.isFile.toString());
|
||||
// FileEntry.name == 'someFile.txt'
|
||||
// fileEntry.fullPath == '/someFile.txt'
|
||||
console.log('Path: ', fileEntry.fullPath);
|
||||
app.writeFile(fileEntry, payload);
|
||||
console.log('fileEntry is file?' + fileEntry.isFile.toString());
|
||||
// FileEntry.name == 'someFile.txt'
|
||||
// fileEntry.fullPath == '/someFile.txt'
|
||||
console.log('Path: ', fileEntry.fullPath);
|
||||
app.writeFile(fileEntry, payload);
|
||||
|
||||
app.log = [];
|
||||
app.log = [];
|
||||
|
||||
}, app.onError);
|
||||
},
|
||||
app.onError);
|
||||
|
||||
}, app.onError);
|
||||
},
|
||||
forceStop: function() {
|
||||
}, app.onError);
|
||||
}, forceStop: function() {
|
||||
'use strict';
|
||||
app.stop = true;
|
||||
$('#scan').show();
|
||||
@ -391,10 +461,10 @@ var app = {
|
||||
}.bind(this));
|
||||
|
||||
$('#stop').on('click', function() {
|
||||
'use strict';
|
||||
app.forceStop();
|
||||
'use strict';
|
||||
app.forceStop();
|
||||
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
$('#longScan').on('click', function() {
|
||||
'use strict';
|
||||
@ -412,8 +482,7 @@ var app = {
|
||||
self.connect(id);
|
||||
});
|
||||
|
||||
},
|
||||
addTab: function(tID) {
|
||||
}, addTab: function(tID) {
|
||||
var appTabs = $('#app-tabs');
|
||||
var panes = $('#tab-panes');
|
||||
|
||||
@ -426,8 +495,8 @@ var app = {
|
||||
|
||||
$('<div>', {class: 'mui-tabs__pane', id: paneID}).appendTo(panes);
|
||||
|
||||
|
||||
var li = $('<li>').append($('<a>',{'data-mui-toggle': 'tab', 'data-mui-controls': paneID, text: _name }));
|
||||
var li = $('<li>').append($('<a>',
|
||||
{'data-mui-toggle': 'tab', 'data-mui-controls': paneID, text: _name}));
|
||||
|
||||
appTabs.append(li);
|
||||
|
||||
@ -444,36 +513,40 @@ var app = {
|
||||
},
|
||||
|
||||
doAnimate: function() {
|
||||
'use strict';
|
||||
// Console.log('Animate..');
|
||||
for (var t = 0; t < app.activeServices.length;t++) {
|
||||
app.activeServices[t].animateGraph();
|
||||
for (var item in app.activeServices) {
|
||||
if (app.activeServices.hasOwnProperty(item)) {
|
||||
var activeService = app.activeServices[item];
|
||||
for (var t = 0; t < activeService.length; t++) {
|
||||
activeService[t].animateGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.requestAnimFrame(app.doAnimate.bind(this));
|
||||
},
|
||||
connect: function(deviceId) {
|
||||
}, connect: function(deviceId) {
|
||||
|
||||
$('#results').slideUp();
|
||||
console.log('Connect to ', deviceId);
|
||||
|
||||
var tID = 'd-' + deviceId.replace(/:/g, '');
|
||||
var tID = 'd-' + deviceId.replace(/:/g, '').split('-')[0];
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param a.services
|
||||
*/
|
||||
var onConnect = function(a) {
|
||||
var services = [];
|
||||
|
||||
services = a.services;
|
||||
|
||||
|
||||
console.log('Searching services for ', tID);
|
||||
var usedServices = [];
|
||||
|
||||
var target = app.addTab(tID);
|
||||
|
||||
var _params = {
|
||||
deviceID: deviceId,
|
||||
target: target
|
||||
};
|
||||
deviceID: deviceId, target: target
|
||||
};
|
||||
|
||||
for (var t = 0; t < services.length; t++) {
|
||||
|
||||
@ -501,29 +574,26 @@ var app = {
|
||||
if (!app.activeServices.hasOwnProperty(tID)) {
|
||||
|
||||
ble.connect(deviceId, onConnect, function(e) {
|
||||
'use strict';
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
'use strict';
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}, onError: function(reason) {
|
||||
console.error('ERROR: ' + reason); // Real apps should use notification.alert
|
||||
}, updateGyro: function(g) {
|
||||
'use strict';
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
})();
|
||||
|
||||
app.initialize();
|
||||
|
@ -5,38 +5,82 @@
|
||||
* Time: 14:21
|
||||
*
|
||||
*/
|
||||
|
||||
/* global MANUFACTUREDECODER */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var MANUFACTUREDECODER = function() {
|
||||
'use strict';
|
||||
|
||||
this.getManID = function(data) {
|
||||
return ('0000' + ((data[1] << 8) | data[0]).toString(16)).slice(-4).toUpperCase();
|
||||
},
|
||||
};
|
||||
|
||||
this.decodeIbeacon = function(data) {
|
||||
|
||||
// Not decoding anything yet.
|
||||
// https://support.kontakt.io/hc/en-gb/articles/201492492-iBeacon-advertising-packet-structure
|
||||
var bin = data;
|
||||
var obj = { msg: '(iBeacon)'};
|
||||
// obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
// Obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
obj.manID = this.getManID(bin);
|
||||
var uuid = [];
|
||||
uuid.push(bin[4].toString(16) + bin[5].toString(16) + bin[6].toString(16) + bin[7].toString(16)) ;
|
||||
if (bin[2] === 2) {
|
||||
uuid.push(bin[4].toString(16) + bin[5].toString(16) + bin[6].toString(16) + bin[7].toString(16)) ;
|
||||
|
||||
uuid.push(bin[8].toString(16) + bin[9].toString(16)) ;
|
||||
uuid.push(bin[10].toString(16) + bin[11].toString(16)) ;
|
||||
uuid.push(bin[12].toString(16) + bin[13].toString(16)) ;
|
||||
uuid.push(bin[8].toString(16) + bin[9].toString(16)) ;
|
||||
uuid.push(bin[10].toString(16) + bin[11].toString(16)) ;
|
||||
uuid.push(bin[12].toString(16) + bin[13].toString(16)) ;
|
||||
|
||||
uuid.push(bin[14].toString(16) + bin[15].toString(16) + bin[16].toString(16) + bin[17].toString(16) + bin[18].toString(16) + bin[19].toString(16)) ;
|
||||
var p4 = bin[14].toString(16);
|
||||
p4 = p4 + bin[15].toString(16);
|
||||
p4 = p4 + bin[16].toString(16);
|
||||
p4 = p4 + bin[17].toString(16);
|
||||
p4 = p4 + bin[18].toString(16);
|
||||
p4 = p4 + bin[19].toString(16);
|
||||
|
||||
obj.uuid = uuid.join('-');
|
||||
uuid.push(p4);
|
||||
obj.uuid = uuid.join('-');
|
||||
}
|
||||
|
||||
if (bin[2] === 9) {
|
||||
// This looks like an ip address?
|
||||
var ipaddy = [];
|
||||
ipaddy.push(bin[6]);
|
||||
ipaddy.push(bin[7]);
|
||||
ipaddy.push(bin[8]);
|
||||
ipaddy.push(bin[9]);
|
||||
|
||||
obj.ipaddress = ipaddy.join('.');
|
||||
obj.msg = obj.msg + ' IP:' + obj.ipaddress;
|
||||
}
|
||||
|
||||
if (bin[2] === 12) {
|
||||
|
||||
|
||||
var output = bin.map(function(i) {
|
||||
|
||||
return ('0000' + i.toString(16)).slice(-2) + '';
|
||||
});
|
||||
|
||||
obj.secureUUID = output.join('');
|
||||
|
||||
}
|
||||
|
||||
var signedByte = new Int8Array(1);
|
||||
signedByte[0] = bin[24];
|
||||
obj.txpower = signedByte[0];
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
this.decodeSiliconLabsSensorPuck = function(data) {
|
||||
var bin = data;
|
||||
var obj = {data:{}};
|
||||
//obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
var obj = {data: {}};
|
||||
obj.manID = this.getManID(bin);
|
||||
obj.a = (bin[3] << 8) | bin[2];
|
||||
obj.b = (bin[5] << 8) | bin[4];
|
||||
@ -53,8 +97,7 @@ var MANUFACTUREDECODER = function() {
|
||||
|
||||
this.decodeSansible = function(data) {
|
||||
var bin = data;
|
||||
var obj = {data:{}};
|
||||
// obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
var obj = {data: {}};
|
||||
obj.manID = this.getManID(bin);
|
||||
|
||||
obj.data.p1 = ((bin[2] << 16) | bin[3] << 8 | bin[4]);
|
||||
|
@ -5,13 +5,21 @@
|
||||
* Time: 11:47
|
||||
*
|
||||
*/
|
||||
|
||||
/* global bt_company_ids */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {{find: bt_company_ids.find, entries: *[]}}
|
||||
*/
|
||||
|
||||
var bt_company_ids = {
|
||||
find: function(id) {
|
||||
var _id = id;
|
||||
var item = this.entries.filter(function(obj) {
|
||||
return this.entries.filter(function(obj) {
|
||||
return obj.hexadecimal === _id;
|
||||
});
|
||||
return item;
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
|
@ -53,8 +53,7 @@ var BUTTON = function(p) {
|
||||
|
||||
this.state = message;
|
||||
|
||||
if (this.$result !== null)
|
||||
{
|
||||
if (this.$result !== null) {
|
||||
this.$result.text(this.state);
|
||||
}
|
||||
console.log('ButtonState: ', this.state);
|
||||
@ -63,7 +62,6 @@ var BUTTON = function(p) {
|
||||
};
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting Button Service on ', this.deviceID);
|
||||
@ -78,7 +76,7 @@ var BUTTON = function(p) {
|
||||
this.insertFrame = function() {
|
||||
|
||||
var self = this;
|
||||
console.log('Overloading...');
|
||||
console.log('Overloading...');
|
||||
// Call the parent displayForm first...
|
||||
this.superClass_.insertFrame.call(self);
|
||||
|
||||
@ -90,7 +88,7 @@ var BUTTON = function(p) {
|
||||
$('<div />', { class: 'mui-col-xs-8 mui--text-dark', id: detail}).appendTo(row);
|
||||
|
||||
this.$id.append(row);
|
||||
this.$result = $('#'+detail);
|
||||
this.$result = $('#' + detail);
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,14 +5,18 @@
|
||||
* Time: 10:32
|
||||
*
|
||||
*/
|
||||
|
||||
/* global inheritsFrom */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
'use strict';
|
||||
var capabilityManager = {
|
||||
capabilityList : [],
|
||||
register : function(details) {
|
||||
console.log('Registered:', details );
|
||||
capabilityList: [],
|
||||
register: function(details) {
|
||||
console.log('Registered:', details);
|
||||
this.capabilityList.push(details);
|
||||
},
|
||||
discover : function(id) {
|
||||
discover: function(id) {
|
||||
|
||||
var wanted = this.capabilityList.filter(function(obj) {
|
||||
return obj.id === id;
|
||||
@ -41,15 +45,18 @@ var CAPABILITY = function(p) {
|
||||
|
||||
this.target = null;
|
||||
this.$frame = null;
|
||||
capabilityManager.register({id:this.capabilityID, module:this});
|
||||
|
||||
this.previousCeil = 0;
|
||||
|
||||
capabilityManager.register({id: this.capabilityID, module: this});
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.setFrame = function() {
|
||||
this.$frame = (this.target !== null) ? $('#'+ this.target) : null;
|
||||
this.$frame = (this.target !== null) ? $('#' + this.target) : null;
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.setInternalID = function() {
|
||||
this.internalID = (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1).toString(36);
|
||||
this.internalID = (Math.floor(Math.random() * 60000) + 1).toString(36);
|
||||
this.frameID = 'f-' + this.internalID;
|
||||
};
|
||||
|
||||
@ -81,10 +88,10 @@ CAPABILITY.prototype.insertFrame = function() {
|
||||
|
||||
|
||||
CAPABILITY.prototype.inherits = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
var C = function() {};
|
||||
C.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype = new C;
|
||||
a.prototype.constructor = a;
|
||||
};
|
||||
|
||||
@ -92,6 +99,13 @@ CAPABILITY.prototype.onError = function(e) {
|
||||
console.error(e);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @param alt
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
CAPABILITY.prototype.storeData = function(data, alt) {
|
||||
|
||||
if (!this.first) {
|
||||
@ -124,87 +138,114 @@ CAPABILITY.prototype.startGraph = function(id) {
|
||||
this.ctx.fillRect(0,0,300,150);
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraph = function(subID) {
|
||||
|
||||
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraphBase = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
|
||||
var svgID = this.frameID + _subID + '-svg';
|
||||
var text1ID = this.frameID + _subID + '-txt1';
|
||||
var lineID = this.frameID + _subID + '-line';
|
||||
|
||||
var svg = document.createElementNS(xmlns,'svg');
|
||||
|
||||
svg.setAttributeNS(xmlns,'id',svgID);
|
||||
svg.setAttributeNS(xmlns,'width',300);
|
||||
svg.setAttributeNS(xmlns,'height',150);
|
||||
svg.setAttributeNS(xmlns,'width','300');
|
||||
svg.setAttributeNS(xmlns,'height','150');
|
||||
svg.setAttributeNS(xmlns,'fill', 'blue');
|
||||
|
||||
|
||||
svg = this.graphAddXAxis(svg,{y: 12, colour: '#004c6d', id: text1ID});
|
||||
svg = this.graphAddXAxis(svg,{y: 136, colour: '#004c6d', text: '0'});
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
var _svg = svg;
|
||||
var y = settings.y || 0;
|
||||
var y2 = y + 3;
|
||||
var x2 = settings.x2 || 280;
|
||||
var colour = settings.colour || '#ff0000';
|
||||
var id = settings.id;
|
||||
var textContent = settings.text || '-';
|
||||
var lineStyle = ['stroke:',colour,';stroke-width:2;'].join('');
|
||||
var textStyle = ['font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: ',colour,';text-align:right;'].join('');
|
||||
|
||||
var line = document.createElementNS(xmlns,'line');
|
||||
|
||||
line.setAttributeNS(null,'x1','46');
|
||||
line.setAttributeNS(null,'y1','12');
|
||||
line.setAttributeNS(null,'x2','280');
|
||||
line.setAttributeNS(null,'y2', '12');
|
||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
||||
line.setAttributeNS(null,'y1', y);
|
||||
line.setAttributeNS(null,'x2', x2);
|
||||
line.setAttributeNS(null,'y2', y);
|
||||
line.setAttributeNS(null,'style',lineStyle);
|
||||
|
||||
svg.appendChild(line);
|
||||
|
||||
line = document.createElementNS(xmlns,'line');
|
||||
|
||||
line.setAttributeNS(null,'x1','46');
|
||||
line.setAttributeNS(null,'y1','136');
|
||||
line.setAttributeNS(null,'x2','280');
|
||||
line.setAttributeNS(null,'y2', '136');
|
||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
||||
|
||||
svg.appendChild(line);
|
||||
_svg.appendChild(line);
|
||||
|
||||
var text = document.createElementNS(xmlns,'text');
|
||||
|
||||
text.setAttributeNS(null,'id',text1ID);
|
||||
if (id !== null) {
|
||||
text.setAttributeNS(null,'id',id);
|
||||
}
|
||||
text.setAttributeNS(null,'x','36');
|
||||
text.setAttributeNS(null,'y','15');
|
||||
text.setAttributeNS(null,'y', y2);
|
||||
text.setAttributeNS(null,'text-anchor', 'end');
|
||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
||||
text.textContent = '000';
|
||||
text.setAttributeNS(null,'style',textStyle);
|
||||
text.textContent = textContent;
|
||||
|
||||
svg.appendChild(text);
|
||||
_svg.appendChild(text);
|
||||
|
||||
text = document.createElementNS(xmlns,'text');
|
||||
return _svg;
|
||||
};
|
||||
|
||||
text.setAttributeNS(null,'id','text2');
|
||||
text.setAttributeNS(null,'x','36');
|
||||
text.setAttributeNS(null,'y','140');
|
||||
text.setAttributeNS(null,'text-anchor', 'end');
|
||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
||||
text.textContent = '0';
|
||||
|
||||
svg.appendChild(text);
|
||||
CAPABILITY.prototype.graphAddLine = function(svg, lineId, colour) {
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
var _svg = svg;
|
||||
|
||||
var polyline = document.createElementNS(xmlns,'polyline');
|
||||
|
||||
polyline.setAttributeNS(null,'id',lineID);
|
||||
polyline.setAttributeNS(null,'id',lineId);
|
||||
polyline.setAttributeNS(null,'fill','none');
|
||||
polyline.setAttributeNS(null,'stroke','#2196F3');
|
||||
//#e5f7fd
|
||||
// Proper '#2196F3'
|
||||
polyline.setAttributeNS(null,'stroke',colour);
|
||||
// #e5f7fd
|
||||
// old #B5C7FF
|
||||
polyline.setAttributeNS(null,'text-anchor', 'end');
|
||||
polyline.setAttributeNS(null,'stroke-width','2');
|
||||
|
||||
svg.appendChild(polyline);
|
||||
_svg.appendChild(polyline);
|
||||
|
||||
return _svg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraph = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var lineID = this.frameID + _subID + '-line';
|
||||
|
||||
var svg = this.generateBlankGraphBase(_subID);
|
||||
|
||||
svg = this.graphAddLine(svg, lineID, '#2196F3');
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.animateGraph = function() {
|
||||
//This.simpleGraph(this.data);
|
||||
// This.simpleGraph(this.data);
|
||||
};
|
||||
|
||||
|
||||
CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
var ceilingLimit;
|
||||
var ceiling;
|
||||
var _subID;
|
||||
var _data;
|
||||
var text1ID;
|
||||
@ -218,9 +259,11 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
text1ID = [this.frameID , _subID , '-txt1'].join('');
|
||||
|
||||
if (_data.length > 0) {
|
||||
var ceiling = _data.reduce(function(p, v) {
|
||||
return (p > v ? p : v);
|
||||
});
|
||||
|
||||
ceiling = _data.reduce(function(p, v) {
|
||||
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||
});
|
||||
|
||||
|
||||
/* Var floor = _data.reduce(function(p, v) {
|
||||
return (p < v ? p : v);
|
||||
@ -229,6 +272,7 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
var calcArray = [];
|
||||
|
||||
/*
|
||||
var ceilingLimit = Math.floor(ceiling / 10) * 10;
|
||||
if (ceilingLimit < ceiling) {
|
||||
ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10;
|
||||
@ -237,6 +281,13 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
if (ceilingLimit < 30) {
|
||||
ceilingLimit = 30;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 10) * 10);
|
||||
if (ceilingLimit > 1000) {
|
||||
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 50) * 50);
|
||||
}
|
||||
|
||||
var scale = 124 / ceilingLimit;
|
||||
// Var xstep = (280 - 46) / 100;
|
||||
@ -264,10 +315,10 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
|
||||
var inheritsFrom = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
var C = function() {};
|
||||
C.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype = new C;
|
||||
a.prototype.constructor = a;
|
||||
a.prototype.superClass_ = b.prototype;
|
||||
};
|
||||
|
@ -6,6 +6,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
var GADGET = function(p) {
|
||||
'use strict';
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Created by martin on 2016-05-20.
|
||||
*/
|
||||
var DEVICEBASE = function(p) {
|
||||
|
||||
this.controller = p.controller || null;
|
||||
this.settings = p.settings || {};
|
||||
this.data = {};
|
||||
this.standards = {
|
||||
|
||||
button: {
|
||||
service: 'FFE0',
|
||||
data: 'FFE1' // Bit 2: side key, Bit 1- right key, Bit 0 –left key
|
||||
},
|
||||
heartRate: {
|
||||
service: '180d',
|
||||
measurement: '2a37'
|
||||
}
|
||||
};
|
||||
this.custom = {};
|
||||
this.capabilities = [];
|
||||
this.deviceID = null;
|
||||
|
||||
this.inherits = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype.constructor = a;
|
||||
};
|
||||
|
||||
|
||||
this.register = function(c) {
|
||||
c.registerPage(this);
|
||||
|
||||
};
|
||||
|
||||
this.bytesToString = function(buffer) {
|
||||
return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
};
|
||||
|
||||
// ASCII only
|
||||
this.stringToBytes = function(string) {
|
||||
var array = new Uint8Array(string.length);
|
||||
for (var i = 0, l = string.length; i < l; i++) {
|
||||
array[i] = string.charCodeAt(i);
|
||||
}
|
||||
return array.buffer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
this.register(this.controller);
|
||||
};
|
64
config.xml
@ -1,6 +1,6 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="org.censis.sensortoy" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<name>Sensortoy</name>
|
||||
<name>BLE Sensors</name>
|
||||
<description>
|
||||
A sample Apache Cordova application that responds to the deviceready event.
|
||||
</description>
|
||||
@ -18,49 +18,39 @@
|
||||
<allow-intent href="geo:*" />
|
||||
<platform name="android">
|
||||
<allow-intent href="market:*" />
|
||||
<icon src="res/android/android-chrome-36x36.png" density="ldpi"/>
|
||||
<icon src="res/android/mipmap-mdpi/ic_launcher.png" density="mdpi"/>
|
||||
<icon src="res/android/mipmap-hdpi/ic_launcher.png" density="hdpi"/>
|
||||
<icon src="res/android/mipmap-xhdpi/ic_launcher.png" density="xhdpi"/>
|
||||
<icon src="res/android/mipmap-xxhdpi/ic_launcher.png" density="xxhdpi"/>
|
||||
<icon src="res/android/mipmap-xxxhdpi/ic_launcher.png" density="xxxhdpi"/>
|
||||
<icon density="ldpi" src="res/android/android-chrome-36x36.png" />
|
||||
<icon density="mdpi" src="res/android/mipmap-mdpi/ic_launcher.png" />
|
||||
<icon density="hdpi" src="res/android/mipmap-hdpi/ic_launcher.png" />
|
||||
<icon density="xhdpi" src="res/android/mipmap-xhdpi/ic_launcher.png" />
|
||||
<icon density="xxhdpi" src="res/android/mipmap-xxhdpi/ic_launcher.png" />
|
||||
<icon density="xxxhdpi" src="res/android/mipmap-xxxhdpi/ic_launcher.png" />
|
||||
</platform>
|
||||
<platform name="ios">
|
||||
<preference name="StatusBarStyle" value="lightcontent"/>
|
||||
<preference name="DisallowOverscroll" value="true" />
|
||||
<preference name="StatusBarStyle" value="lightcontent" />
|
||||
<preference name="DisallowOverscroll" value="true" />
|
||||
<allow-intent href="itms:*" />
|
||||
<allow-intent href="itms-apps:*" />
|
||||
|
||||
<!-- iOS 8.0+ -->
|
||||
<!-- iPhone 6 Plus -->
|
||||
<icon src="res/ios/icon-60@3x.png" width="180" height="180"/>
|
||||
<!-- iOS 7.0+ -->
|
||||
<!-- iPhone / iPod Touch -->
|
||||
<icon src="res/ios/icon-60.png" width="60" height="60"/>
|
||||
<icon src="res/ios/icon-60@2x.png" width="120" height="120"/>
|
||||
<!-- iPad -->
|
||||
<icon src="res/ios/icon-76.png" width="76" height="76"/>
|
||||
<icon src="res/ios/icon-76@2x.png" width="152" height="152"/>
|
||||
<!-- iOS 6.1 -->
|
||||
<!-- Spotlight Icon -->
|
||||
<icon src="res/ios/icon-40.png" width="40" height="40"/>
|
||||
<icon src="res/ios/icon-40@2x.png" width="80" height="80"/>
|
||||
<!-- iPhone / iPod Touch -->
|
||||
<icon src="res/ios/icon.png" width="57" height="57"/>
|
||||
<icon src="res/ios/icon@2x.png" width="114" height="114"/>
|
||||
<!-- iPad -->
|
||||
<icon src="res/ios/icon-72.png" width="72" height="72"/>
|
||||
<icon src="res/ios/icon-72@2x.png" width="144" height="144"/>
|
||||
<!-- iPhone Spotlight and Settings Icon -->
|
||||
<icon src="res/ios/icon-small.png" width="29" height="29"/>
|
||||
<icon src="res/ios/icon-small@2x.png" width="58" height="58"/>
|
||||
<!-- iPad Spotlight and Settings Icon -->
|
||||
<icon src="res/ios/icon-50.png" width="50" height="50"/>
|
||||
<icon src="res/ios/icon-50@2x.png" width="100" height="100"/>
|
||||
<icon height="180" src="res/ios/icon-60@3x.png" width="180" />
|
||||
<icon height="60" src="res/ios/icon-60.png" width="60" />
|
||||
<icon height="120" src="res/ios/icon-60@2x.png" width="120" />
|
||||
<icon height="76" src="res/ios/icon-76.png" width="76" />
|
||||
<icon height="152" src="res/ios/icon-76@2x.png" width="152" />
|
||||
<icon height="40" src="res/ios/icon-40.png" width="40" />
|
||||
<icon height="80" src="res/ios/icon-40@2x.png" width="80" />
|
||||
<icon height="57" src="res/ios/icon.png" width="57" />
|
||||
<icon height="114" src="res/ios/icon@2x.png" width="114" />
|
||||
<icon height="72" src="res/ios/icon-72.png" width="72" />
|
||||
<icon height="144" src="res/ios/icon-72@2x.png" width="144" />
|
||||
<icon height="29" src="res/ios/icon-small.png" width="29" />
|
||||
<icon height="58" src="res/ios/icon-small@2x.png" width="58" />
|
||||
<icon height="50" src="res/ios/icon-50.png" width="50" />
|
||||
<icon height="100" src="res/ios/icon-50@2x.png" width="100" />
|
||||
</platform>
|
||||
<engine name="ios" spec="~4.1.1" />
|
||||
<engine name="android" spec="~5.1.1" />
|
||||
<plugin name="cordova-plugin-ble-central" spec="~1.1.0" />
|
||||
<plugin name="cordova-plugin-file" spec="~4.2.0" />
|
||||
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
|
||||
<preference name="AndroidPersistentFileLocation" value="Compatibility" />
|
||||
<plugin name="cordova-plugin-device" spec="~1.1.2" />
|
||||
<plugin name="cordova-plugin-statusbar" spec="~2.1.3" />
|
||||
</widget>
|
||||
|
2
fonts.list
Normal file
@ -0,0 +1,2 @@
|
||||
Ubuntu:300,400,500,700
|
||||
Ubuntu+Condensed
|
96
gulpfile.js
@ -13,22 +13,26 @@ var inject = require('gulp-inject');
|
||||
var del = require('del');
|
||||
var htmlreplace = require('gulp-html-replace');
|
||||
var stripDebug = require('gulp-strip-debug');
|
||||
var scss = require('gulp-scss');
|
||||
var sass = require('gulp-sass');
|
||||
var googleWebFonts = require('gulp-google-webfonts');
|
||||
|
||||
|
||||
var filePath = {
|
||||
build_dir: './dist'
|
||||
};
|
||||
|
||||
var fontOptions = { };
|
||||
|
||||
gulp.task('appJS', function() {
|
||||
return gulp.src(['app/js/mandecoder.js','app/js/index.js'])
|
||||
.pipe(stripDebug())
|
||||
.pipe(jshint('.jshintrc'))
|
||||
.pipe(jshint.reporter('default'))
|
||||
.pipe(concat('index.js'))
|
||||
.pipe(concat('app.js'))
|
||||
/*.pipe(gulp.dest('dist/js'))*/
|
||||
/*.pipe(rename({suffix: '.min'}))*/
|
||||
/* .pipe(uglify({mangle: false}))*/
|
||||
.pipe(uglify({mangle: false}))
|
||||
/*.pipe(concat('app.js'))*/
|
||||
.pipe(gulp.dest('www/js'));
|
||||
});
|
||||
@ -41,9 +45,9 @@ gulp.task('cc2650', function() {
|
||||
.pipe(concat('cc2650.js'))
|
||||
/*.pipe(gulp.dest('dist/js'))*/
|
||||
/*.pipe(rename({suffix: '.min'}))*/
|
||||
/* .pipe(uglify({mangle: false}))*/
|
||||
.pipe(uglify({mangle: false}))
|
||||
/*.pipe(concat('app.js'))*/
|
||||
.pipe(gulp.dest('www/js/device'));
|
||||
.pipe(gulp.dest('www/js'));
|
||||
});
|
||||
|
||||
gulp.task('devices', function() {
|
||||
@ -51,16 +55,80 @@ gulp.task('devices', function() {
|
||||
.pipe(stripDebug())
|
||||
.pipe(jshint('.jshintrc'))
|
||||
.pipe(jshint.reporter('default'))
|
||||
.pipe(concat('devices.js'))
|
||||
.pipe(concat('standards.js'))
|
||||
/*.pipe(gulp.dest('dist/js'))*/
|
||||
/*.pipe(rename({suffix: '.min'}))*/
|
||||
/* .pipe(uglify({mangle: false}))*/
|
||||
.pipe(uglify({mangle: false}))
|
||||
/*.pipe(concat('app.js'))*/
|
||||
.pipe(gulp.dest('www/js/standards'));
|
||||
.pipe(gulp.dest('www/js'));
|
||||
});
|
||||
|
||||
gulp.task('vendor', function() {
|
||||
return gulp.src(['app/libs/jquery/dist/jquery.min.js',
|
||||
'app/libs/mui/packages/cdn/js/mui.min.js'])
|
||||
.pipe(concat('vendor.js'))
|
||||
.pipe(uglify({mangle: false}))
|
||||
.pipe(gulp.dest('www/libs'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('mui', function() {
|
||||
return gulp.src(['app/css/custom.scss'])
|
||||
.pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
|
||||
//.pipe(cssnano())
|
||||
.pipe(gulp.dest('www/css'));
|
||||
});
|
||||
|
||||
gulp.task('styles', function() {
|
||||
return gulp.src(['app/css/app.css','app/css/progress.css'])
|
||||
.pipe(autoprefixer('last 2 version', 'safari 5', 'ie 8', 'ie 9', 'opera 12.1', 'ios 6', 'android 4'))
|
||||
.pipe(cssnano())
|
||||
.pipe(concat('app.css'))
|
||||
.pipe(gulp.dest('www/css'));
|
||||
});
|
||||
|
||||
gulp.task('fonts', function() {
|
||||
return gulp.src('./fonts.list')
|
||||
.pipe(googleWebFonts(fontOptions))
|
||||
.pipe(gulp.dest('www/fonts'))
|
||||
;
|
||||
});
|
||||
|
||||
gulp.task('index', function() {
|
||||
|
||||
return gulp.src(['app/index.html'])
|
||||
.pipe(htmlreplace({
|
||||
mui: 'css/custom.css',
|
||||
css: 'css/app.css',
|
||||
js: 'js/app.js',
|
||||
vendor: 'libs/vendor.js',
|
||||
fonts: 'fonts/fonts.css',
|
||||
standards: 'js/standards.js',
|
||||
cc2650: 'js/cc2650.js'
|
||||
|
||||
}))
|
||||
.pipe(htmlmin({removeComments: true, collapseWhitespace: true, keepClosingSlash: true}))
|
||||
|
||||
.pipe(gulp.dest('www/'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('partials', function() {
|
||||
|
||||
// Gulp.src(['app/partials/**/*']).pipe(gulp.dest('dist/partials'));
|
||||
// gulp.src(['app/libs/ejs_production.js']).pipe(gulp.dest('dist/libs'));
|
||||
// gulp.src(['app/libs/microevent.js']).pipe(gulp.dest('dist/libs'));
|
||||
//gulp.src(['app/fav/**/*']).pipe(size({title: 'Partials'})).pipe(gulp.dest('dist/fav'));
|
||||
gulp.src(['app/img/logo.png']).pipe(gulp.dest('www/img'));
|
||||
});
|
||||
|
||||
gulp.task('copy', function() {
|
||||
return gulp.src(['app/**/*'])
|
||||
.pipe(gulp.dest('www'));
|
||||
});
|
||||
|
||||
gulp.task('buildJS', function() {
|
||||
gulp.start('appJS','cc2650','devices');
|
||||
gulp.start('appJS','cc2650','devices','vendor');
|
||||
});
|
||||
|
||||
gulp.task('clean', function() {
|
||||
@ -68,8 +136,16 @@ gulp.task('clean', function() {
|
||||
});
|
||||
|
||||
|
||||
|
||||
gulp.task('normal', ['clean'], function() {
|
||||
'use strict';
|
||||
gulp.start('copy','watch');
|
||||
});
|
||||
|
||||
gulp.task('default', ['clean'], function() {
|
||||
gulp.start('buildJS');
|
||||
gulp.start('buildJS','mui','styles','fonts', 'index', 'partials');
|
||||
});
|
||||
|
||||
gulp.task('watch',function() {
|
||||
gulp.watch('app/**/*',['copy']);
|
||||
|
||||
});
|
||||
|
@ -19,6 +19,7 @@
|
||||
"gulp-cache": "^0.4.5",
|
||||
"gulp-concat": "^2.6.0",
|
||||
"gulp-cssnano": "^2.1.2",
|
||||
"gulp-google-webfonts": "0.0.12",
|
||||
"gulp-html-replace": "^1.6.0",
|
||||
"gulp-htmlmin": "^2.0.0",
|
||||
"gulp-inject": "^4.1.0",
|
||||
@ -26,8 +27,12 @@
|
||||
"gulp-livereload": "^3.8.1",
|
||||
"gulp-notify": "^2.2.0",
|
||||
"gulp-rename": "^1.2.2",
|
||||
"gulp-sass": "^2.3.1",
|
||||
"gulp-scss": "^1.3.17",
|
||||
"gulp-strip-debug": "^1.1.0",
|
||||
"gulp-uglify": "^1.5.3",
|
||||
"jshint": "^2.9.2"
|
||||
"gulp-watch": "^4.3.6",
|
||||
"jshint": "^2.9.2",
|
||||
"scss": "^0.2.4"
|
||||
}
|
||||
}
|
||||
|
@ -15,6 +15,14 @@
|
||||
{
|
||||
"xml": "<feature name=\"File\"><param name=\"android-package\" value=\"org.apache.cordova.file.FileUtils\" /><param name=\"onload\" value=\"true\" /></feature>",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"xml": "<feature name=\"Device\"><param name=\"android-package\" value=\"org.apache.cordova.device.Device\" /></feature>",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"xml": "<feature name=\"StatusBar\"><param name=\"android-package\" value=\"org.apache.cordova.statusbar.StatusBar\" /><param name=\"onload\" value=\"true\" /></feature>",
|
||||
"count": 1
|
||||
}
|
||||
],
|
||||
"/widget": [
|
||||
@ -63,6 +71,12 @@
|
||||
},
|
||||
"cordova-plugin-file": {
|
||||
"PACKAGE_NAME": "org.censis.sensortoy"
|
||||
},
|
||||
"cordova-plugin-device": {
|
||||
"PACKAGE_NAME": "org.censis.sensortoy"
|
||||
},
|
||||
"cordova-plugin-statusbar": {
|
||||
"PACKAGE_NAME": "org.censis.sensortoy"
|
||||
}
|
||||
},
|
||||
"dependent_plugins": {},
|
||||
@ -224,12 +238,28 @@
|
||||
"cordova"
|
||||
],
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-device/www/device.js",
|
||||
"id": "cordova-plugin-device.device",
|
||||
"clobbers": [
|
||||
"device"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
|
||||
"id": "cordova-plugin-statusbar.statusbar",
|
||||
"clobbers": [
|
||||
"window.StatusBar"
|
||||
]
|
||||
}
|
||||
],
|
||||
"plugin_metadata": {
|
||||
"cordova-plugin-whitelist": "1.2.2",
|
||||
"cordova-plugin-compat": "1.0.0",
|
||||
"cordova-plugin-ble-central": "1.1.0",
|
||||
"cordova-plugin-file": "4.2.0"
|
||||
"cordova-plugin-file": "4.2.0",
|
||||
"cordova-plugin-device": "1.1.2",
|
||||
"cordova-plugin-statusbar": "2.1.3"
|
||||
}
|
||||
}
|
18
platforms/android/assets/www/cordova_plugins.js
vendored
@ -157,6 +157,20 @@ module.exports = [
|
||||
"cordova"
|
||||
],
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-device/www/device.js",
|
||||
"id": "cordova-plugin-device.device",
|
||||
"clobbers": [
|
||||
"device"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
|
||||
"id": "cordova-plugin-statusbar.statusbar",
|
||||
"clobbers": [
|
||||
"window.StatusBar"
|
||||
]
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
@ -165,7 +179,9 @@ module.exports.metadata =
|
||||
"cordova-plugin-whitelist": "1.2.2",
|
||||
"cordova-plugin-compat": "1.0.0",
|
||||
"cordova-plugin-ble-central": "1.1.0",
|
||||
"cordova-plugin-file": "4.2.0"
|
||||
"cordova-plugin-file": "4.2.0",
|
||||
"cordova-plugin-device": "1.1.2",
|
||||
"cordova-plugin-statusbar": "2.1.3"
|
||||
};
|
||||
// BOTTOM OF METADATA
|
||||
});
|
15
platforms/android/assets/www/css/custom.scss
Normal file
@ -0,0 +1,15 @@
|
||||
@import "app/libs/mui/src/sass/mui/colors";
|
||||
|
||||
|
||||
$mui-body-bg-color: mui-color('grey', '100');
|
||||
//$mui-accent-color: #bad649;
|
||||
$mui-accent-color: #004c6d;
|
||||
$mui-btn-accent-font-color: #004c6d;
|
||||
//$mui-accent-color-dark: mui-color('green', 'A100');
|
||||
$mui-accent-color-dark: #004c6d;
|
||||
$mui-accent-color-light: mui-color('green', 'A400');
|
||||
$mui-tab-font-color: rgba(255, 255, 255, 0.87);
|
||||
$mui-appbar-bg-color: #004c6d;
|
||||
|
||||
// import MUI SASS
|
||||
@import "app/libs/mui/src/sass/mui";
|
@ -33,20 +33,18 @@
|
||||
<meta name="msapplication-tap-highlight" content="no">
|
||||
<meta name="viewport"
|
||||
content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
|
||||
<link rel="stylesheet"
|
||||
href="http://fonts.googleapis.com/css?family=Ubuntu:300,400,500,700"
|
||||
type="text/css">
|
||||
<link href='https://fonts.googleapis.com/css?family=Ubuntu+Condensed'
|
||||
rel='stylesheet' type='text/css'>
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
|
||||
rel="stylesheet">
|
||||
<!-- build:fonts -->
|
||||
<link rel="stylesheet" href="fonts/fonts.css">
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:mui -->
|
||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||
<!-- endbuild -->
|
||||
<!-- build:css -->
|
||||
<link rel="stylesheet" href="fonts/fonts.css">
|
||||
<link href="css/mui.custom.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/app.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/ripple.css" rel="stylesheet" type="text/css"/>
|
||||
<link href="css/progress.css" rel="stylesheet" type="text/css"/>
|
||||
<!-- endbuild -->
|
||||
<title>Sensor Toy</title>
|
||||
</head>
|
||||
<body class="mui--no-user-select">
|
||||
@ -56,10 +54,6 @@
|
||||
<li class="mui--is-active"><a data-mui-toggle="tab"
|
||||
data-mui-controls="pane-default-1">Devices</a>
|
||||
</li>
|
||||
<!--<li><a data-mui-toggle="tab" data-mui-controls="pane-default-2">Tab-2</a>
|
||||
</li>
|
||||
<li><a data-mui-toggle="tab" data-mui-controls="pane-default-3">Tab-3</a>
|
||||
</li>-->
|
||||
</ul>
|
||||
</div>
|
||||
</header>
|
||||
@ -94,16 +88,24 @@
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="cordova.js"></script>
|
||||
|
||||
<!-- build:vendor -->
|
||||
<script type="text/javascript" src="libs/jquery/dist/jquery.js"></script>
|
||||
<script type="text/javascript" src="libs/mui/packages/cdn/js/mui.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="libs/bluebird/js/browser/bluebird.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:standards -->
|
||||
<script type="text/javascript"
|
||||
src="js/standards/bluetooth_company_identifiers.js"></script>
|
||||
<script type="text/javascript" src="js/standards/capability.js"></script>
|
||||
<script type="text/javascript" src="js/standards/battery.js"></script>
|
||||
<script type="text/javascript" src="js/standards/button.js"></script>
|
||||
<script type="text/javascript" src="js/mandecoder.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:cc2650 -->
|
||||
<script type="text/javascript"
|
||||
src="js/device/CC2650/cc2650_accelerometer.js"></script>
|
||||
<script type="text/javascript"
|
||||
@ -114,6 +116,10 @@
|
||||
src="js/device/CC2650/cc2650_thermopile.js"></script>
|
||||
<script type="text/javascript"
|
||||
src="js/device/CC2650/cc2650_humidity.js"></script>
|
||||
<!-- endbuild -->
|
||||
|
||||
<!-- build:js -->
|
||||
<script type="text/javascript" src="js/index.js"></script>
|
||||
<!-- endbuild -->
|
||||
</body>
|
||||
</html>
|
||||
|
@ -5,11 +5,12 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
var CC2650_ACCEL = function(p) {
|
||||
var CC2650_ACCEL;
|
||||
CC2650_ACCEL = function(p) {
|
||||
'use strict';
|
||||
this.name = 'Accelerometer';
|
||||
this.deviceID = p.deviceID || null;
|
||||
@ -17,159 +18,390 @@ var CC2650_ACCEL = function(p) {
|
||||
|
||||
this.capabilityID = 'F000AA80-0451-4000-B000-000000000000';
|
||||
this.serviceDef = {
|
||||
service: 'F000AA80-0451-4000-B000-000000000000',
|
||||
data: 'F000AA81-0451-4000-B000-000000000000', // Read/notify 3 bytes X : Y : Z
|
||||
notification: 'F0002902-0451-4000-B000-000000000000',
|
||||
configuration: 'F000AA82-0451-4000-B000-000000000000', // Read/write 1 byte
|
||||
period: 'F000AA83-0451-4000-B000-000000000000' // Read/write 1 byte Period = [Input*10]ms
|
||||
};
|
||||
service: 'F000AA80-0451-4000-B000-000000000000',
|
||||
data: 'F000AA81-0451-4000-B000-000000000000', // Read/notify 3 bytes X : Y : Z
|
||||
notification: 'F0002902-0451-4000-B000-000000000000',
|
||||
configuration: 'F000AA82-0451-4000-B000-000000000000', // Read/write 1 byte
|
||||
period: 'F000AA83-0451-4000-B000-000000000000' // Read/write 1 byte Period = [Input*10]ms
|
||||
};
|
||||
this.frames = {};
|
||||
|
||||
this.$id = {};
|
||||
this.$result = {};
|
||||
this.data = {
|
||||
gyro: {x: [], y: [], z: []},
|
||||
accel: {x: [], y: [], z: []},
|
||||
mag: {x: [], y: [], z: []}
|
||||
};
|
||||
|
||||
this.setFrame();
|
||||
|
||||
this.sensorMpu9250GyroConvert = function(data) {
|
||||
return data / (65536 / 500);
|
||||
};
|
||||
return (data * 1.0) / (65536 / 500);
|
||||
};
|
||||
|
||||
this.sensorMpu9250AccConvert = function(data) {
|
||||
// Change /2 to match accel range...i.e. 16 g would be /16
|
||||
return data / (32768 / 2);
|
||||
// Change /2 to match accel range...i.e. 16 g would be /16
|
||||
return (data * 1.0) / (32768 / 2);
|
||||
};
|
||||
|
||||
this.processData = function(data) {
|
||||
var a = new Int16Array(data);
|
||||
var calcData = {
|
||||
gyro: {
|
||||
x: this.sensorMpu9250GyroConvert(a[0]),
|
||||
y: this.sensorMpu9250GyroConvert(a[1]),
|
||||
z: this.sensorMpu9250GyroConvert(a[2])
|
||||
}, accel: {
|
||||
x: this.sensorMpu9250AccConvert(a[3]),
|
||||
y: this.sensorMpu9250AccConvert(a[4]),
|
||||
z: this.sensorMpu9250AccConvert(a[5])
|
||||
}, mag: {
|
||||
x: a[6], y: a[7], z: a[8]
|
||||
}
|
||||
};
|
||||
|
||||
return calcData;
|
||||
};
|
||||
this.onAccelerometerData = function(data) {
|
||||
// Console.log(data);
|
||||
var message;
|
||||
var a = new Int16Array(data);
|
||||
// Console.log(data);
|
||||
var message;
|
||||
var calcData;
|
||||
|
||||
//0 gyro x
|
||||
//1 gyro y
|
||||
//2 gyro z
|
||||
//3 accel x
|
||||
//4 accel y
|
||||
//5 accel z
|
||||
//6 mag x
|
||||
//7 mag y
|
||||
//8 mag z
|
||||
function gString(v) {
|
||||
return [v.toFixed(3),'G'].join('');
|
||||
}
|
||||
|
||||
// TODO get a template to line this up
|
||||
// TODO round or format numbers for better display
|
||||
message = 'Gyro <br/>' +
|
||||
'X: ' + this.sensorMpu9250GyroConvert(a[0]).toFixed(5) + '<br/>' +
|
||||
'Y: ' + this.sensorMpu9250GyroConvert(a[1]) + '<br/>' +
|
||||
'Z: ' + this.sensorMpu9250GyroConvert(a[2]) + '<br/>' +
|
||||
'Accel <br/>' +
|
||||
'X: ' + this.sensorMpu9250AccConvert(a[3]) + '<br/>' +
|
||||
'Y: ' + this.sensorMpu9250AccConvert(a[4]) + '<br/>' +
|
||||
'Z: ' + this.sensorMpu9250AccConvert(a[5]) + '<br/>' +
|
||||
'Mag <br/>' +
|
||||
'X: ' + a[3] + '<br/>' +
|
||||
'Y: ' + a[4] + '<br/>' +
|
||||
'Z: ' + a[5] + '<br/>' ;
|
||||
function aString(v) {
|
||||
return [v.toFixed(3),'\'/s'].join('');
|
||||
}
|
||||
|
||||
this.state = message;
|
||||
function mString(v) {
|
||||
return [v.toFixed(3),'mT'].join('');
|
||||
}
|
||||
calcData = this.processData(data);
|
||||
|
||||
this.$result[this.frames.gyroID + '-x'].text(this.sensorMpu9250GyroConvert(a[0]).toFixed(5));
|
||||
this.$result[this.frames.gyroID + '-y'].text(this.sensorMpu9250GyroConvert(a[1]).toFixed(5));
|
||||
this.$result[this.frames.gyroID + '-z'].text(this.sensorMpu9250GyroConvert(a[2]).toFixed(5));
|
||||
message = 'Gyro <br/>' + 'X: ' + calcData.gyro.x + '<br/>' + 'Y: ' + calcData.gyro.y + '<br/>' + 'Z: ' + calcData.gyro.z + '<br/>' + 'Accel <br/>' + 'X: ' + calcData.accel.x + '<br/>' + 'Y: ' + calcData.accel.y + '<br/>' + 'Z: ' + calcData.accel.z + '<br/>' + 'Mag <br/>' + 'X: ' + calcData.mag.x + '<br/>' + 'Y: ' + calcData.mag.y + '<br/>' + 'Z: ' + calcData.mag.z + '<br/>';
|
||||
|
||||
this.$result[this.frames.accelID + '-x'].text(this.sensorMpu9250AccConvert(a[3]).toFixed(5));
|
||||
this.$result[this.frames.accelID + '-y'].text(this.sensorMpu9250AccConvert(a[4]).toFixed(5));
|
||||
this.$result[this.frames.accelID + '-z'].text(this.sensorMpu9250AccConvert(a[5]).toFixed(5));
|
||||
this.state = message;
|
||||
|
||||
this.$result[this.frames.magID + '-x'].text(a[3]);
|
||||
this.$result[this.frames.magID + '-y'].text(a[4]);
|
||||
this.$result[this.frames.magID + '-z'].text(a[5]);
|
||||
this.$result[this.frames.gyroID + '-x'].text(gString(calcData.gyro.x));
|
||||
this.$result[this.frames.gyroID + '-y'].text(gString(calcData.gyro.y));
|
||||
this.$result[this.frames.gyroID + '-z'].text(gString(calcData.gyro.z));
|
||||
|
||||
// Console.log(this.state);
|
||||
};
|
||||
this.$result[this.frames.accelID + '-x'].text(aString(calcData.accel.x));
|
||||
this.$result[this.frames.accelID + '-y'].text(aString(calcData.accel.y));
|
||||
this.$result[this.frames.accelID + '-z'].text(aString(calcData.accel.z));
|
||||
|
||||
this.$result[this.frames.magID + '-x'].text(mString(calcData.mag.x));
|
||||
this.$result[this.frames.magID + '-y'].text(mString(calcData.mag.y));
|
||||
this.$result[this.frames.magID + '-z'].text(mString(calcData.mag.z));
|
||||
|
||||
this.data.gyro.x = this.storeData(calcData.gyro.x, this.data.gyro.x);
|
||||
this.data.gyro.y = this.storeData(calcData.gyro.y, this.data.gyro.y);
|
||||
this.data.gyro.z = this.storeData(calcData.gyro.z, this.data.gyro.z);
|
||||
|
||||
this.data.accel.x = this.storeData(calcData.accel.x, this.data.accel.x);
|
||||
this.data.accel.y = this.storeData(calcData.accel.y, this.data.accel.y);
|
||||
this.data.accel.z = this.storeData(calcData.accel.z, this.data.accel.z);
|
||||
|
||||
this.data.mag.x = this.storeData(calcData.mag.x, this.data.mag.x);
|
||||
this.data.mag.y = this.storeData(calcData.mag.y, this.data.mag.y);
|
||||
this.data.mag.z = this.storeData(calcData.mag.z, this.data.mag.z);
|
||||
|
||||
// Console.log(JSON.stringify(this.data));
|
||||
// Console.log(this.state);
|
||||
};
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
||||
console.log(this.serviceDef);
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
ble.startNotification(this.deviceID, this.serviceDef.service, this.serviceDef.data, this.onAccelerometerData.bind(this), this.onError);
|
||||
console.log('Starting CC2650 Accelerometer Service on ', this.deviceID);
|
||||
console.log(this.serviceDef);
|
||||
|
||||
// Turn accelerometer on
|
||||
var configData = new Uint16Array(1);
|
||||
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
||||
configData[0] = 0x007F;
|
||||
ble.write(this.deviceID, this.serviceDef.service, this.serviceDef.configuration, configData.buffer,
|
||||
function() { console.log('Started accelerometer.'); }, this.onError);
|
||||
this.setInternalID();
|
||||
this.insertFrame('gyro');
|
||||
this.insertFrame('accel');
|
||||
this.insertFrame('mag');
|
||||
|
||||
var periodData = new Uint8Array(1);
|
||||
periodData[0] = 0x0A;
|
||||
// Ble.write(deviceId, accelerometer.service, accelerometer.period, periodData.buffer,
|
||||
// function() { console.log("Configured accelerometer period."); },app.onError);
|
||||
ble.startNotification(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.data,
|
||||
this.onAccelerometerData.bind(this),
|
||||
this.onError);
|
||||
|
||||
// Turn accelerometer on
|
||||
var configData = new Uint16Array(1);
|
||||
// Turn on gyro, accel, and mag, 2G range, Disable wake on motion
|
||||
configData[0] = 0x007F;
|
||||
ble.write(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.configuration,
|
||||
configData.buffer,
|
||||
function() { console.log('Started accelerometer.'); },
|
||||
this.onError);
|
||||
|
||||
var periodData = new Uint8Array(1);
|
||||
periodData[0] = 0x0A;
|
||||
ble.write(this.deviceID,
|
||||
this.serviceDef.service,
|
||||
this.serviceDef.period,
|
||||
periodData.buffer,
|
||||
function() { console.log('Configured accelerometer period.'); },
|
||||
this.onError);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
this.advancedGraph = function(mode, data, subID) {
|
||||
|
||||
var lm;
|
||||
var ceiling;
|
||||
var elm;
|
||||
var text2ID;
|
||||
var ceilingLimit;
|
||||
var calcArray;
|
||||
var floor;
|
||||
var _subID;
|
||||
var _data;
|
||||
var text1ID;
|
||||
var lineID;
|
||||
var max;
|
||||
|
||||
|
||||
var parts = ['x', 'y', 'z'];
|
||||
|
||||
_data = data || this.data;
|
||||
|
||||
_subID = subID || '';
|
||||
|
||||
// LineID = [this.frameID , _subID , '-line'].join('');
|
||||
text1ID = [this.frameID, _subID, '-txt1'].join('');
|
||||
text2ID = [this.frameID, _subID, '-txt2'].join('');
|
||||
|
||||
if (_data.x.length > 0) {
|
||||
|
||||
max = 2;
|
||||
|
||||
for (var lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||
lm = parts[lineMode];
|
||||
ceiling = _data[lm].reduce(function(p, v) {
|
||||
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||
});
|
||||
|
||||
|
||||
if (ceiling > 500) {
|
||||
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 50) * 50) : max;
|
||||
} else {
|
||||
max = (ceiling > max) ? (Math.ceil((Math.round(ceiling) + 1) / 10) * 10) : max;
|
||||
}
|
||||
}
|
||||
|
||||
ceiling = max;
|
||||
|
||||
floor = ceiling * -1;
|
||||
ceilingLimit = ceiling;
|
||||
|
||||
var scalePos = (124 / 2) / ceiling;
|
||||
var scaleNeg = (124 / 2) / floor;
|
||||
var xstep = (680 - 46) / 100;
|
||||
|
||||
//Var xstep = 2.34;
|
||||
|
||||
for (lineMode = 0; lineMode < parts.length; lineMode++) {
|
||||
|
||||
lm = parts[lineMode];
|
||||
var startX = 46 + (100 - _data[lm].length) * xstep;
|
||||
|
||||
calcArray = [];
|
||||
|
||||
lineID = this.frameID + _subID + '-' + lm + '-line';
|
||||
for (var x = 0; x < _data[lm].length; x++) {
|
||||
|
||||
calcArray.push((startX + (x * xstep)).toFixed(2) + ',' + (71 - ((_data[lm][x]) * scalePos)).toFixed(
|
||||
2));
|
||||
|
||||
}
|
||||
|
||||
elm = document.getElementById(lineID);
|
||||
|
||||
elm.setAttribute('points', calcArray.join(' '));
|
||||
|
||||
}
|
||||
|
||||
elm = document.getElementById(text1ID);
|
||||
elm.textContent = ceilingLimit;
|
||||
|
||||
elm = document.getElementById(text2ID);
|
||||
elm.textContent = floor;
|
||||
|
||||
this.setInternalID();
|
||||
this.insertFrame('gyro');
|
||||
this.insertFrame('accel');
|
||||
this.insertFrame('mag');
|
||||
}
|
||||
|
||||
this.previousCeil = ceiling;
|
||||
};
|
||||
|
||||
this.animateGraph = function() {
|
||||
// Nothing to animate yet
|
||||
// Nothing to animate yet
|
||||
|
||||
return -1;
|
||||
};
|
||||
// return -1;
|
||||
this.advancedGraph(0, this.data.gyro, 'gyro');
|
||||
this.advancedGraph(0, this.data.accel, 'accel');
|
||||
this.advancedGraph(0, this.data.mag, 'mag');
|
||||
// This.simpleGraph(this.data.temp, 'temp');
|
||||
// this.simpleGraph(this.data.pressure, 'pressure');
|
||||
|
||||
};
|
||||
|
||||
this.generateBlankGraphBase = function(subID, settings) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
|
||||
var svgID = this.frameID + _subID + '-svg';
|
||||
var text1ID = this.frameID + _subID + '-txt1';
|
||||
var text2ID = this.frameID + _subID + '-txt2';
|
||||
|
||||
var _width = settings.width || 300;
|
||||
var _height = settings.height || 150;
|
||||
var _fill = settings.fill || 'blue';
|
||||
|
||||
var svg = document.createElementNS(xmlns, 'svg');
|
||||
|
||||
svg.setAttribute('id', svgID);
|
||||
// Svg.setAttribute(xmlns, 'version', '1.1');
|
||||
svg.setAttribute('width', _width.toString());
|
||||
svg.setAttribute('height', _height.toString());
|
||||
svg.setAttribute('fill', _fill);
|
||||
|
||||
|
||||
svg.setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xlink', 'http://www.w3.org/1999/xlink');
|
||||
|
||||
svg.setAttributeNS(xmlns, 'viewBox', '0 0 700 150');
|
||||
// Svg.setAttributeNS(xmlns, 'style', 'width:700px;height:150px;');
|
||||
|
||||
|
||||
svg = this.graphAddXAxis(svg, {y: 12, x2: 680, colour: '#004c6d', id: text1ID});
|
||||
svg = this.graphAddXAxis(svg, {y: 136, x2: 680, colour: '#004c6d', id: text2ID});
|
||||
svg = this.graphAddXAxis(svg, {y: 71, x2: 680, colour: '#004c6d', text: '0'});
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
this.generateBlankGraph = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xlineID = this.frameID + _subID + '-x-line';
|
||||
var ylineID = this.frameID + _subID + '-y-line';
|
||||
var zlineID = this.frameID + _subID + '-z-line';
|
||||
|
||||
var svg = this.generateBlankGraphBase(_subID,{width: '700',height: 150});
|
||||
|
||||
svg = this.graphAddLine(svg, xlineID, 'rgba(255,0,0,0.5)');
|
||||
svg = this.graphAddLine(svg, ylineID, 'rgba(0,255,0,0.5)');
|
||||
svg = this.graphAddLine(svg, zlineID, 'rgba(0,0,255,0.5)');
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
this.startCalibrate = function() {
|
||||
console.log('Start calibrate');
|
||||
|
||||
alert('Mag Calibration: Wave device in a figure eight until done!');
|
||||
};
|
||||
|
||||
this.insertFrame = function(mode) {
|
||||
|
||||
var frame;
|
||||
var title;
|
||||
var modeID = mode + 'ID';
|
||||
this.frames[modeID] = this.frameID + '-' + mode;
|
||||
var frame;
|
||||
var title;
|
||||
var modeID = mode + 'ID';
|
||||
this.frames[modeID] = this.frameID + '-' + mode;
|
||||
|
||||
var titles = {gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'};
|
||||
|
||||
console.log('FrameID: ' , this.frames[modeID]);
|
||||
|
||||
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
||||
|
||||
frame = $('<div />', {
|
||||
class: 'mui-panel', id: this.frames[modeID]
|
||||
});
|
||||
|
||||
$('<div />', { class: 'mui-row'}).append($('<div />', { class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title})).appendTo(frame);
|
||||
|
||||
this.$frame.append(frame);
|
||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||
|
||||
// Call the parent displayForm first...
|
||||
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'X'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Y'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Z'}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-x' }).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-y'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', text: '--', id: this.frames[modeID] + '-z'}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
this.$result[this.frames[modeID] + '-x'] = $('#' + this.frames[modeID] + '-x');
|
||||
this.$result[this.frames[modeID] + '-y'] = $('#' + this.frames[modeID] + '-y');
|
||||
this.$result[this.frames[modeID] + '-z'] = $('#' + this.frames[modeID] + '-z');
|
||||
var titles = {
|
||||
gyro: 'Gyroscope', accel: 'Accelerometer', mag: 'Magnetometer'
|
||||
};
|
||||
var modes = ['gyro', 'accel', 'mag'];
|
||||
|
||||
console.log('FrameID: ', this.frames[modeID]);
|
||||
|
||||
title = [titles[mode], ' - ', this.deviceID].join(' ');
|
||||
|
||||
frame = $('<div />', {
|
||||
class: 'mui-panel', id: this.frames[modeID]
|
||||
});
|
||||
|
||||
if (mode === 'mag') {
|
||||
var elm = $('<div />', {class: 'mui-row'});
|
||||
var button = $('<button />',{class: 'mui-btn mui-btn--raised', id: modeID + '-cal', text: 'Calibrate', click: this.startCalibrate.bind(this)});
|
||||
|
||||
elm.append($('<div />', { class: 'mui-col-xs-8 mui--text-title mui-ellipsis-2', text: title}));
|
||||
|
||||
elm.append($('<div />', {class: 'mui-col-xs-4 mui--text-right'}).append(button));
|
||||
|
||||
frame.append(elm);
|
||||
|
||||
} else {
|
||||
$('<div />', {class: 'mui-row'}).append($('<div />', {
|
||||
class: 'mui-col-xs-12 mui--text-title mui-ellipsis-2', text: title
|
||||
})).appendTo(frame);
|
||||
|
||||
}
|
||||
this.$frame.append(frame);
|
||||
this.$id[modeID] = $('#' + this.frames[modeID]);
|
||||
|
||||
// Call the parent displayForm first...
|
||||
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'X'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Y'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-accent mui--text-center', text: 'Z'
|
||||
}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-x'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-y'
|
||||
}).appendTo(row);
|
||||
$('<div />', {
|
||||
class: 'mui-col-xs-4 mui--text-dark mui--text-center',
|
||||
text: '--',
|
||||
id: this.frames[modeID] + '-z'
|
||||
}).appendTo(row);
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
|
||||
this.$result[this.frames[modeID] + '-x'] = $('#' + this.frames[modeID] + '-x');
|
||||
this.$result[this.frames[modeID] + '-y'] = $('#' + this.frames[modeID] + '-y');
|
||||
this.$result[this.frames[modeID] + '-z'] = $('#' + this.frames[modeID] + '-z');
|
||||
|
||||
row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
var _graph = this.generateBlankGraph(mode);
|
||||
row.append($('<div>', {class: 'mui-col-sm-12'}).append(_graph));
|
||||
|
||||
this.$id[modeID].append(row);
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
||||
inheritsFrom(CC2650_ACCEL, CAPABILITY);
|
||||
|
||||
capabilityManager.register({id:'F000AA80-0451-4000-B000-000000000000', module:CC2650_ACCEL});
|
||||
capabilityManager.register({id: 'F000AA80-0451-4000-B000-000000000000', module: CC2650_ACCEL});
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -29,7 +29,7 @@ var CC2650_BAR = function(p) {
|
||||
this.setFrame();
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Barometer Service on ', this.deviceID);
|
||||
@ -38,7 +38,7 @@ var CC2650_BAR = function(p) {
|
||||
|
||||
ble.startNotification(this.deviceID, this.serviceDef.service, this.serviceDef.data, this.onBarometerData.bind(this), this.onError);
|
||||
|
||||
//Turn on barometer
|
||||
// Turn on barometer
|
||||
var barometerConfig = new Uint8Array(1);
|
||||
barometerConfig[0] = 0x01;
|
||||
ble.write(this.deviceID, this.serviceDef.service, this.serviceDef.configuration, barometerConfig.buffer,
|
||||
@ -59,8 +59,8 @@ var CC2650_BAR = function(p) {
|
||||
var message;
|
||||
var a = new Uint8Array(data);
|
||||
|
||||
//0-2 Temp
|
||||
//3-5 Pressure
|
||||
// 0-2 Temp
|
||||
// 3-5 Pressure
|
||||
var temp, pressure;
|
||||
temp = this.sensorBarometerConvert(a[0] | (a[1] << 8) | (a[2] << 16));
|
||||
pressure = this.sensorBarometerConvert(a[3] | (a[4] << 8) | (a[5] << 16));
|
||||
@ -101,29 +101,56 @@ var CC2650_BAR = function(p) {
|
||||
var pressure = this.frameID + '-p';
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent', text: 'Pressure:'}).appendTo(row);
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Pressure:'}).appendTo(row);
|
||||
|
||||
$('<div />', { class: 'mui-col-xs-3 mui--text-dark', id: pressure}).appendTo(row);
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{text:'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>',{class: 'tabOnWhite'}).append($('<a>',{text:'Pressure','data-mui-toggle': 'tab', 'data-mui-controls': (pressure + '-pane')})).appendTo(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
this.$id.append(tabBody);
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('pressure'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
this.$id.append($('<div>',{'class':'mui-tabs__pane mui--is-active',id:(temp + '-pane')}).append(blankChart));
|
||||
} else {
|
||||
|
||||
blankChart = this.generateBlankGraph('pressure');
|
||||
var tabBody = $('<ul>',
|
||||
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Pressure',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (pressure + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
|
||||
this.$id.append($('<div>',{'class':'mui-tabs__pane',id:(pressure + '-pane')}).append(blankChart));
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
|
||||
blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('pressure');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{
|
||||
class: 'mui-tabs__pane',
|
||||
id: (pressure + '-pane')
|
||||
}).append(blankChart));
|
||||
}
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.pressure = $('#' + pressure);
|
||||
|
||||
@ -134,4 +161,4 @@ var CC2650_BAR = function(p) {
|
||||
|
||||
inheritsFrom(CC2650_BAR, CAPABILITY);
|
||||
|
||||
capabilityManager.register({id:'F000AA40-0451-4000-B000-000000000000', module:CC2650_BAR});
|
||||
capabilityManager.register({id: 'F000AA40-0451-4000-B000-000000000000', module: CC2650_BAR});
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager, device */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -29,7 +29,7 @@ var CC2650_HUM = function(p) {
|
||||
this.setFrame();
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Humidity Service on ', this.deviceID);
|
||||
@ -42,7 +42,7 @@ var CC2650_HUM = function(p) {
|
||||
this.onHumidityData.bind(this),
|
||||
this.onError);
|
||||
|
||||
//Turn on barometer
|
||||
// Turn on barometer
|
||||
var humidityConfig = new Uint8Array(1);
|
||||
humidityConfig[0] = 0x01;
|
||||
ble.write(this.deviceID,
|
||||
@ -63,17 +63,17 @@ var CC2650_HUM = function(p) {
|
||||
var message;
|
||||
var raw = new Uint16Array(data);
|
||||
|
||||
//-- calculate temperature [°C]
|
||||
// -- calculate temperature [°C]
|
||||
var temp = (raw[0] / 65536) * 165 - 40;
|
||||
|
||||
//-- calculate relative humidity [%RH]
|
||||
// -- calculate relative humidity [%RH]
|
||||
var hum = (raw[1] / 65536) * 100;
|
||||
|
||||
tStr = temp.toFixed(2) + '°C';
|
||||
hStr = hum.toFixed(2) + '%RH';
|
||||
|
||||
message = 'Temperature <br/>' + tStr + 'Humidity <br/>' + hStr;
|
||||
|
||||
|
||||
this.data.temp = this.storeData(temp, this.data.temp);
|
||||
this.data.humidity = this.storeData(hum, this.data.humidity);
|
||||
|
||||
@ -105,13 +105,13 @@ var CC2650_HUM = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
$('<div />',
|
||||
{
|
||||
class: 'mui-col-xs-3 mui--text-accent',
|
||||
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
|
||||
text: 'Humidity:'
|
||||
}).appendTo(row);
|
||||
|
||||
@ -120,18 +120,44 @@ var CC2650_HUM = function(p) {
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{text: 'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>',{class: 'tabOnWhite'}).append($('<a>',{text: 'Humidity','data-mui-toggle': 'tab', 'data-mui-controls': (humidity + '-pane')})).appendTo(tabBody);
|
||||
this.$id.append(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('humidity'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('humidity');
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (humidity + '-pane')}).append(blankChart));
|
||||
} else {
|
||||
var tabBody = $('<ul>',
|
||||
{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>', {class: 'mui--is-active tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',
|
||||
{
|
||||
text: 'Humidity',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (humidity + '-pane')
|
||||
})).appendTo(tabBody);
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',
|
||||
{class: 'mui-tabs__pane mui--is-active', id: (temp + '-pane')}).append(
|
||||
blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('humidity');
|
||||
this.$id.append($('<div>',
|
||||
{
|
||||
class: 'mui-tabs__pane',
|
||||
id: (humidity + '-pane')
|
||||
}).append(blankChart));
|
||||
}
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.humidity = $('#' + humidity);
|
||||
|
||||
@ -141,4 +167,4 @@ var CC2650_HUM = function(p) {
|
||||
|
||||
inheritsFrom(CC2650_HUM, CAPABILITY);
|
||||
|
||||
capabilityManager.register({id:'F000AA20-0451-4000-B000-000000000000', module:CC2650_HUM});
|
||||
capabilityManager.register({id: 'F000AA20-0451-4000-B000-000000000000', module: CC2650_HUM});
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -30,7 +30,7 @@ var CC2650_LUX = function(p) {
|
||||
this.setFrame();
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Luxometer Service on ', this.deviceID);
|
||||
@ -43,7 +43,7 @@ var CC2650_LUX = function(p) {
|
||||
this.onLuxData.bind(this),
|
||||
this.onError);
|
||||
|
||||
//Turn on luxometer
|
||||
// Turn on luxometer
|
||||
var luxConfig = new Uint8Array(1);
|
||||
luxConfig[0] = 0x01;
|
||||
ble.write(this.deviceID,
|
||||
@ -91,7 +91,7 @@ var CC2650_LUX = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-4 mui--text-accent', text: 'Luminosity:'}).appendTo(
|
||||
{class: 'mui-col-xs-4 mui--text-accent mui--text-right', text: 'Luminosity:'}).appendTo(
|
||||
row);
|
||||
|
||||
$('<div />',
|
||||
@ -110,4 +110,4 @@ var CC2650_LUX = function(p) {
|
||||
};
|
||||
|
||||
inheritsFrom(CC2650_LUX, CAPABILITY);
|
||||
capabilityManager.register({id:'F000AA70-0451-4000-B000-000000000000', module:CC2650_LUX});
|
||||
capabilityManager.register({id: 'F000AA70-0451-4000-B000-000000000000', module: CC2650_LUX});
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -30,7 +30,7 @@ var CC2650_TMP = function(p) {
|
||||
this.setFrame();
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting CC2650 Thermopile Service on ', this.deviceID);
|
||||
@ -43,7 +43,7 @@ var CC2650_TMP = function(p) {
|
||||
this.onThermData.bind(this),
|
||||
this.onError);
|
||||
|
||||
//Turn on thermopile
|
||||
// Turn on thermopile
|
||||
var tmpConfig = new Uint8Array(1);
|
||||
tmpConfig[0] = 0x01;
|
||||
ble.write(this.deviceID,
|
||||
@ -83,7 +83,7 @@ var CC2650_TMP = function(p) {
|
||||
|
||||
this.$result.temp.text(tStr);
|
||||
this.$result.ambient.text(aStr);
|
||||
|
||||
|
||||
};
|
||||
|
||||
this.animateGraph = function() {
|
||||
@ -91,10 +91,10 @@ var CC2650_TMP = function(p) {
|
||||
this.simpleGraph(this.data.ambient, 'ambient');
|
||||
};
|
||||
|
||||
|
||||
|
||||
this.insertFrame = function() {
|
||||
|
||||
var liSetting;
|
||||
var tabBody;
|
||||
var blankChart;
|
||||
var self = this;
|
||||
// Console.log('Overloading...');
|
||||
@ -107,13 +107,13 @@ var CC2650_TMP = function(p) {
|
||||
var row = $('<div />', {class: 'mui-row'});
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-accent', text: 'Temp:'}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-accent mui--text-right', text: 'Temp:'}).appendTo(row);
|
||||
|
||||
$('<div />',
|
||||
{class: 'mui-col-xs-3 mui--text-dark', id: temp}).appendTo(row);
|
||||
{class: 'mui-col-xs-3 mui--text-dark mui--text-left', id: temp}).appendTo(row);
|
||||
$('<div />',
|
||||
{
|
||||
class: 'mui-col-xs-3 mui--text-accent',
|
||||
class: 'mui-col-xs-3 mui--text-accent mui--text-right',
|
||||
text: 'Ambient:'
|
||||
}).appendTo(row);
|
||||
|
||||
@ -122,19 +122,38 @@ var CC2650_TMP = function(p) {
|
||||
|
||||
this.$id.append(row);
|
||||
|
||||
var tabBody = $('<ul>',{class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',{ text: 'Temperature','data-mui-toggle': 'tab', 'data-mui-controls': (temp + '-pane')})).appendTo(tabBody);
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',{ text: 'Ambient','data-mui-toggle': 'tab', 'data-mui-controls': (amb + '-pane')})).appendTo(tabBody);
|
||||
if (/ipad/i.test(device.model)) {
|
||||
|
||||
this.$id.append(tabBody);
|
||||
tabBody = $('<div>', {class: 'mui-row'});
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('temp'))) ;
|
||||
tabBody.append($('<div>',{class: 'mui-col-md-6'}).append(this.generateBlankGraph('ambient'))) ;
|
||||
this.$id.append(tabBody);
|
||||
|
||||
} else {
|
||||
tabBody = $('<ul>', {class: 'mui-tabs__bar mui-tabs__bar--justified'});
|
||||
liSetting = {
|
||||
text: 'Temperature',
|
||||
'data-mui-toggle': 'tab',
|
||||
'data-mui-controls': (temp + '-pane')
|
||||
};
|
||||
$('<li>',{class: 'mui--is-active tabOnWhite'}).append($('<a>',liSetting)).appendTo(tabBody);
|
||||
liSetting = { text: 'Ambient','data-mui-toggle': 'tab', 'data-mui-controls': (amb + '-pane')};
|
||||
$('<li>', {class: 'tabOnWhite'}).append($('<a>',liSetting)).appendTo(tabBody);
|
||||
|
||||
this.$id.append(tabBody);
|
||||
|
||||
blankChart = this.generateBlankGraph('temp');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('ambient');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (amb + '-pane')}).append(blankChart));
|
||||
}
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane mui--is-active',id: (temp + '-pane')}).append(blankChart));
|
||||
|
||||
blankChart = this.generateBlankGraph('ambient');
|
||||
|
||||
this.$id.append($('<div>',{class: 'mui-tabs__pane',id: (amb + '-pane')}).append(blankChart));
|
||||
|
||||
this.$result.temp = $('#' + temp);
|
||||
this.$result.ambient = $('#' + amb);
|
||||
|
@ -17,38 +17,39 @@
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/* global BATTERY, BUTTON, bt_company_ids, ble, LocalFileSystem, capabilityManager */
|
||||
/* global mui, bt_company_ids, ble, LocalFileSystem, capabilityManager, MANUFACTUREDECODER */
|
||||
|
||||
var app = {
|
||||
stop: false,
|
||||
log: {},
|
||||
activeServices: {},
|
||||
var app;
|
||||
app = {
|
||||
mode: 0, stop: false, log: {}, activeServices: {},
|
||||
|
||||
list: {},
|
||||
foundDevices: {},
|
||||
list: {}, foundDevices: {},
|
||||
|
||||
manufactureDecoder: new MANUFACTUREDECODER(),
|
||||
// Application Constructor
|
||||
manufactureDecoder: new MANUFACTUREDECODER(), // Application Constructor
|
||||
initialize: function() {
|
||||
this.bindEvents();
|
||||
},
|
||||
|
||||
arrayBufferToIntArray: function(buffer) {
|
||||
var result;
|
||||
var result;
|
||||
|
||||
if (buffer) {
|
||||
var typedArray = new Uint8Array(buffer);
|
||||
result = [];
|
||||
for (var i = 0; i < typedArray.length; i++) {
|
||||
result[i] = typedArray[i];
|
||||
}
|
||||
if (buffer) {
|
||||
var typedArray = new Uint8Array(buffer);
|
||||
result = [];
|
||||
for (var i = 0; i < typedArray.length; i++) {
|
||||
result[i] = typedArray[i];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
},
|
||||
return result;
|
||||
},
|
||||
|
||||
parseAdvertisingData: function(bytes) {
|
||||
var length, type, data, i = 0, advertisementData = {};
|
||||
var length;
|
||||
var type;
|
||||
var data;
|
||||
var i = 0;
|
||||
var advertisementData = {};
|
||||
|
||||
while (length !== 0) {
|
||||
|
||||
@ -66,8 +67,7 @@ var app = {
|
||||
}
|
||||
|
||||
return advertisementData;
|
||||
},
|
||||
handle255: function(buffer) {
|
||||
}, handle255: function(buffer) {
|
||||
'use strict';
|
||||
|
||||
var company;
|
||||
@ -77,12 +77,6 @@ var app = {
|
||||
var decoded = {};
|
||||
|
||||
console.log('Block255', bin);
|
||||
var manSpec = bin.map(function(i) {
|
||||
|
||||
return i.toString(16) + ' ';
|
||||
});
|
||||
|
||||
console.log('manSpec: ', manSpec);
|
||||
manID = app.manufactureDecoder.getManID(bin);
|
||||
|
||||
console.log('ManID:', manID);
|
||||
@ -92,7 +86,7 @@ var app = {
|
||||
company = bt_company_ids.find(cid);
|
||||
|
||||
switch (manID) {
|
||||
case '004c': {
|
||||
case '004C': {
|
||||
decoded = app.manufactureDecoder.decodeIbeacon(bin);
|
||||
decoded.company = company;
|
||||
break;
|
||||
@ -116,60 +110,97 @@ var app = {
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
},
|
||||
makeHexBuffer: function(buffer) {
|
||||
}, makeHexBuffer: function(buffer) {
|
||||
'use strict';
|
||||
var hexBuffer = buffer.map(function(i) {
|
||||
return ('00' + i.toString(16)).slice(-2) + ',';
|
||||
});
|
||||
return hexBuffer;
|
||||
},
|
||||
makeChars: function(buffer) {
|
||||
return buffer.map(function(i) {
|
||||
return ('00' + i.toString(16)).slice(-2) + ',';
|
||||
});
|
||||
}, makeChars: function(buffer) {
|
||||
'use strict';
|
||||
var output = buffer.map(function(i) {
|
||||
return buffer.map(function(i) {
|
||||
return String.fromCharCode(i);
|
||||
});
|
||||
}, calculateDistance: function(txPower, rssi) {
|
||||
|
||||
return String.fromCharCode(i);
|
||||
});
|
||||
// If there is 0 txPower then default it to -12dBm which appears to be a general default.
|
||||
|
||||
var _txPower = (txPower !== 0) ? txPower : -12;
|
||||
|
||||
var ratio_db = _txPower - rssi;
|
||||
var ratio_linear = Math.pow(10, ratio_db / 10);
|
||||
|
||||
return Math.sqrt(ratio_linear);
|
||||
|
||||
}, /**
|
||||
*
|
||||
* @param device
|
||||
* @param device.rssi
|
||||
* @param device.otherData
|
||||
* @param device.id
|
||||
* @param device.name
|
||||
* @param device.rssiBuffer
|
||||
* @returns {jQuery|HTMLElement|*}
|
||||
*/
|
||||
|
||||
return output;
|
||||
},
|
||||
buildNewDeviceResultPanel: function(device) {
|
||||
'use strict';
|
||||
var dString;
|
||||
var accuracy;
|
||||
var avg;
|
||||
var sum;
|
||||
var newPanel, newRow;
|
||||
var otherData = device.otherData;
|
||||
var newId = 'd-' + device.id.replace(/:/g, '');
|
||||
var newId = 'd-' + device.id.replace(/:/g, '').split('-')[0];
|
||||
var title = device.hasOwnProperty('name') ? device.name : '*** Unknown';
|
||||
|
||||
newPanel = $('<div>',{id: newId,class: 'mui-panel deviceRow', style: 'min-height:75px;'});
|
||||
newPanel = $('<div>',
|
||||
{id: newId, class: 'mui-panel deviceRow', style: 'min-height:75px;'});
|
||||
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-12 mui--text-title',text: device.id}));
|
||||
newRow.append($('<div>',
|
||||
{class: 'mui-col-xs-12 mui--text-title', text: device.id}));
|
||||
|
||||
newPanel.append(newRow);
|
||||
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Name:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: title}));
|
||||
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'Title:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: title}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'RSSI:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: device.rssi}));
|
||||
if (typeof otherData !== 'undefined' && otherData !== null && otherData.hasOwnProperty(
|
||||
'txpower')) {
|
||||
if (device.hasOwnProperty('rssiBuffer') && (device.rssiBuffer.length > 0)) {
|
||||
sum = device.rssiBuffer.reduce(function(a, b) { return a + b; });
|
||||
avg = sum / device.rssiBuffer.length;
|
||||
accuracy = app.calculateDistance(otherData.txpower, avg);
|
||||
} else {
|
||||
accuracy = app.calculateDistance(otherData.txpower, device.rssi);
|
||||
}
|
||||
|
||||
dString = (accuracy <= 30.00) ? accuracy.toFixed(2) + ' m' : 'Far';
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Distance:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: dString}));
|
||||
|
||||
} else {
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'RSSI:'}));
|
||||
newRow.append($('<div>',
|
||||
{class: 'mui-col-xs-3', text: device.rssi + ' dB'}));
|
||||
|
||||
}
|
||||
|
||||
newPanel.append(newRow);
|
||||
|
||||
if (typeof otherData !== 'undefined' && otherData !== null) {
|
||||
if (otherData.hasOwnProperty('msg')) {
|
||||
newRow = $('<div>',{class: 'mui-row'});
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-3',text: 'Data:'}));
|
||||
newRow.append($('<div>',{class: 'mui-col-xs-8',text: otherData.msg}));
|
||||
newRow = $('<div>', {class: 'mui-row'});
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-3', text: 'Details:'}));
|
||||
newRow.append($('<div>', {class: 'mui-col-xs-8', text: otherData.msg}));
|
||||
newPanel.append(newRow);
|
||||
}
|
||||
}
|
||||
|
||||
return newPanel;
|
||||
},
|
||||
extractPData: function(prev) {
|
||||
}, extractPData: function(prev) {
|
||||
'use strict';
|
||||
|
||||
if (typeof prev === 'undefined' || prev === null) {
|
||||
@ -177,13 +208,21 @@ var app = {
|
||||
}
|
||||
return prev.pData;
|
||||
|
||||
}, extractRSSIBuffer: function(prev) {
|
||||
'use strict';
|
||||
|
||||
if (typeof prev === 'undefined' || prev === null) {
|
||||
return [];
|
||||
}
|
||||
return prev.rssiBuffer;
|
||||
|
||||
},
|
||||
|
||||
processPData: function(newData, oldData) {
|
||||
'use strict';
|
||||
var output = {};
|
||||
var wa = [];
|
||||
if (newData.data === null) {
|
||||
if (newData === null || newData.data === null) {
|
||||
return {};
|
||||
}
|
||||
|
||||
@ -206,169 +245,200 @@ var app = {
|
||||
}
|
||||
|
||||
return output;
|
||||
},
|
||||
doScan: function(mode) {
|
||||
}, processRSSIData: function(rssi, oldBuffer) {
|
||||
'use strict';
|
||||
if (typeof oldBuffer === 'undefined' || oldBuffer === null) {
|
||||
return [];
|
||||
}
|
||||
var wa = oldBuffer;
|
||||
|
||||
$('#ripple').show();
|
||||
if (mode !== 2) {
|
||||
$('#tbody').empty();
|
||||
if (wa.length === 10) {
|
||||
wa = wa.slice(1);
|
||||
}
|
||||
|
||||
var otherData = null;
|
||||
var msgText = '';
|
||||
ble.startScan([], function(device) {
|
||||
var parsed;
|
||||
var hexBuffer;
|
||||
var advertBuffer;
|
||||
var newTR;
|
||||
var newId;
|
||||
var _device = device;
|
||||
var $newID;
|
||||
wa.push(rssi);
|
||||
|
||||
_device.pData = {};
|
||||
|
||||
otherData = null;
|
||||
msgText = '';
|
||||
// console.log(JSON.stringify(_device));
|
||||
|
||||
newId = 'd-' + _device.id.replace(/:/g, '');
|
||||
console.log(newId);
|
||||
|
||||
this.list[newId] = _device.id;
|
||||
|
||||
if (_device.hasOwnProperty('advertising')) {
|
||||
|
||||
advertBuffer = app.arrayBufferToIntArray(_device.advertising);
|
||||
|
||||
hexBuffer = app.makeHexBuffer(advertBuffer);
|
||||
|
||||
parsed = app.parseAdvertisingData(advertBuffer);
|
||||
|
||||
// Console.log(parsed);
|
||||
|
||||
if (parsed.hasOwnProperty('9')) {
|
||||
|
||||
var name = app.makeChars(parsed['9']);
|
||||
|
||||
_device.name = name.join('');
|
||||
console.log('Name: ', name.join(''));
|
||||
|
||||
}
|
||||
|
||||
if (parsed.hasOwnProperty('255')) {
|
||||
|
||||
otherData = app.handle255(parsed['255']);
|
||||
console.log(otherData);
|
||||
_device.otherData = otherData;
|
||||
}
|
||||
_device.advertBuffer = advertBuffer;
|
||||
_device.hexBuffer = hexBuffer;
|
||||
_device.parsed = parsed;
|
||||
return wa;
|
||||
}, doScan: function(mode) {
|
||||
'use strict';
|
||||
app.mode = mode;
|
||||
$('#ripple').show();
|
||||
if (mode !== 2) {
|
||||
$('#tbody').empty();
|
||||
}
|
||||
|
||||
newTR = app.buildNewDeviceResultPanel(device);
|
||||
ble.startScan([], app.foundDevice.bind(this), function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
$newID = $('div#' + newId);
|
||||
if ($newID.length > 0) {
|
||||
$newID.replaceWith(newTR);
|
||||
} else {
|
||||
$('#scanResults').append(newTR);
|
||||
}
|
||||
var _t = [5000, 60000, 200][mode];
|
||||
|
||||
// $('#output').append(JSON.stringify(device) + '<br/>');
|
||||
|
||||
var oldPdata = app.extractPData(app.log[newId]);
|
||||
|
||||
var newPData = app.processPData(otherData, oldPdata);
|
||||
|
||||
// console.log(newPData);
|
||||
_device.pData = newPData;
|
||||
|
||||
app.log[newId] = _device;
|
||||
app.foundDevices[newId] = _device;
|
||||
|
||||
// console.log(JSON.stringify(_device));
|
||||
|
||||
}.bind(this), function(e) {
|
||||
console.error(e);
|
||||
});
|
||||
|
||||
var _t = [5000,60000,200][mode];
|
||||
|
||||
setTimeout(ble.stopScan,
|
||||
_t,
|
||||
function() { console.log('Scan complete');
|
||||
|
||||
if (mode === 1) {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
if (mode === 2) {
|
||||
if (!app.stop) {
|
||||
setTimeout(function() {
|
||||
app.doScan(2);
|
||||
}.bind(this), 200);
|
||||
} else {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
function() { console.log('stopScan failed');
|
||||
setTimeout(ble.stopScan, _t, app.scanComplete, function() {
|
||||
console.log('stopScan failed');
|
||||
$('#ripple').hide();
|
||||
});
|
||||
|
||||
}, populateObject: function(source, dest) {
|
||||
var rObj = dest;
|
||||
for (var item in source) {
|
||||
if (source.hasOwnProperty(item)) {
|
||||
rObj[item] = source[item];
|
||||
}
|
||||
}
|
||||
|
||||
return rObj;
|
||||
},
|
||||
writeFile: function(fileEntry, dataObj) {
|
||||
// Create a FileWriter object for our FileEntry (log.txt).
|
||||
fileEntry.createWriter(function(fileWriter) {
|
||||
/**
|
||||
*
|
||||
* @param device
|
||||
* @param device.advertising
|
||||
* @param device.rssi
|
||||
* @param device.id
|
||||
*/
|
||||
|
||||
fileWriter.onwriteend = function() {
|
||||
console.log('Successful file write...');
|
||||
// ReadFile(fileEntry);
|
||||
};
|
||||
foundDevice: function(device) {
|
||||
var rssiBuffer;
|
||||
var oldRSSIBuffer;
|
||||
var newPData;
|
||||
var oldPdata;
|
||||
var parsed;
|
||||
var hexBuffer;
|
||||
var advertBuffer;
|
||||
var newTR;
|
||||
var newId = 'd-' + device.id.replace(/:/g, '').split('-')[0];
|
||||
var _device = app.foundDevices[newId] || {};
|
||||
var $newID;
|
||||
var otherData;
|
||||
|
||||
fileWriter.onerror = function(e) {
|
||||
console.error('Failed file write: ' + e.toString());
|
||||
};
|
||||
_device = app.populateObject(device, _device);
|
||||
// _device.pData = {};
|
||||
|
||||
// If data object is not passed in,
|
||||
// create a new Blob instead.
|
||||
if (!dataObj) {
|
||||
dataObj = new Blob(['some file data'], { type: 'text/plain' });
|
||||
}
|
||||
otherData = null;
|
||||
this.list[newId] = _device.id;
|
||||
|
||||
fileWriter.write(dataObj);
|
||||
});
|
||||
},
|
||||
saveLog: function() {
|
||||
if (_device.hasOwnProperty('advertising')) {
|
||||
|
||||
advertBuffer = app.arrayBufferToIntArray(_device.advertising);
|
||||
|
||||
hexBuffer = app.makeHexBuffer(advertBuffer);
|
||||
|
||||
parsed = app.parseAdvertisingData(advertBuffer);
|
||||
|
||||
if (parsed.hasOwnProperty('9')) {
|
||||
|
||||
var name = app.makeChars(parsed['9']);
|
||||
|
||||
_device.name = name.join('');
|
||||
console.log('Name: ', name.join(''));
|
||||
|
||||
}
|
||||
|
||||
if (parsed.hasOwnProperty('255')) {
|
||||
|
||||
otherData = app.handle255(parsed['255']);
|
||||
console.log(otherData);
|
||||
_device.otherData = otherData;
|
||||
}
|
||||
_device.advertBuffer = advertBuffer;
|
||||
_device.hexBuffer = hexBuffer;
|
||||
_device.parsed = parsed;
|
||||
}
|
||||
|
||||
// OldPdata = app.extractPData(app.log[newId]);
|
||||
oldPdata = app.extractPData(_device);
|
||||
|
||||
newPData = app.processPData(otherData, oldPdata);
|
||||
|
||||
// OldRSSIBuffer = app.extractRSSIBuffer(app.log[newId]);
|
||||
oldRSSIBuffer = app.extractRSSIBuffer(_device);
|
||||
rssiBuffer = app.processRSSIData(_device.rssi, oldRSSIBuffer);
|
||||
|
||||
_device.pData = newPData;
|
||||
_device.rssiBuffer = rssiBuffer;
|
||||
|
||||
newTR = app.buildNewDeviceResultPanel(_device);
|
||||
|
||||
$newID = $('div#' + newId);
|
||||
if ($newID.length > 0) {
|
||||
$newID.replaceWith(newTR);
|
||||
} else {
|
||||
$('#scanResults').append(newTR);
|
||||
}
|
||||
|
||||
app.log[newId] = _device;
|
||||
app.foundDevices[newId] = _device;
|
||||
|
||||
console.log(JSON.stringify(_device));
|
||||
|
||||
}, scanComplete: function() {
|
||||
console.log('Scan complete');
|
||||
|
||||
if (app.mode === 1) {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
if (app.mode === 2) {
|
||||
if (!app.stop) {
|
||||
setTimeout(function() {
|
||||
app.doScan(2);
|
||||
}.bind(this), 200);
|
||||
} else {
|
||||
app.saveLog();
|
||||
$('#ripple').hide();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}, writeFile: function(fileEntry, dataObj) {
|
||||
// Create a FileWriter object for our FileEntry (log.txt).
|
||||
fileEntry.createWriter(function(fileWriter) {
|
||||
|
||||
fileWriter.onwriteend = function() {
|
||||
console.log('Successful file write...');
|
||||
// ReadFile(fileEntry);
|
||||
};
|
||||
|
||||
fileWriter.onerror = function(e) {
|
||||
console.error('Failed file write: ' + e.toString());
|
||||
};
|
||||
|
||||
// If data object is not passed in,
|
||||
// create a new Blob instead.
|
||||
if (!dataObj) {
|
||||
dataObj = new Blob(['some file data'], {type: 'text/plain'});
|
||||
}
|
||||
|
||||
fileWriter.write(dataObj);
|
||||
});
|
||||
}, saveLog: function() {
|
||||
'use strict';
|
||||
var dt = new Date().toISOString().replace(/:|-/g,'').replace(/(\.\w+)/g,'');
|
||||
var dt = new Date().toISOString().replace(/:|-/g, '').replace(/(\.\w+)/g,
|
||||
'');
|
||||
var payload = JSON.stringify(app.log);
|
||||
var filename = 'sensortoy-' + dt + '.json';
|
||||
|
||||
// Var dataObj = new Blob(payload, { type: 'text/plain' });
|
||||
window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, function(fs) {
|
||||
|
||||
console.log('file system open: ' + fs.name);
|
||||
fs.root.getFile(filename, { create: true, exclusive: false }, function(fileEntry) {
|
||||
console.log('file system open: ' + fs.name);
|
||||
fs.root.getFile(filename,
|
||||
{create: true, exclusive: false},
|
||||
function(fileEntry) {
|
||||
|
||||
console.log('fileEntry is file?' + fileEntry.isFile.toString());
|
||||
// FileEntry.name == 'someFile.txt'
|
||||
// fileEntry.fullPath == '/someFile.txt'
|
||||
console.log('Path: ', fileEntry.fullPath);
|
||||
app.writeFile(fileEntry, payload);
|
||||
console.log('fileEntry is file?' + fileEntry.isFile.toString());
|
||||
// FileEntry.name == 'someFile.txt'
|
||||
// fileEntry.fullPath == '/someFile.txt'
|
||||
console.log('Path: ', fileEntry.fullPath);
|
||||
app.writeFile(fileEntry, payload);
|
||||
|
||||
app.log = [];
|
||||
app.log = [];
|
||||
|
||||
}, app.onError);
|
||||
},
|
||||
app.onError);
|
||||
|
||||
}, app.onError);
|
||||
},
|
||||
forceStop: function() {
|
||||
}, app.onError);
|
||||
}, forceStop: function() {
|
||||
'use strict';
|
||||
app.stop = true;
|
||||
$('#scan').show();
|
||||
@ -391,10 +461,10 @@ var app = {
|
||||
}.bind(this));
|
||||
|
||||
$('#stop').on('click', function() {
|
||||
'use strict';
|
||||
app.forceStop();
|
||||
'use strict';
|
||||
app.forceStop();
|
||||
|
||||
}.bind(this));
|
||||
}.bind(this));
|
||||
|
||||
$('#longScan').on('click', function() {
|
||||
'use strict';
|
||||
@ -412,13 +482,11 @@ var app = {
|
||||
self.connect(id);
|
||||
});
|
||||
|
||||
},
|
||||
addTab: function(tID) {
|
||||
}, addTab: function(tID) {
|
||||
var appTabs = $('#app-tabs');
|
||||
var panes = $('#tab-panes');
|
||||
|
||||
var paneID = 'pane-' + tID;
|
||||
var id = app.list[tID];
|
||||
|
||||
var _device = app.foundDevices[tID];
|
||||
var _name = _device.name || _device.id;
|
||||
@ -427,8 +495,8 @@ var app = {
|
||||
|
||||
$('<div>', {class: 'mui-tabs__pane', id: paneID}).appendTo(panes);
|
||||
|
||||
|
||||
var li = $('<li>').append($('<a>',{'data-mui-toggle': 'tab', 'data-mui-controls': paneID, text: _name }));
|
||||
var li = $('<li>').append($('<a>',
|
||||
{'data-mui-toggle': 'tab', 'data-mui-controls': paneID, text: _name}));
|
||||
|
||||
appTabs.append(li);
|
||||
|
||||
@ -442,51 +510,43 @@ var app = {
|
||||
// function, we must explicitly call 'app.receivedEvent(...);'
|
||||
onDeviceReady: function() {
|
||||
|
||||
}, serviceDiscovery: function(services) {
|
||||
'use strict';
|
||||
|
||||
console.log(services);
|
||||
|
||||
}, sensorMpu9250GyroConvert: function(data) {
|
||||
return data / (65536 / 500);
|
||||
},
|
||||
|
||||
sensorMpu9250AccConvert: function(data) {
|
||||
// Change /2 to match accel range...i.e. 16 g would be /16
|
||||
return data / (32768 / 2);
|
||||
},
|
||||
|
||||
doAnimate: function() {
|
||||
'use strict';
|
||||
// Console.log('Animate..');
|
||||
for (var t = 0; t < app.activeServices.length;t++) {
|
||||
app.activeServices[t].animateGraph();
|
||||
for (var item in app.activeServices) {
|
||||
if (app.activeServices.hasOwnProperty(item)) {
|
||||
var activeService = app.activeServices[item];
|
||||
for (var t = 0; t < activeService.length; t++) {
|
||||
activeService[t].animateGraph();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
window.requestAnimFrame(app.doAnimate.bind(this));
|
||||
},
|
||||
connect: function(deviceId) {
|
||||
}, connect: function(deviceId) {
|
||||
|
||||
$('#results').slideUp();
|
||||
console.log('Connect to ', deviceId);
|
||||
|
||||
var tID = 'd-' + deviceId.replace(/:/g, '');
|
||||
var tID = 'd-' + deviceId.replace(/:/g, '').split('-')[0];
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a
|
||||
* @param a.services
|
||||
*/
|
||||
var onConnect = function(a) {
|
||||
var services = [];
|
||||
|
||||
services = a.services;
|
||||
|
||||
|
||||
console.log('Searching services for ', tID);
|
||||
var usedServices = [];
|
||||
|
||||
var target = app.addTab(tID);
|
||||
|
||||
var _params = {
|
||||
deviceID: deviceId,
|
||||
target: target
|
||||
};
|
||||
deviceID: deviceId, target: target
|
||||
};
|
||||
|
||||
for (var t = 0; t < services.length; t++) {
|
||||
|
||||
@ -514,29 +574,26 @@ var app = {
|
||||
if (!app.activeServices.hasOwnProperty(tID)) {
|
||||
|
||||
ble.connect(deviceId, onConnect, function(e) {
|
||||
'use strict';
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
'use strict';
|
||||
console.log(e);
|
||||
console.error(e);
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}, onError: function(reason) {
|
||||
console.error('ERROR: ' + reason); // Real apps should use notification.alert
|
||||
}, updateGyro: function(g) {
|
||||
'use strict';
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
window.requestAnimFrame = (function() {
|
||||
return window.requestAnimationFrame ||
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
function(callback) {
|
||||
window.setTimeout(callback, 1000 / 60);
|
||||
};
|
||||
})();
|
||||
|
||||
app.initialize();
|
||||
|
@ -5,38 +5,82 @@
|
||||
* Time: 14:21
|
||||
*
|
||||
*/
|
||||
|
||||
/* global MANUFACTUREDECODER */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @constructor
|
||||
*/
|
||||
var MANUFACTUREDECODER = function() {
|
||||
'use strict';
|
||||
|
||||
this.getManID = function(data) {
|
||||
return ('0000' + ((data[1] << 8) | data[0]).toString(16)).slice(-4).toUpperCase();
|
||||
},
|
||||
};
|
||||
|
||||
this.decodeIbeacon = function(data) {
|
||||
|
||||
// Not decoding anything yet.
|
||||
// https://support.kontakt.io/hc/en-gb/articles/201492492-iBeacon-advertising-packet-structure
|
||||
var bin = data;
|
||||
var obj = { msg: '(iBeacon)'};
|
||||
// obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
// Obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
obj.manID = this.getManID(bin);
|
||||
var uuid = [];
|
||||
uuid.push(bin[4].toString(16) + bin[5].toString(16) + bin[6].toString(16) + bin[7].toString(16)) ;
|
||||
if (bin[2] === 2) {
|
||||
uuid.push(bin[4].toString(16) + bin[5].toString(16) + bin[6].toString(16) + bin[7].toString(16)) ;
|
||||
|
||||
uuid.push(bin[8].toString(16) + bin[9].toString(16)) ;
|
||||
uuid.push(bin[10].toString(16) + bin[11].toString(16)) ;
|
||||
uuid.push(bin[12].toString(16) + bin[13].toString(16)) ;
|
||||
uuid.push(bin[8].toString(16) + bin[9].toString(16)) ;
|
||||
uuid.push(bin[10].toString(16) + bin[11].toString(16)) ;
|
||||
uuid.push(bin[12].toString(16) + bin[13].toString(16)) ;
|
||||
|
||||
uuid.push(bin[14].toString(16) + bin[15].toString(16) + bin[16].toString(16) + bin[17].toString(16) + bin[18].toString(16) + bin[19].toString(16)) ;
|
||||
var p4 = bin[14].toString(16);
|
||||
p4 = p4 + bin[15].toString(16);
|
||||
p4 = p4 + bin[16].toString(16);
|
||||
p4 = p4 + bin[17].toString(16);
|
||||
p4 = p4 + bin[18].toString(16);
|
||||
p4 = p4 + bin[19].toString(16);
|
||||
|
||||
obj.uuid = uuid.join('-');
|
||||
uuid.push(p4);
|
||||
obj.uuid = uuid.join('-');
|
||||
}
|
||||
|
||||
if (bin[2] === 9) {
|
||||
// This looks like an ip address?
|
||||
var ipaddy = [];
|
||||
ipaddy.push(bin[6]);
|
||||
ipaddy.push(bin[7]);
|
||||
ipaddy.push(bin[8]);
|
||||
ipaddy.push(bin[9]);
|
||||
|
||||
obj.ipaddress = ipaddy.join('.');
|
||||
obj.msg = obj.msg + ' IP:' + obj.ipaddress;
|
||||
}
|
||||
|
||||
if (bin[2] === 12) {
|
||||
|
||||
|
||||
var output = bin.map(function(i) {
|
||||
|
||||
return ('0000' + i.toString(16)).slice(-2) + '';
|
||||
});
|
||||
|
||||
obj.secureUUID = output.join('');
|
||||
|
||||
}
|
||||
|
||||
var signedByte = new Int8Array(1);
|
||||
signedByte[0] = bin[24];
|
||||
obj.txpower = signedByte[0];
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
|
||||
this.decodeSiliconLabsSensorPuck = function(data) {
|
||||
var bin = data;
|
||||
var obj = {data:{}};
|
||||
//obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
var obj = {data: {}};
|
||||
obj.manID = this.getManID(bin);
|
||||
obj.a = (bin[3] << 8) | bin[2];
|
||||
obj.b = (bin[5] << 8) | bin[4];
|
||||
@ -53,8 +97,7 @@ var MANUFACTUREDECODER = function() {
|
||||
|
||||
this.decodeSansible = function(data) {
|
||||
var bin = data;
|
||||
var obj = {data:{}};
|
||||
// obj.manID = ('0000' + ((bin[1] << 8) | bin[0]).toString(16)).slice(-4);
|
||||
var obj = {data: {}};
|
||||
obj.manID = this.getManID(bin);
|
||||
|
||||
obj.data.p1 = ((bin[2] << 16) | bin[3] << 8 | bin[4]);
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
|
@ -5,13 +5,21 @@
|
||||
* Time: 11:47
|
||||
*
|
||||
*/
|
||||
|
||||
/* global bt_company_ids */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @type {{find: bt_company_ids.find, entries: *[]}}
|
||||
*/
|
||||
|
||||
var bt_company_ids = {
|
||||
find: function(id) {
|
||||
var _id = id;
|
||||
var item = this.entries.filter(function(obj) {
|
||||
return this.entries.filter(function(obj) {
|
||||
return obj.hexadecimal === _id;
|
||||
});
|
||||
return item;
|
||||
},
|
||||
entries: [
|
||||
{
|
||||
|
@ -5,7 +5,7 @@
|
||||
* Time: 10:13
|
||||
*
|
||||
*/
|
||||
/* global CAPABILITY, inheritsFrom */
|
||||
/* global CAPABILITY, inheritsFrom, capabilityManager */
|
||||
/* global ble */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
@ -53,8 +53,7 @@ var BUTTON = function(p) {
|
||||
|
||||
this.state = message;
|
||||
|
||||
if (this.$result !== null)
|
||||
{
|
||||
if (this.$result !== null) {
|
||||
this.$result.text(this.state);
|
||||
}
|
||||
console.log('ButtonState: ', this.state);
|
||||
@ -63,7 +62,6 @@ var BUTTON = function(p) {
|
||||
};
|
||||
|
||||
this.startService = function() {
|
||||
'use strict';
|
||||
if (this.deviceID !== null) {
|
||||
|
||||
console.log('Starting Button Service on ', this.deviceID);
|
||||
@ -78,7 +76,7 @@ var BUTTON = function(p) {
|
||||
this.insertFrame = function() {
|
||||
|
||||
var self = this;
|
||||
console.log('Overloading...');
|
||||
console.log('Overloading...');
|
||||
// Call the parent displayForm first...
|
||||
this.superClass_.insertFrame.call(self);
|
||||
|
||||
@ -90,7 +88,7 @@ var BUTTON = function(p) {
|
||||
$('<div />', { class: 'mui-col-xs-8 mui--text-dark', id: detail}).appendTo(row);
|
||||
|
||||
this.$id.append(row);
|
||||
this.$result = $('#'+detail);
|
||||
this.$result = $('#' + detail);
|
||||
|
||||
};
|
||||
|
||||
|
@ -5,14 +5,18 @@
|
||||
* Time: 10:32
|
||||
*
|
||||
*/
|
||||
|
||||
/* global inheritsFrom */
|
||||
/* jshint browser: true , devel: true*/
|
||||
|
||||
'use strict';
|
||||
var capabilityManager = {
|
||||
capabilityList : [],
|
||||
register : function(details) {
|
||||
console.log('Registered:', details );
|
||||
capabilityList: [],
|
||||
register: function(details) {
|
||||
console.log('Registered:', details);
|
||||
this.capabilityList.push(details);
|
||||
},
|
||||
discover : function(id) {
|
||||
discover: function(id) {
|
||||
|
||||
var wanted = this.capabilityList.filter(function(obj) {
|
||||
return obj.id === id;
|
||||
@ -41,15 +45,18 @@ var CAPABILITY = function(p) {
|
||||
|
||||
this.target = null;
|
||||
this.$frame = null;
|
||||
capabilityManager.register({id:this.capabilityID, module:this});
|
||||
|
||||
this.previousCeil = 0;
|
||||
|
||||
capabilityManager.register({id: this.capabilityID, module: this});
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.setFrame = function() {
|
||||
this.$frame = (this.target !== null) ? $('#'+ this.target) : null;
|
||||
this.$frame = (this.target !== null) ? $('#' + this.target) : null;
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.setInternalID = function() {
|
||||
this.internalID = (Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1).toString(36);
|
||||
this.internalID = (Math.floor(Math.random() * 60000) + 1).toString(36);
|
||||
this.frameID = 'f-' + this.internalID;
|
||||
};
|
||||
|
||||
@ -81,10 +88,10 @@ CAPABILITY.prototype.insertFrame = function() {
|
||||
|
||||
|
||||
CAPABILITY.prototype.inherits = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
var C = function() {};
|
||||
C.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype = new C;
|
||||
a.prototype.constructor = a;
|
||||
};
|
||||
|
||||
@ -92,6 +99,13 @@ CAPABILITY.prototype.onError = function(e) {
|
||||
console.error(e);
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @param alt
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
CAPABILITY.prototype.storeData = function(data, alt) {
|
||||
|
||||
if (!this.first) {
|
||||
@ -124,87 +138,114 @@ CAPABILITY.prototype.startGraph = function(id) {
|
||||
this.ctx.fillRect(0,0,300,150);
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraph = function(subID) {
|
||||
|
||||
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraphBase = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
|
||||
var svgID = this.frameID + _subID + '-svg';
|
||||
var text1ID = this.frameID + _subID + '-txt1';
|
||||
var lineID = this.frameID + _subID + '-line';
|
||||
|
||||
var svg = document.createElementNS(xmlns,'svg');
|
||||
|
||||
svg.setAttributeNS(xmlns,'id',svgID);
|
||||
svg.setAttributeNS(xmlns,'width',300);
|
||||
svg.setAttributeNS(xmlns,'height',150);
|
||||
svg.setAttributeNS(xmlns,'width','300');
|
||||
svg.setAttributeNS(xmlns,'height','150');
|
||||
svg.setAttributeNS(xmlns,'fill', 'blue');
|
||||
|
||||
|
||||
svg = this.graphAddXAxis(svg,{y: 12, colour: '#004c6d', id: text1ID});
|
||||
svg = this.graphAddXAxis(svg,{y: 136, colour: '#004c6d', text: '0'});
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.graphAddXAxis = function(svg, settings) {
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
var _svg = svg;
|
||||
var y = settings.y || 0;
|
||||
var y2 = y + 3;
|
||||
var x2 = settings.x2 || 280;
|
||||
var colour = settings.colour || '#ff0000';
|
||||
var id = settings.id;
|
||||
var textContent = settings.text || '-';
|
||||
var lineStyle = ['stroke:',colour,';stroke-width:2;'].join('');
|
||||
var textStyle = ['font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: ',colour,';text-align:right;'].join('');
|
||||
|
||||
var line = document.createElementNS(xmlns,'line');
|
||||
|
||||
line.setAttributeNS(null,'x1','46');
|
||||
line.setAttributeNS(null,'y1','12');
|
||||
line.setAttributeNS(null,'x2','280');
|
||||
line.setAttributeNS(null,'y2', '12');
|
||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
||||
line.setAttributeNS(null,'y1', y);
|
||||
line.setAttributeNS(null,'x2', x2);
|
||||
line.setAttributeNS(null,'y2', y);
|
||||
line.setAttributeNS(null,'style',lineStyle);
|
||||
|
||||
svg.appendChild(line);
|
||||
|
||||
line = document.createElementNS(xmlns,'line');
|
||||
|
||||
line.setAttributeNS(null,'x1','46');
|
||||
line.setAttributeNS(null,'y1','136');
|
||||
line.setAttributeNS(null,'x2','280');
|
||||
line.setAttributeNS(null,'y2', '136');
|
||||
line.setAttributeNS(null,'style','stroke:#004c6d;stroke-width:2;');
|
||||
|
||||
svg.appendChild(line);
|
||||
_svg.appendChild(line);
|
||||
|
||||
var text = document.createElementNS(xmlns,'text');
|
||||
|
||||
text.setAttributeNS(null,'id',text1ID);
|
||||
if (id !== null) {
|
||||
text.setAttributeNS(null,'id',id);
|
||||
}
|
||||
text.setAttributeNS(null,'x','36');
|
||||
text.setAttributeNS(null,'y','15');
|
||||
text.setAttributeNS(null,'y', y2);
|
||||
text.setAttributeNS(null,'text-anchor', 'end');
|
||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
||||
text.textContent = '000';
|
||||
text.setAttributeNS(null,'style',textStyle);
|
||||
text.textContent = textContent;
|
||||
|
||||
svg.appendChild(text);
|
||||
_svg.appendChild(text);
|
||||
|
||||
text = document.createElementNS(xmlns,'text');
|
||||
return _svg;
|
||||
};
|
||||
|
||||
text.setAttributeNS(null,'id','text2');
|
||||
text.setAttributeNS(null,'x','36');
|
||||
text.setAttributeNS(null,'y','140');
|
||||
text.setAttributeNS(null,'text-anchor', 'end');
|
||||
text.setAttributeNS(null,'style','font-family:"Ubuntu Condensed",sans-serif;font-size:12;fill: #004c6d;text-align:right;');
|
||||
text.textContent = '0';
|
||||
|
||||
svg.appendChild(text);
|
||||
CAPABILITY.prototype.graphAddLine = function(svg, lineId, colour) {
|
||||
var xmlns = 'http://www.w3.org/2000/svg';
|
||||
var _svg = svg;
|
||||
|
||||
var polyline = document.createElementNS(xmlns,'polyline');
|
||||
|
||||
polyline.setAttributeNS(null,'id',lineID);
|
||||
polyline.setAttributeNS(null,'id',lineId);
|
||||
polyline.setAttributeNS(null,'fill','none');
|
||||
polyline.setAttributeNS(null,'stroke','#2196F3');
|
||||
//#e5f7fd
|
||||
// Proper '#2196F3'
|
||||
polyline.setAttributeNS(null,'stroke',colour);
|
||||
// #e5f7fd
|
||||
// old #B5C7FF
|
||||
polyline.setAttributeNS(null,'text-anchor', 'end');
|
||||
polyline.setAttributeNS(null,'stroke-width','2');
|
||||
|
||||
svg.appendChild(polyline);
|
||||
_svg.appendChild(polyline);
|
||||
|
||||
return _svg;
|
||||
|
||||
};
|
||||
|
||||
|
||||
CAPABILITY.prototype.generateBlankGraph = function(subID) {
|
||||
|
||||
var _subID = subID || '';
|
||||
var lineID = this.frameID + _subID + '-line';
|
||||
|
||||
var svg = this.generateBlankGraphBase(_subID);
|
||||
|
||||
svg = this.graphAddLine(svg, lineID, '#2196F3');
|
||||
|
||||
return svg;
|
||||
|
||||
};
|
||||
|
||||
CAPABILITY.prototype.animateGraph = function() {
|
||||
//This.simpleGraph(this.data);
|
||||
// This.simpleGraph(this.data);
|
||||
};
|
||||
|
||||
|
||||
CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
var ceilingLimit;
|
||||
var ceiling;
|
||||
var _subID;
|
||||
var _data;
|
||||
var text1ID;
|
||||
@ -218,9 +259,11 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
text1ID = [this.frameID , _subID , '-txt1'].join('');
|
||||
|
||||
if (_data.length > 0) {
|
||||
var ceiling = _data.reduce(function(p, v) {
|
||||
return (p > v ? p : v);
|
||||
});
|
||||
|
||||
ceiling = _data.reduce(function(p, v) {
|
||||
return (Math.abs(p) > Math.abs(v) ? Math.abs(p) : Math.abs(v));
|
||||
});
|
||||
|
||||
|
||||
/* Var floor = _data.reduce(function(p, v) {
|
||||
return (p < v ? p : v);
|
||||
@ -229,6 +272,7 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
var calcArray = [];
|
||||
|
||||
/*
|
||||
var ceilingLimit = Math.floor(ceiling / 10) * 10;
|
||||
if (ceilingLimit < ceiling) {
|
||||
ceilingLimit = Math.floor((ceiling + (ceiling * 0.25)) / 10) * 10;
|
||||
@ -237,6 +281,13 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
if (ceilingLimit < 30) {
|
||||
ceilingLimit = 30;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 10) * 10);
|
||||
if (ceilingLimit > 1000) {
|
||||
ceilingLimit = (Math.ceil((Math.round(ceiling) + 1) / 50) * 50);
|
||||
}
|
||||
|
||||
var scale = 124 / ceilingLimit;
|
||||
// Var xstep = (280 - 46) / 100;
|
||||
@ -264,10 +315,10 @@ CAPABILITY.prototype.simpleGraph = function(data, subID) {
|
||||
|
||||
|
||||
var inheritsFrom = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
var C = function() {};
|
||||
C.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype = new C;
|
||||
a.prototype.constructor = a;
|
||||
a.prototype.superClass_ = b.prototype;
|
||||
};
|
||||
|
@ -6,6 +6,12 @@
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param p
|
||||
* @constructor
|
||||
*/
|
||||
|
||||
var GADGET = function(p) {
|
||||
'use strict';
|
||||
|
||||
|
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* Created by martin on 2016-05-20.
|
||||
*/
|
||||
var DEVICEBASE = function(p) {
|
||||
|
||||
this.controller = p.controller || null;
|
||||
this.settings = p.settings || {};
|
||||
this.data = {};
|
||||
this.standards = {
|
||||
|
||||
button: {
|
||||
service: 'FFE0',
|
||||
data: 'FFE1' // Bit 2: side key, Bit 1- right key, Bit 0 –left key
|
||||
},
|
||||
heartRate: {
|
||||
service: '180d',
|
||||
measurement: '2a37'
|
||||
}
|
||||
};
|
||||
this.custom = {};
|
||||
this.capabilities = [];
|
||||
this.deviceID = null;
|
||||
|
||||
this.inherits = function(a, b) {
|
||||
var c = function() {};
|
||||
c.prototype = b.prototype;
|
||||
a.superClass_ = b.prototype;
|
||||
a.prototype = new c;
|
||||
a.prototype.constructor = a;
|
||||
};
|
||||
|
||||
|
||||
this.register = function(c) {
|
||||
c.registerPage(this);
|
||||
|
||||
};
|
||||
|
||||
this.bytesToString = function(buffer) {
|
||||
return String.fromCharCode.apply(null, new Uint8Array(buffer));
|
||||
};
|
||||
|
||||
// ASCII only
|
||||
this.stringToBytes = function(string) {
|
||||
var array = new Uint8Array(string.length);
|
||||
for (var i = 0, l = string.length; i < l; i++) {
|
||||
array[i] = string.charCodeAt(i);
|
||||
}
|
||||
return array.buffer;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
this.register(this.controller);
|
||||
};
|
@ -1,44 +0,0 @@
|
||||
{
|
||||
"name": "bluebird",
|
||||
"version": "3.4.0",
|
||||
"homepage": "https://github.com/petkaantonov/bluebird",
|
||||
"authors": [
|
||||
"Petka Antonov <petka_antonov@hotmail.com>"
|
||||
],
|
||||
"description": "Bluebird is a full featured promise library with unmatched performance.",
|
||||
"main": "js/browser/bluebird.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"benchmark",
|
||||
"bower_components",
|
||||
"./browser",
|
||||
"node_modules",
|
||||
"test"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"performance",
|
||||
"promises",
|
||||
"promises-a",
|
||||
"promises-aplus",
|
||||
"async",
|
||||
"await",
|
||||
"deferred",
|
||||
"deferreds",
|
||||
"future",
|
||||
"flow control",
|
||||
"dsl",
|
||||
"fluent interface"
|
||||
],
|
||||
"_release": "3.4.0",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "v3.4.0",
|
||||
"commit": "3aeb023d26df1e738e37a162a8f81b36afe1c6b9"
|
||||
},
|
||||
"_source": "https://github.com/petkaantonov/bluebird.git",
|
||||
"_target": "^3.4.0",
|
||||
"_originalSource": "bluebird",
|
||||
"_direct": true
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
{
|
||||
"name": "jquery",
|
||||
"main": "dist/jquery.js",
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"package.json"
|
||||
],
|
||||
"keywords": [
|
||||
"jquery",
|
||||
"javascript",
|
||||
"browser",
|
||||
"library"
|
||||
],
|
||||
"homepage": "https://github.com/jquery/jquery-dist",
|
||||
"version": "2.2.3",
|
||||
"_release": "2.2.3",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "2.2.3",
|
||||
"commit": "af22a351b2ea5801ffb1695abb3bb34d5bed9198"
|
||||
},
|
||||
"_source": "https://github.com/jquery/jquery-dist.git",
|
||||
"_target": "^2.2.3",
|
||||
"_originalSource": "jquery"
|
||||
}
|
@ -1,29 +0,0 @@
|
||||
{
|
||||
"boss": true,
|
||||
"curly": true,
|
||||
"eqeqeq": true,
|
||||
"eqnull": true,
|
||||
"expr": true,
|
||||
"immed": true,
|
||||
"noarg": true,
|
||||
"quotmark": "double",
|
||||
"undef": true,
|
||||
"unused": true,
|
||||
|
||||
"sub": true,
|
||||
|
||||
// Support: IE < 10, Android < 4.1
|
||||
// The above browsers are failing a lot of tests in the ES5
|
||||
// test suite at http://test262.ecmascript.org.
|
||||
"es3": true,
|
||||
|
||||
"globals": {
|
||||
"window": true,
|
||||
"JSON": false,
|
||||
|
||||
"jQuery": true,
|
||||
"define": true,
|
||||
"module": true,
|
||||
"noGlobal": true
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
{
|
||||
"name": "mui",
|
||||
"version": "0.5.9",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
"Andres Morey <andres@muicss.com>"
|
||||
],
|
||||
"homepage": "https://www.muicss.com",
|
||||
"description": "MUI is a lightweight HTML/CSS/JS framework that follows Google's Material Design guidelines.",
|
||||
"main": [
|
||||
"src/sass/mui.scss",
|
||||
"src/sass/mui/_colors.scss",
|
||||
"src/email/mui-email-inline.scss",
|
||||
"src/email/mui-email-styletag.scss",
|
||||
"packages/cdn/css/mui.css",
|
||||
"packages/cdn/css/mui.min.css",
|
||||
"packages/cdn/js/mui.js",
|
||||
"packages/cdn/js/mui.min.js"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/muicss/mui.git"
|
||||
},
|
||||
"keywords": [
|
||||
"material design",
|
||||
"frontend framework",
|
||||
"html, css, and js framework",
|
||||
"email css template"
|
||||
],
|
||||
"dependencies": {},
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"build-targets",
|
||||
"e2e-tests",
|
||||
"examples",
|
||||
"gulpfile.js",
|
||||
"node_modules",
|
||||
"package.json",
|
||||
"test"
|
||||
],
|
||||
"_release": "0.5.9",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "0.5.9",
|
||||
"commit": "12b7c78ed3243af477f16aafb553d977628df82f"
|
||||
},
|
||||
"_source": "https://github.com/muicss/mui.git",
|
||||
"_target": "^0.5.3",
|
||||
"_originalSource": "mui"
|
||||
}
|
86
platforms/android/assets/www/plugins/cordova-plugin-device/www/device.js
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
cordova.define("cordova-plugin-device.device", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
//ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
|
||||
//TODO: CB-5105 native implementations should not return info.cordova
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
|
||||
});
|
116
platforms/android/assets/www/plugins/cordova-plugin-statusbar/www/statusbar.js
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global cordova */
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var namedColors = {
|
||||
"black": "#000000",
|
||||
"darkGray": "#A9A9A9",
|
||||
"lightGray": "#D3D3D3",
|
||||
"white": "#FFFFFF",
|
||||
"gray": "#808080",
|
||||
"red": "#FF0000",
|
||||
"green": "#00FF00",
|
||||
"blue": "#0000FF",
|
||||
"cyan": "#00FFFF",
|
||||
"yellow": "#FFFF00",
|
||||
"magenta": "#FF00FF",
|
||||
"orange": "#FFA500",
|
||||
"purple": "#800080",
|
||||
"brown": "#A52A2A"
|
||||
};
|
||||
|
||||
var StatusBar = {
|
||||
|
||||
isVisible: true,
|
||||
|
||||
overlaysWebView: function (doOverlay) {
|
||||
exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
// dark text ( to be used on a light background )
|
||||
exec(null, null, "StatusBar", "styleDefault", []);
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
// light text ( to be used on a dark background )
|
||||
exec(null, null, "StatusBar", "styleLightContent", []);
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackOpaque", []);
|
||||
},
|
||||
|
||||
backgroundColorByName: function (colorname) {
|
||||
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (hexString) {
|
||||
if (hexString.charAt(0) !== "#") {
|
||||
hexString = "#" + hexString;
|
||||
}
|
||||
|
||||
if (hexString.length === 4) {
|
||||
var split = hexString.split("");
|
||||
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
||||
}
|
||||
|
||||
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
exec(null, null, "StatusBar", "hide", []);
|
||||
StatusBar.isVisible = false;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
exec(null, null, "StatusBar", "show", []);
|
||||
StatusBar.isVisible = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// prime it. setTimeout so that proxy gets time to init
|
||||
window.setTimeout(function () {
|
||||
exec(function (res) {
|
||||
if (typeof res == 'object') {
|
||||
if (res.type == 'tap') {
|
||||
cordova.fireWindowEvent('statusTap');
|
||||
}
|
||||
} else {
|
||||
StatusBar.isVisible = res;
|
||||
}
|
||||
}, null, "StatusBar", "_ready", []);
|
||||
}, 0);
|
||||
|
||||
module.exports = StatusBar;
|
||||
|
||||
});
|
@ -157,6 +157,20 @@ module.exports = [
|
||||
"cordova"
|
||||
],
|
||||
"runs": true
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-device/www/device.js",
|
||||
"id": "cordova-plugin-device.device",
|
||||
"clobbers": [
|
||||
"device"
|
||||
]
|
||||
},
|
||||
{
|
||||
"file": "plugins/cordova-plugin-statusbar/www/statusbar.js",
|
||||
"id": "cordova-plugin-statusbar.statusbar",
|
||||
"clobbers": [
|
||||
"window.StatusBar"
|
||||
]
|
||||
}
|
||||
];
|
||||
module.exports.metadata =
|
||||
@ -165,7 +179,9 @@ module.exports.metadata =
|
||||
"cordova-plugin-whitelist": "1.2.2",
|
||||
"cordova-plugin-compat": "1.0.0",
|
||||
"cordova-plugin-ble-central": "1.1.0",
|
||||
"cordova-plugin-file": "4.2.0"
|
||||
"cordova-plugin-file": "4.2.0",
|
||||
"cordova-plugin-device": "1.1.2",
|
||||
"cordova-plugin-statusbar": "2.1.3"
|
||||
};
|
||||
// BOTTOM OF METADATA
|
||||
});
|
86
platforms/android/platform_www/plugins/cordova-plugin-device/www/device.js
vendored
Normal file
@ -0,0 +1,86 @@
|
||||
cordova.define("cordova-plugin-device.device", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
var argscheck = require('cordova/argscheck'),
|
||||
channel = require('cordova/channel'),
|
||||
utils = require('cordova/utils'),
|
||||
exec = require('cordova/exec'),
|
||||
cordova = require('cordova');
|
||||
|
||||
channel.createSticky('onCordovaInfoReady');
|
||||
// Tell cordova channel to wait on the CordovaInfoReady event
|
||||
channel.waitForInitialization('onCordovaInfoReady');
|
||||
|
||||
/**
|
||||
* This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
|
||||
* phone, etc.
|
||||
* @constructor
|
||||
*/
|
||||
function Device() {
|
||||
this.available = false;
|
||||
this.platform = null;
|
||||
this.version = null;
|
||||
this.uuid = null;
|
||||
this.cordova = null;
|
||||
this.model = null;
|
||||
this.manufacturer = null;
|
||||
this.isVirtual = null;
|
||||
this.serial = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
channel.onCordovaReady.subscribe(function() {
|
||||
me.getInfo(function(info) {
|
||||
//ignoring info.cordova returning from native, we should use value from cordova.version defined in cordova.js
|
||||
//TODO: CB-5105 native implementations should not return info.cordova
|
||||
var buildLabel = cordova.version;
|
||||
me.available = true;
|
||||
me.platform = info.platform;
|
||||
me.version = info.version;
|
||||
me.uuid = info.uuid;
|
||||
me.cordova = buildLabel;
|
||||
me.model = info.model;
|
||||
me.isVirtual = info.isVirtual;
|
||||
me.manufacturer = info.manufacturer || 'unknown';
|
||||
me.serial = info.serial || 'unknown';
|
||||
channel.onCordovaInfoReady.fire();
|
||||
},function(e) {
|
||||
me.available = false;
|
||||
utils.alert("[ERROR] Error initializing Cordova: " + e);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get device info
|
||||
*
|
||||
* @param {Function} successCallback The function to call when the heading data is available
|
||||
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
|
||||
*/
|
||||
Device.prototype.getInfo = function(successCallback, errorCallback) {
|
||||
argscheck.checkArgs('fF', 'Device.getInfo', arguments);
|
||||
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
|
||||
};
|
||||
|
||||
module.exports = new Device();
|
||||
|
||||
});
|
116
platforms/android/platform_www/plugins/cordova-plugin-statusbar/www/statusbar.js
vendored
Normal file
@ -0,0 +1,116 @@
|
||||
cordova.define("cordova-plugin-statusbar.statusbar", function(require, exports, module) {
|
||||
/*
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
/* global cordova */
|
||||
|
||||
var exec = require('cordova/exec');
|
||||
|
||||
var namedColors = {
|
||||
"black": "#000000",
|
||||
"darkGray": "#A9A9A9",
|
||||
"lightGray": "#D3D3D3",
|
||||
"white": "#FFFFFF",
|
||||
"gray": "#808080",
|
||||
"red": "#FF0000",
|
||||
"green": "#00FF00",
|
||||
"blue": "#0000FF",
|
||||
"cyan": "#00FFFF",
|
||||
"yellow": "#FFFF00",
|
||||
"magenta": "#FF00FF",
|
||||
"orange": "#FFA500",
|
||||
"purple": "#800080",
|
||||
"brown": "#A52A2A"
|
||||
};
|
||||
|
||||
var StatusBar = {
|
||||
|
||||
isVisible: true,
|
||||
|
||||
overlaysWebView: function (doOverlay) {
|
||||
exec(null, null, "StatusBar", "overlaysWebView", [doOverlay]);
|
||||
},
|
||||
|
||||
styleDefault: function () {
|
||||
// dark text ( to be used on a light background )
|
||||
exec(null, null, "StatusBar", "styleDefault", []);
|
||||
},
|
||||
|
||||
styleLightContent: function () {
|
||||
// light text ( to be used on a dark background )
|
||||
exec(null, null, "StatusBar", "styleLightContent", []);
|
||||
},
|
||||
|
||||
styleBlackTranslucent: function () {
|
||||
// #88000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackTranslucent", []);
|
||||
},
|
||||
|
||||
styleBlackOpaque: function () {
|
||||
// #FF000000 ? Apple says to use lightContent instead
|
||||
exec(null, null, "StatusBar", "styleBlackOpaque", []);
|
||||
},
|
||||
|
||||
backgroundColorByName: function (colorname) {
|
||||
return StatusBar.backgroundColorByHexString(namedColors[colorname]);
|
||||
},
|
||||
|
||||
backgroundColorByHexString: function (hexString) {
|
||||
if (hexString.charAt(0) !== "#") {
|
||||
hexString = "#" + hexString;
|
||||
}
|
||||
|
||||
if (hexString.length === 4) {
|
||||
var split = hexString.split("");
|
||||
hexString = "#" + split[1] + split[1] + split[2] + split[2] + split[3] + split[3];
|
||||
}
|
||||
|
||||
exec(null, null, "StatusBar", "backgroundColorByHexString", [hexString]);
|
||||
},
|
||||
|
||||
hide: function () {
|
||||
exec(null, null, "StatusBar", "hide", []);
|
||||
StatusBar.isVisible = false;
|
||||
},
|
||||
|
||||
show: function () {
|
||||
exec(null, null, "StatusBar", "show", []);
|
||||
StatusBar.isVisible = true;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// prime it. setTimeout so that proxy gets time to init
|
||||
window.setTimeout(function () {
|
||||
exec(function (res) {
|
||||
if (typeof res == 'object') {
|
||||
if (res.type == 'tap') {
|
||||
cordova.fireWindowEvent('statusTap');
|
||||
}
|
||||
} else {
|
||||
StatusBar.isVisible = res;
|
||||
}
|
||||
}, null, "StatusBar", "_ready", []);
|
||||
}, 0);
|
||||
|
||||
module.exports = StatusBar;
|
||||
|
||||
});
|
@ -1,6 +1,6 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<resources>
|
||||
<string name="app_name">Sensortoy</string>
|
||||
<string name="app_name">BLE Sensors</string>
|
||||
<string name="launcher_name">@string/app_name</string>
|
||||
<string name="activity_name">@string/launcher_name</string>
|
||||
</resources>
|
||||
|
@ -9,6 +9,13 @@
|
||||
<param name="android-package" value="org.apache.cordova.file.FileUtils" />
|
||||
<param name="onload" value="true" />
|
||||
</feature>
|
||||
<feature name="Device">
|
||||
<param name="android-package" value="org.apache.cordova.device.Device" />
|
||||
</feature>
|
||||
<feature name="StatusBar">
|
||||
<param name="android-package" value="org.apache.cordova.statusbar.StatusBar" />
|
||||
<param name="onload" value="true" />
|
||||
</feature>
|
||||
<feature name="BLE">
|
||||
<param name="android-package" value="com.megster.cordova.ble.central.BLECentralPlugin" />
|
||||
</feature>
|
||||
@ -19,7 +26,7 @@
|
||||
<icon density="xhdpi" src="res/android/mipmap-xhdpi/ic_launcher.png" />
|
||||
<icon density="xxhdpi" src="res/android/mipmap-xxhdpi/ic_launcher.png" />
|
||||
<icon density="xxxhdpi" src="res/android/mipmap-xxxhdpi/ic_launcher.png" />
|
||||
<name>Sensortoy</name>
|
||||
<name>BLE Sensors</name>
|
||||
<description>
|
||||
A sample Apache Cordova application that responds to the deviceready event.
|
||||
</description>
|
||||
|
174
platforms/android/src/org/apache/cordova/device/Device.java
Normal file
@ -0,0 +1,174 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
package org.apache.cordova.device;
|
||||
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import android.provider.Settings;
|
||||
|
||||
public class Device extends CordovaPlugin {
|
||||
public static final String TAG = "Device";
|
||||
|
||||
public static String platform; // Device OS
|
||||
public static String uuid; // Device UUID
|
||||
|
||||
private static final String ANDROID_PLATFORM = "Android";
|
||||
private static final String AMAZON_PLATFORM = "amazon-fireos";
|
||||
private static final String AMAZON_DEVICE = "Amazon";
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public Device() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
|
||||
super.initialize(cordova, webView);
|
||||
Device.uuid = getUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false if not.
|
||||
*/
|
||||
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
||||
if ("getDeviceInfo".equals(action)) {
|
||||
JSONObject r = new JSONObject();
|
||||
r.put("uuid", Device.uuid);
|
||||
r.put("version", this.getOSVersion());
|
||||
r.put("platform", this.getPlatform());
|
||||
r.put("model", this.getModel());
|
||||
r.put("manufacturer", this.getManufacturer());
|
||||
r.put("isVirtual", this.isVirtual());
|
||||
r.put("serial", this.getSerialNumber());
|
||||
callbackContext.success(r);
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// LOCAL METHODS
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Get the OS name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getPlatform() {
|
||||
String platform;
|
||||
if (isAmazonDevice()) {
|
||||
platform = AMAZON_PLATFORM;
|
||||
} else {
|
||||
platform = ANDROID_PLATFORM;
|
||||
}
|
||||
return platform;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the device's Universally Unique Identifier (UUID).
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getUuid() {
|
||||
String uuid = Settings.Secure.getString(this.cordova.getActivity().getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public String getModel() {
|
||||
String model = android.os.Build.MODEL;
|
||||
return model;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
String productname = android.os.Build.PRODUCT;
|
||||
return productname;
|
||||
}
|
||||
|
||||
public String getManufacturer() {
|
||||
String manufacturer = android.os.Build.MANUFACTURER;
|
||||
return manufacturer;
|
||||
}
|
||||
|
||||
public String getSerialNumber() {
|
||||
String serial = android.os.Build.SERIAL;
|
||||
return serial;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the OS version.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getOSVersion() {
|
||||
String osversion = android.os.Build.VERSION.RELEASE;
|
||||
return osversion;
|
||||
}
|
||||
|
||||
public String getSDKVersion() {
|
||||
@SuppressWarnings("deprecation")
|
||||
String sdkversion = android.os.Build.VERSION.SDK;
|
||||
return sdkversion;
|
||||
}
|
||||
|
||||
public String getTimeZoneID() {
|
||||
TimeZone tz = TimeZone.getDefault();
|
||||
return (tz.getID());
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to check if the device is manufactured by Amazon
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isAmazonDevice() {
|
||||
if (android.os.Build.MANUFACTURER.equals(AMAZON_DEVICE)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isVirtual() {
|
||||
return android.os.Build.FINGERPRINT.contains("generic") ||
|
||||
android.os.Build.PRODUCT.contains("sdk");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
*/
|
||||
package org.apache.cordova.statusbar;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import org.apache.cordova.CallbackContext;
|
||||
import org.apache.cordova.CordovaArgs;
|
||||
import org.apache.cordova.CordovaInterface;
|
||||
import org.apache.cordova.CordovaPlugin;
|
||||
import org.apache.cordova.CordovaWebView;
|
||||
import org.apache.cordova.PluginResult;
|
||||
import org.json.JSONException;
|
||||
|
||||
public class StatusBar extends CordovaPlugin {
|
||||
private static final String TAG = "StatusBar";
|
||||
|
||||
/**
|
||||
* Sets the context of the Command. This can then be used to do things like
|
||||
* get file paths associated with the Activity.
|
||||
*
|
||||
* @param cordova The context of the main Activity.
|
||||
* @param webView The CordovaWebView Cordova is running in.
|
||||
*/
|
||||
@Override
|
||||
public void initialize(final CordovaInterface cordova, CordovaWebView webView) {
|
||||
Log.v(TAG, "StatusBar: initialization");
|
||||
super.initialize(cordova, webView);
|
||||
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Clear flag FLAG_FORCE_NOT_FULLSCREEN which is set initially
|
||||
// by the Cordova.
|
||||
Window window = cordova.getActivity().getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
|
||||
|
||||
// Read 'StatusBarBackgroundColor' from config.xml, default is #000000.
|
||||
setStatusBarBackgroundColor(preferences.getString("StatusBarBackgroundColor", "#000000"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Executes the request and returns PluginResult.
|
||||
*
|
||||
* @param action The action to execute.
|
||||
* @param args JSONArry of arguments for the plugin.
|
||||
* @param callbackContext The callback id used when calling back into JavaScript.
|
||||
* @return True if the action was valid, false otherwise.
|
||||
*/
|
||||
@Override
|
||||
public boolean execute(final String action, final CordovaArgs args, final CallbackContext callbackContext) throws JSONException {
|
||||
Log.v(TAG, "Executing action: " + action);
|
||||
final Activity activity = this.cordova.getActivity();
|
||||
final Window window = activity.getWindow();
|
||||
|
||||
if ("_ready".equals(action)) {
|
||||
boolean statusBarVisible = (window.getAttributes().flags & WindowManager.LayoutParams.FLAG_FULLSCREEN) == 0;
|
||||
callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, statusBarVisible));
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("show".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
|
||||
// use KitKat here to be aligned with "Fullscreen" preference
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
int uiOptions = window.getDecorView().getSystemUiVisibility();
|
||||
uiOptions &= ~View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN;
|
||||
uiOptions &= ~View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("hide".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// SYSTEM_UI_FLAG_FULLSCREEN is available since JellyBean, but we
|
||||
// use KitKat here to be aligned with "Fullscreen" preference
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||
int uiOptions = window.getDecorView().getSystemUiVisibility()
|
||||
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
| View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
|
||||
window.getDecorView().setSystemUiVisibility(uiOptions);
|
||||
return;
|
||||
}
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
if ("backgroundColorByHexString".equals(action)) {
|
||||
this.cordova.getActivity().runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
setStatusBarBackgroundColor(args.getString(0));
|
||||
} catch (JSONException ignore) {
|
||||
Log.e(TAG, "Invalid hexString argument, use f.i. '#777777'");
|
||||
}
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void setStatusBarBackgroundColor(final String colorPref) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
if (colorPref != null && !colorPref.isEmpty()) {
|
||||
final Window window = cordova.getActivity().getWindow();
|
||||
// Method and constants not available on all SDKs but we want to be able to compile this code with any SDK
|
||||
window.clearFlags(0x04000000); // SDK 19: WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.addFlags(0x80000000); // SDK 21: WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
try {
|
||||
// Using reflection makes sure any 5.0+ device will work without having to compile with SDK level 21
|
||||
window.getClass().getDeclaredMethod("setStatusBarColor", int.class).invoke(window, Color.parseColor(colorPref));
|
||||
} catch (IllegalArgumentException ignore) {
|
||||
Log.e(TAG, "Invalid hexString argument, use f.i. '#999999'");
|
||||
} catch (Exception ignore) {
|
||||
// this should not happen, only in case Android removes this method in a version > 21
|
||||
Log.w(TAG, "Method window.setStatusBarColor not found for SDK level " + Build.VERSION.SDK_INT);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -22,6 +22,8 @@
|
||||
8133BB75956A4B3D9041CDEB /* CDVFile.m in Sources */ = {isa = PBXBuildFile; fileRef = CD0540EE3BB84FEB9D80207C /* CDVFile.m */; };
|
||||
2F69CAFCDF7041BF8EEF9E10 /* CDVLocalFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = BF6C111A8ABF493F9CFAD599 /* CDVLocalFilesystem.m */; };
|
||||
D8A12904BC024C6CB9F27CF6 /* CDVAssetLibraryFilesystem.m in Sources */ = {isa = PBXBuildFile; fileRef = AF593BFBE5B74A0F8829A8B4 /* CDVAssetLibraryFilesystem.m */; };
|
||||
5C43D82B4EDE4BB09292244D /* CDVDevice.m in Sources */ = {isa = PBXBuildFile; fileRef = DCBEFDAD848D4696B54B6EFF /* CDVDevice.m */; };
|
||||
7C36207894744A0F836FB66A /* CDVStatusBar.m in Sources */ = {isa = PBXBuildFile; fileRef = B4C324D26AB949AAA01F6AB1 /* CDVStatusBar.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXContainerItemProxy section */
|
||||
@ -42,10 +44,10 @@
|
||||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
0207DA571B56EA530066E2B4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "Sensortoy/Images.xcassets"; sourceTree = SOURCE_ROOT; };
|
||||
0207DA571B56EA530066E2B4 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = "BLE Sensors/Images.xcassets"; sourceTree = SOURCE_ROOT; };
|
||||
1D3623240D0F684500981E51 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
|
||||
1D3623250D0F684500981E51 /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
|
||||
1D6058910D05DD3D006BFB54 /* Sensortoy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Sensortoy.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
1D6058910D05DD3D006BFB54 /* BLE Sensors.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "BLE Sensors.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
301BF52D109A57CC0062928A /* CordovaLib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CordovaLib.xcodeproj; path = CordovaLib/CordovaLib.xcodeproj; sourceTree = "<group>"; };
|
||||
301BF56E109A69640062928A /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; path = www; sourceTree = SOURCE_ROOT; };
|
||||
@ -55,11 +57,11 @@
|
||||
3047A50F1AB8059700498E2A /* build-debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "build-debug.xcconfig"; path = cordova/build-debug.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
3047A5101AB8059700498E2A /* build-release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = "build-release.xcconfig"; path = cordova/build-release.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
3047A5111AB8059700498E2A /* build.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = build.xcconfig; path = cordova/build.xcconfig; sourceTree = SOURCE_ROOT; };
|
||||
32CA4F630368D1EE00C91783 /* Sensortoy-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "Sensortoy-Prefix.pch"; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* Sensortoy-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "Sensortoy-Info.plist"; path = "Sensortoy/Sensortoy-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = SOURCE_ROOT; };
|
||||
32CA4F630368D1EE00C91783 /* BLE Sensors-Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BLE Sensors-Prefix.pch"; sourceTree = "<group>"; };
|
||||
8D1107310486CEB800E47090 /* BLE Sensors-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "BLE Sensors-Info.plist"; path = "BLE Sensors/BLE Sensors-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = SOURCE_ROOT; };
|
||||
EB87FDF31871DA8E0020F90C /* www */ = {isa = PBXFileReference; lastKnownFileType = folder; name = www; path = ../../www; sourceTree = "<group>"; };
|
||||
EB87FDF41871DAF40020F90C /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = ../../config.xml; sourceTree = "<group>"; };
|
||||
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "Sensortoy/config.xml"; sourceTree = "<group>"; };
|
||||
F840E1F0165FE0F500CFE078 /* config.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; name = config.xml; path = "BLE Sensors/config.xml"; sourceTree = "<group>"; };
|
||||
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "Bridging-Header.h"; path = "Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
B668E8BBCBB54EE8920D9CE6 /* BLECentralPlugin.m */ = {isa = PBXFileReference; name = "BLECentralPlugin.m"; path = "cordova-plugin-ble-central/BLECentralPlugin/BLECentralPlugin.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||
8121E3457B8C4D788EA22698 /* CBPeripheral+Extensions.m */ = {isa = PBXFileReference; name = "CBPeripheral+Extensions.m"; path = "cordova-plugin-ble-central/BLECentralPlugin/CBPeripheral+Extensions.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||
@ -74,6 +76,10 @@
|
||||
59D0E567446345F8906117A1 /* CDVFile.h */ = {isa = PBXFileReference; name = "CDVFile.h"; path = "cordova-plugin-file/CDVFile.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||
0A058DF503B048619AB9C937 /* CDVLocalFilesystem.h */ = {isa = PBXFileReference; name = "CDVLocalFilesystem.h"; path = "cordova-plugin-file/CDVLocalFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||
266CC34DDEFA486FB0CBF3AD /* CDVAssetLibraryFilesystem.h */ = {isa = PBXFileReference; name = "CDVAssetLibraryFilesystem.h"; path = "cordova-plugin-file/CDVAssetLibraryFilesystem.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||
DCBEFDAD848D4696B54B6EFF /* CDVDevice.m */ = {isa = PBXFileReference; name = "CDVDevice.m"; path = "cordova-plugin-device/CDVDevice.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||
8BE41502FED742AB9910992F /* CDVDevice.h */ = {isa = PBXFileReference; name = "CDVDevice.h"; path = "cordova-plugin-device/CDVDevice.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||
B4C324D26AB949AAA01F6AB1 /* CDVStatusBar.m */ = {isa = PBXFileReference; name = "CDVStatusBar.m"; path = "cordova-plugin-statusbar/CDVStatusBar.m"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; explicitFileType = undefined; includeInIndex = 0; };
|
||||
8C56B591C722421E8ECBB2E4 /* CDVStatusBar.h */ = {isa = PBXFileReference; name = "CDVStatusBar.h"; path = "cordova-plugin-statusbar/CDVStatusBar.h"; sourceTree = "<group>"; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; explicitFileType = undefined; includeInIndex = 0; };
|
||||
/* End PBXFileReference section */
|
||||
|
||||
/* Begin PBXFrameworksBuildPhase section */
|
||||
@ -99,13 +105,13 @@
|
||||
1D3623250D0F684500981E51 /* AppDelegate.m */,
|
||||
);
|
||||
name = Classes;
|
||||
path = "Sensortoy/Classes";
|
||||
path = "BLE Sensors/Classes";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
19C28FACFE9D520D11CA2CBB /* Products */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
1D6058910D05DD3D006BFB54 /* Sensortoy.app */,
|
||||
1D6058910D05DD3D006BFB54 /* BLE Sensors.app */,
|
||||
);
|
||||
name = Products;
|
||||
sourceTree = "<group>";
|
||||
@ -130,12 +136,12 @@
|
||||
29B97315FDCFA39411CA2CEA /* Other Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
32CA4F630368D1EE00C91783 /* Sensortoy-Prefix.pch */,
|
||||
32CA4F630368D1EE00C91783 /* BLE Sensors-Prefix.pch */,
|
||||
29B97316FDCFA39411CA2CEA /* main.m */,
|
||||
ED33DF2A687741AEAF9F8254 /* Bridging-Header.h */,
|
||||
);
|
||||
name = "Other Sources";
|
||||
path = "Sensortoy";
|
||||
path = "BLE Sensors";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97317FDCFA39411CA2CEA /* Resources */ = {
|
||||
@ -143,10 +149,10 @@
|
||||
children = (
|
||||
0207DA571B56EA530066E2B4 /* Images.xcassets */,
|
||||
3047A50E1AB8057F00498E2A /* config */,
|
||||
8D1107310486CEB800E47090 /* Sensortoy-Info.plist */,
|
||||
8D1107310486CEB800E47090 /* BLE Sensors-Info.plist */,
|
||||
);
|
||||
name = Resources;
|
||||
path = "Sensortoy/Resources";
|
||||
path = "BLE Sensors/Resources";
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29B97323FDCFA39411CA2CEA /* Frameworks */ = {
|
||||
@ -190,9 +196,13 @@
|
||||
59D0E567446345F8906117A1 /* CDVFile.h */,
|
||||
0A058DF503B048619AB9C937 /* CDVLocalFilesystem.h */,
|
||||
266CC34DDEFA486FB0CBF3AD /* CDVAssetLibraryFilesystem.h */,
|
||||
DCBEFDAD848D4696B54B6EFF /* CDVDevice.m */,
|
||||
8BE41502FED742AB9910992F /* CDVDevice.h */,
|
||||
B4C324D26AB949AAA01F6AB1 /* CDVStatusBar.m */,
|
||||
8C56B591C722421E8ECBB2E4 /* CDVStatusBar.h */,
|
||||
);
|
||||
name = Plugins;
|
||||
path = "Sensortoy/Plugins";
|
||||
path = "BLE Sensors/Plugins";
|
||||
sourceTree = SOURCE_ROOT;
|
||||
};
|
||||
EB87FDF11871DA420020F90C /* Staging */ = {
|
||||
@ -207,9 +217,9 @@
|
||||
/* End PBXGroup section */
|
||||
|
||||
/* Begin PBXNativeTarget section */
|
||||
1D6058900D05DD3D006BFB54 /* Sensortoy */ = {
|
||||
1D6058900D05DD3D006BFB54 /* BLE Sensors */ = {
|
||||
isa = PBXNativeTarget;
|
||||
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Sensortoy" */;
|
||||
buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "BLE Sensors" */;
|
||||
buildPhases = (
|
||||
304B58A110DAC018002A0835 /* Copy www directory */,
|
||||
1D60588D0D05DD3D006BFB54 /* Resources */,
|
||||
@ -221,9 +231,9 @@
|
||||
dependencies = (
|
||||
301BF551109A68C00062928A /* PBXTargetDependency */,
|
||||
);
|
||||
name = "Sensortoy";
|
||||
productName = "Sensortoy";
|
||||
productReference = 1D6058910D05DD3D006BFB54 /* Sensortoy.app */;
|
||||
name = "BLE Sensors";
|
||||
productName = "BLE Sensors";
|
||||
productReference = 1D6058910D05DD3D006BFB54 /* BLE Sensors.app */;
|
||||
productType = "com.apple.product-type.application";
|
||||
};
|
||||
/* End PBXNativeTarget section */
|
||||
@ -248,7 +258,7 @@
|
||||
);
|
||||
projectRoot = "";
|
||||
targets = (
|
||||
1D6058900D05DD3D006BFB54 /* Sensortoy */,
|
||||
1D6058900D05DD3D006BFB54 /* BLE Sensors */,
|
||||
);
|
||||
};
|
||||
/* End PBXProject section */
|
||||
@ -310,6 +320,8 @@
|
||||
8133BB75956A4B3D9041CDEB /* CDVFile.m in Sources */,
|
||||
2F69CAFCDF7041BF8EEF9E10 /* CDVLocalFilesystem.m in Sources */,
|
||||
D8A12904BC024C6CB9F27CF6 /* CDVAssetLibraryFilesystem.m in Sources */,
|
||||
5C43D82B4EDE4BB09292244D /* CDVDevice.m in Sources */,
|
||||
7C36207894744A0F836FB66A /* CDVStatusBar.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -337,12 +349,12 @@
|
||||
GCC_DYNAMIC_NO_PIC = NO;
|
||||
GCC_OPTIMIZATION_LEVEL = 0;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "Sensortoy/Sensortoy-Prefix.pch";
|
||||
GCC_PREFIX_HEADER = "BLE Sensors/BLE Sensors-Prefix.pch";
|
||||
GCC_THUMB_SUPPORT = NO;
|
||||
GCC_VERSION = "";
|
||||
INFOPLIST_FILE = "Sensortoy/Sensortoy-Info.plist";
|
||||
INFOPLIST_FILE = "BLE Sensors/BLE Sensors-Info.plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
|
||||
PRODUCT_NAME = "Sensortoy";
|
||||
PRODUCT_NAME = "BLE Sensors";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -357,11 +369,11 @@
|
||||
CLANG_ENABLE_OBJC_ARC = YES;
|
||||
COPY_PHASE_STRIP = YES;
|
||||
GCC_PRECOMPILE_PREFIX_HEADER = YES;
|
||||
GCC_PREFIX_HEADER = "Sensortoy/Sensortoy-Prefix.pch";
|
||||
GCC_PREFIX_HEADER = "BLE Sensors/BLE Sensors-Prefix.pch";
|
||||
GCC_THUMB_SUPPORT = NO;
|
||||
GCC_VERSION = "";
|
||||
INFOPLIST_FILE = "Sensortoy/Sensortoy-Info.plist";
|
||||
PRODUCT_NAME = "Sensortoy";
|
||||
INFOPLIST_FILE = "BLE Sensors/BLE Sensors-Info.plist";
|
||||
PRODUCT_NAME = "BLE Sensors";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
@ -388,6 +400,7 @@
|
||||
ONLY_ACTIVE_ARCH = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = NO;
|
||||
PRODUCT_NAME = "BLE Sensors";
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -413,13 +426,14 @@
|
||||
GCC_WARN_UNUSED_VARIABLE = YES;
|
||||
SDKROOT = iphoneos;
|
||||
SKIP_INSTALL = NO;
|
||||
PRODUCT_NAME = "BLE Sensors";
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
/* End XCBuildConfiguration section */
|
||||
|
||||
/* Begin XCConfigurationList section */
|
||||
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "Sensortoy" */ = {
|
||||
1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "BLE Sensors" */ = {
|
||||
isa = XCConfigurationList;
|
||||
buildConfigurations = (
|
||||
1D6058940D05DD3E006BFB54 /* Debug */,
|
Before Width: | Height: | Size: 4.0 KiB After Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 4.8 KiB After Width: | Height: | Size: 4.8 KiB |
Before Width: | Height: | Size: 9.4 KiB After Width: | Height: | Size: 9.4 KiB |
After Width: | Height: | Size: 534 B |
After Width: | Height: | Size: 809 B |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 618 B |
After Width: | Height: | Size: 912 B |
After Width: | Height: | Size: 633 B |
After Width: | Height: | Size: 944 B |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.2 KiB |
Before Width: | Height: | Size: 5.5 KiB After Width: | Height: | Size: 5.5 KiB |
Before Width: | Height: | Size: 6.9 KiB After Width: | Height: | Size: 6.9 KiB |
After Width: | Height: | Size: 556 B |
After Width: | Height: | Size: 782 B |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 37 KiB |
After Width: | Height: | Size: 56 KiB |
Before Width: | Height: | Size: 78 KiB After Width: | Height: | Size: 78 KiB |
Before Width: | Height: | Size: 207 KiB After Width: | Height: | Size: 207 KiB |
Before Width: | Height: | Size: 90 KiB After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 8.7 KiB |
@ -0,0 +1,30 @@
|
||||
/*
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
*/
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Cordova/CDVPlugin.h>
|
||||
|
||||
@interface CDVDevice : CDVPlugin
|
||||
{}
|
||||
|
||||
+ (NSString*)cordovaVersion;
|
||||
|
||||
- (void)getDeviceInfo:(CDVInvokedUrlCommand*)command;
|
||||
|
||||
@end
|