Skip to content

Commit

Permalink
various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aircable committed Mar 12, 2017
1 parent 27fae06 commit 9a48b0f
Show file tree
Hide file tree
Showing 13 changed files with 278 additions and 89 deletions.
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ browserify mqtt.js -s mqtt > ../../ionic-material-mesh/www/js/mqtt.js
#install MQTT server and run
# building MQTT server
http://goochgooch.co.uk/2014/08/01/building-mosquitto-1-4/
# or installing via brew
# or installing via brew on OSX
#run
/usr/local/opt/mosquitto/sbin/mosquitto -c /usr/local/etc/mosquitto/mqtt.conf

Expand Down
20 changes: 20 additions & 0 deletions www/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@ body {
font-family: RobotoDraft, Roboto, Helvetica Neue, sans-serif;
}

.virtualRepeatdemoHorizontalUsage #horizontal-container {
height: 100px;
width: 100%;
max-width: 830px; }

.virtualRepeatdemoHorizontalUsage .repeated-item {
border-right: 1px solid #ddd;
box-sizing: border-box;
display: inline-block;
height: 84px;
padding-top: 35px;
text-align: center;
width: 50px; }

.virtualRepeatdemoHorizontalUsage md-content {
margin: 16px; }

.virtualRepeatdemoHorizontalUsage md-virtual-repeat-container {
border: solid 1px grey; }


.ios-course-background {
background-color: #45AFA8 !important; }
Expand Down
8 changes: 3 additions & 5 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@
<meta name="format-detection" content="telephone=no"> <!-- To disable phone number typing.-->
<meta name="mobile-web-app-capable" content="yes">

<!-- Origin Trial Token, feature = Web Bluetooth, origin = https://aircable.net:8101, expires = 2016-11-23 -->
<meta http-equiv="origin-trial" data-feature="Web Bluetooth" data-expires="2016-11-23" content="AvoDMGKGHgijUfUh2lpQ7FHUMvoPz5HxngtGM2RA9KihTbvGwLotGEvOwHc0oG8F8u8utqlwjXz++ljJjClwXAgAAABTeyJvcmlnaW4iOiJodHRwczovL2FpcmNhYmxlLm5ldDo4MTAxIiwiZmVhdHVyZSI6IldlYkJsdWV0b290aCIsImV4cGlyeSI6MTQ3OTkyMzg3OX0="> <!-- end Meta section -->
<title></title>

<!-- Font reference section -->
<!-- Origin Trial Token, feature = Web Bluetooth, origin = https://aircable.net:8101, expires = 2017-01-24 -->
<meta http-equiv="origin-trial" data-feature="Web Bluetooth" data-expires="2017-01-24" content="Ao223bJsw0Z8L9MDp34NftSEXxsxnDcpRO6Wxt5lkIAhlj4b00q9d3j2L6Cm9Wxy71fTMizXyix53fgPpSRlkA8AAABTeyJvcmlnaW4iOiJodHRwczovL2FpcmNhYmxlLm5ldDo4MTAxIiwiZmVhdHVyZSI6IldlYkJsdWV0b290aCIsImV4cGlyeSI6MTQ4NTMwMjM5OX0="> <!-- Font reference section -->
<link href="lib/robotodraft/robotodraft.css">
<!-- end Font reference section -->

Expand Down Expand Up @@ -89,6 +86,7 @@
<script src="js/controllers/FlasherCtrl.js"></script>
<script src="js/controllers/SnifferCtrl.js"></script>
<script src="js/controllers/FlowCtrl.js"></script>
<script src="js/controllers/AssetCtrl.js"></script>
<!-- end Controllers section-->

<!-- jQuery section-->
Expand Down
27 changes: 27 additions & 0 deletions www/js/controllers/AssetCtrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Created by juergen on 6/3/16.
* Copyright 2016 Wireless Cables Inc.
*/

appControllers.controller('assetCtrl', function( $scope, $rootScope, $state, $stateParams, $timeout,
TXD, CRED ) {

$scope.credentials = CRED.credentials;

});

appControllers.filter('assetfilter', function() {

return function( meshnodes ) {

return meshnodes.filter( function( element, index, array ) {

if(( element.device_type )&&( element.device_type == 0x1111 )) { //0x105D

element.edit = true;
console.log( "asset="+element.asset );
return true;
}
})
}
});
2 changes: 1 addition & 1 deletion www/js/controllers/GatewayCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ appControllers.controller('gatewayDetailCtrl', function ($scope, $state, $stateP

// writes 8 bytes of string data to the sequence block
function writeBlockToSequence( seq, data, density ) {
var MCP_MULTIBLOCK = 0x75;
var MCP_MULTIBLOCK = 0x15;

if( seq == 0 ){
//create new config_sequence
Expand Down
32 changes: 12 additions & 20 deletions www/js/controllers/LightCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,12 @@ appControllers.filter('lightfilter', function() {
element.nightlight = config[2];
element.threshold = config[3];
element.offtime = config[4];
element.porch = config[5];
if( config[5] > 0 ) {
element.porch = true;
} else {
element.porch = false;
}

}

} catch( e ){
Expand Down Expand Up @@ -223,7 +228,7 @@ appControllers.filter('lightfilter3', function() {
// Controller of Note Detail Page.
appControllers.controller('lightDetailCtrl', function ($scope, $state, $stateParams, MCP, MESH, MQTT, IBEACON, CRED, TXD ) {

const MCP_CONFIG = 0x77;
const MCP_CONFIG = 0x17;

var credentials = CRED.credentials;

Expand Down Expand Up @@ -256,23 +261,6 @@ appControllers.controller('lightDetailCtrl', function ($scope, $state, $statePar
};// End getNoteData.


// sending a BLOCK command with string content
function sendConfigString( command, destination ) {

var MCP_BLOCK = 0x73; // for status messages

// send an iBeacon with BLOCK command as string
meshcmd = new Uint8Array( command.length + 1 );
meshcmd[0] = MCP_BLOCK;
for( var i=0, j=command.length; i < j; ++i ) {
meshcmd[ i+1 ] = command.charCodeAt(i);
}
meshcmd[i + 1] = 0;

TXD.transmit_mesh( destination, meshcmd, 1 );

}



var ConfigTimer;
Expand All @@ -297,7 +285,11 @@ appControllers.controller('lightDetailCtrl', function ($scope, $state, $statePar
newconf[4] = $scope.device.nightlight;
newconf[5] = $scope.device.threshold;
newconf[6] = $scope.device.offtimer;
newconf[7] = $scope.device.porch;
if( $scope.device.porch ) {
newconf[7] = 1;
} else {
newconf[7] = 0;
}

TXD.transmit_mesh( $scope.device.source, newconf, 2 );

Expand Down
43 changes: 31 additions & 12 deletions www/js/controllers/NodeListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
const MCP_PING_REQUEST = 0;
const MCP_PING_RESPONSE = 1;
const MCP_PING_STATUS = 2; // and beyond is status
const MCP_CONFIG = 0x77; // config packet
const MCP_CONFIG = 0x17; // config packet
const MCP_CONFIG_NAME = 1; // first packet is name
const MCP_CONFIG_DATA = 2; // second is fixed config data
const MCP_LIGHT_STATUS = 8; // subcode 8 is response from light getting command
const MCP_LIGHT_SETLEVEL_NOACK = 0; // subcode set level command with ack, 1
const MCP_LIGHT_SETLEVEL = 1; // subcode set level command with ack, 2 bytes payload
const MCP_LIGHT_SETWHITE = 10; // set level, no ack, one byte payload
const MCP_MULTIBLOCK = 0x75; // sequence and length
const MCP_MULTIBLOCK = 0x15; // sequence and length
const MCP_TRACKER_REPORT = 0x46;


var credentials = CRED.credentials;
Expand Down Expand Up @@ -67,6 +68,12 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
sendPing( $scope.devices[i].source );
}

// start with settings if we get here by browser restart
if( !CRED.credentials.hash ) {
//console.log( "no creds" );
$state.go( 'app.settings' );
}


// The function for loading progress.
$timeout(function () {
Expand Down Expand Up @@ -124,13 +131,14 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
newdevice.device_type = 0x1061;
newdevice.lightlevel = 0;
newdevice.newid = "8001";
newdevice.age = CRED.credentials.age;
console.log( "new CSRlight");

$scope.devices.push(newdevice);
$timeout(function () {
try{ $scope.$apply(); } catch(e){}
});
// update the device in localstorage
newdevice.age = 0;
CRED.updateDevice( newdevice );

};
Expand Down Expand Up @@ -464,7 +472,7 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
// remove data object since we processed all
delete meshdata.data;
//console.log( "ping from "+meshdata.source+" type "+meshdata.device_type );
storeDeviceStatus( meshdata, 0 );
storeDeviceStatus( meshdata, 0, 0 );


} else if(( meshdata.data[0] === MCP_PING )
Expand Down Expand Up @@ -499,7 +507,7 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
// remove data object since we processed all
//console.log("name " + meshdata.name);
delete meshdata.data;
storeDeviceStatus( meshdata, 0 );
storeDeviceStatus( meshdata, 0, 0 );

} else if(( meshdata.data[0] == MCP_CONFIG )&&
( meshdata.data[1] == MCP_CONFIG_DATA )){ // 2
Expand All @@ -509,14 +517,14 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
meshdata.duty_cycle = meshdata.data[3];
meshdata.behavior = meshdata.data[4];
// groups
meshdata.group_0 = meshdata.data[5] + ( meshdata.data[6] * 256 )
meshdata.group_1 = meshdata.data[7] + ( meshdata.data[8] * 256 )
meshdata.group_2 = meshdata.data[9] + ( meshdata.data[10] * 256 )
meshdata.group_0 = meshdata.data[5] + ( meshdata.data[6] * 256 );
meshdata.group_1 = meshdata.data[7] + ( meshdata.data[8] * 256 );
meshdata.group_2 = meshdata.data[9] + ( meshdata.data[10] * 256 );

// remove data object since we processed all
delete meshdata.data;
//console.log("state "+angular.toJson(meshdata));
storeDeviceStatus( meshdata, 0 );
storeDeviceStatus( meshdata, 0, 0 );


} else if(( meshdata.data[0] == MCP_CONFIG )&&
Expand All @@ -540,7 +548,7 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout

console.log("conf " + config_msg.source + " idx " + seq + " len " + len + " " + angular.toJson(config_msg.conf));
// remove data object since we processed all
storeDeviceStatus(config_msg, len, seq);
storeDeviceStatus( config_msg, len, seq );

}

Expand All @@ -566,16 +574,27 @@ appControllers.controller('nodeListCtrl', function( $scope, $rootScope, $timeout
sermsg += String.fromCharCode(meshdata.data[i]);
}
console.log( "send "+meshdata.data[1]+" ser "+sermsg);
CRED.pushSerialData( sermsg );
// push to array: data, source, seq
CRED.pushSerialData( sermsg, meshdata.source-1, meshdata.data[1] );

last_serial_sequence = meshdata.data[1];
// update the screen with the devices content, ngrepeat
$timeout(function () {
try{ $scope.$apply(); } catch(e){}
});

} else if( meshdata.data[0] === MCP_TRACKER_REPORT ) {
meshdata.device_type = 0x1111;
meshdata.owner = config_msg.source;
meshdata.asset = meshdata.data[1] + ( meshdata.data[2] * 256 );
meshdata.distance = meshdata.data[3] + ( meshdata.data[4] * 256 );
// remove data object since we processed all
delete meshdata.data;
//console.log("state "+angular.toJson(meshdata));
storeDeviceStatus( meshdata, 0, 0 );

} else {
console.log("mcp" + meshdata.data[0].toString(16)+" sub "+meshdata.data[1].toString(10)+" dest "+meshdata.dest);
console.log("mcp" + meshdata.data[0].toString(16)+" sub "+meshdata.data[1].toString(10)+" src 0x"+meshdata.source.toString(16));
}
}

Expand Down
27 changes: 15 additions & 12 deletions www/js/controllers/SerialCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
appControllers.controller('serialCtrl', function( $scope, $rootScope, $state, $stateParams, $timeout,
TXD, CRED ) {

const MCP_CONFIG = 0x77;
const MCP_CONFIG = 0x17;

$scope.credentials = CRED.credentials;

$scope.baudid = $scope.device.baud;
$scope.baudlist = [
{ id: 3, speed: '9600' },
{ id: 4, speed: '19200' },
{ id: 5, speed: '38400' },
{ id: 6, speed: '57600' },
{ id: 8, speed: '115200' } ];
{ id: 1, speed: '2400' },
{ id: 3, speed: '9600' },
{ id: 4, speed: '19200' },
{ id: 5, speed: '38400' },
{ id: 6, speed: '57600' },
{ id: 8, speed: '115200' } ];

console.log("serialCtrl "+$scope.device.source);

// start terminal
$scope.navigateTo = function( targetPage, objectData ) {
console.log("nav "+objectData.source );
CRED.setSerialFilter( objectData.source );
$state.go( targetPage, {
device: objectData
});
Expand Down Expand Up @@ -63,7 +65,7 @@ appControllers.controller('serialCtrl', function( $scope, $rootScope, $state, $s
$scope.device.group_0 -= 0x8000;
}

var newconf = new Uint8Array( 11 ); // full config pkg
var newconf = new Uint8Array( 8 ); // full config pkg
// AIRcable SerialMesh config block
// first packet: name 01...
// second 02 02 64 ff 05 00 00 00 00 00
Expand All @@ -77,16 +79,17 @@ appControllers.controller('serialCtrl', function( $scope, $rootScope, $state, $s
newconf[5] = $scope.device.group_0 % 256;
newconf[6] = Math.floor( $scope.device.group_0 / 256 );
newconf[7] = 0;
newconf[8] = 0;
newconf[9] = 0;
newconf[10] = 0;
//newconf[8] = 0;
//newconf[9] = 0;
//newconf[10] = 0;

console.log("config group "+$scope.device.group_0+" on "+$scope.device.source);
TXD.transmit_mesh( $scope.device.source, newconf, 2 );
TXD.transmit_mesh( $scope.device.source, newconf, 3 );

// send finish config after 500ms
clearTimeout( ConfigTimer );
ConfigTimer = setTimeout( secondConfig, 250 );
ConfigTimer = setTimeout( finishConfig, 250 );
//ConfigTimer = setTimeout( secondConfig, 250 );
}
});

Expand Down
Loading

0 comments on commit 9a48b0f

Please sign in to comment.