Skip to content

Commit

Permalink
Merge pull request #7 from CANBus-Triple/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
etx committed Jan 31, 2016
2 parents e9b1d7d + 225e04b commit 0946707
Show file tree
Hide file tree
Showing 11 changed files with 322 additions and 44 deletions.
42 changes: 37 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,57 @@ Android / iOS App for controlling your CANBus Triple via USB or Bluetooth

- [CANBus Triple](http://canb.us)

This software is in an alpha state. Test builds will be available soon.
This software is in an beta state. Builds are available at [https://canb.us](https://canb.us)



# Building for Desktop

You'll need NodeJS and NPM installed to build. Get them here: [NodeJS.org](https://nodejs.org/)

## Mac OS / Linux

```
npm install -g bower gulp
export npm_config_disturl=https://atom.io/download/atom-shell
export npm_config_target=0.36.7
export npm_config_arch=x64
export npm_config_runtime=electron
npm install
bower install
npm install -g node-pre-gyp
cd node_modules/serialport
node-pre-gyp rebuild --runtime=node-webkit --target=0.12.0-alpha3
cd node_modules/serialport/build/Release
mv electron-v0.36-darwin-x64 node-v47-darwin-x64
cd ../../../../
gulp build
```

After a successful build you will find the binaries in ./build
If everything goes according to plan you will find the build in the 'release' folder.


## Windows
You'll need Microsoft Visual Studio Express (2015) community edition [from here.](https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx) and 7zip [from here](http://sourceforge.net/projects/sevenzip/files/7-Zip/).
```
npm install -g bower gulp
set npm_config_disturl=https://atom.io/download/atom-shell
set npm_config_target=0.36.7
set npm_config_arch=x64
set npm_config_runtime=electron
GYP_MSVS_VERSION=2015
npm install
cd node_modules/serialport/build/Release
mv electron-v0.36-win32-x64 node-v47-win32-x64
cd ../../../../
bower install
gulp build
```




# Building for Mobile

**Mobile has been abandon in favor of the upcoming Android app.**

Install android sdks and correctly set your PATH env var.

``
Expand Down
22 changes: 17 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@ var sh = require('shelljs');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var del = require('del');

var gulp = require('gulp');
var electron = require('gulp-electron');
var elecRebuild = require('electron-rebuild');
var packageJson = require('./package.json');
var install = require("gulp-install");

var createInstaller = require('electron-installer-squirrel-windows');



Expand Down Expand Up @@ -129,7 +128,10 @@ gulp.task('electron-copy', ['sass', 'scripts', /*'electron-rebuild', 'electron-c
'node_modules/serialport/build/**/*',
'node_modules/serialport/serialport*.*',
'node_modules/serialport/*.js',
'node_modules/serialport/*.json'
'node_modules/serialport/*.json',
'node_modules/intel-hex/**/*',
'node_modules/electron-squirrel-startup/**/*',
'node_modules/chip.avr.avr109/**/*',
];


Expand Down Expand Up @@ -163,7 +165,17 @@ gulp.task('electron-copy', ['sass', 'scripts', /*'electron-rebuild', 'electron-c

});


gulp.task('electron-installer', [], function(){
var opts = {
"path": "release/v0.36.7/win32-x64/",
"name": "CANBus Triple",
"description": "CANBus Triple Desktop app http://canb.us"
}
createInstaller(opts, function done (err){
if(err)
gutil.log('electron-installer', gutil.colors.red(err), err);
})
});

gulp.task('electron-install', ['electron-copy'], function() {
gulp.src(['./electron-src/package.json'])
Expand All @@ -181,7 +193,7 @@ gulp.task('electron-build', ['electron-copy'], function() {
asar: true,
version: 'v0.36.7',
packaging: true,
platforms: [/*'win32-ia32', 'win32-x64', */'darwin-x64', /*'linux-x64'*/],
platforms: [/*'win32-ia32',*/ 'win32-x64', 'darwin-x64', /*'linux-x64'*/],
platformResources: {
darwin: {
CFBundleDisplayName: packageJson.name,
Expand Down
74 changes: 72 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,71 @@
var app = require('app'); // Module to control application life.

const app = require('electron').app; // Module to control application life.
var BrowserWindow = require('browser-window'); // Module to create native browser window.
var autoUpdater = require('auto-updater');

if(require('electron-squirrel-startup')) return;

var handleStartupEvent = function() {
if (process.platform !== 'win32') {
return false;
}

var squirrelCommand = process.argv[1];
switch (squirrelCommand) {
case '--squirrel-install':
case '--squirrel-updated':

// Optionally do things such as:
//
// - Install desktop and start menu shortcuts
// - Add your .exe to the PATH
// - Write to the registry for things like file associations and
// explorer context menus

// Always quit when done
app.quit();

return true;
case '--squirrel-uninstall':
// Undo anything you did in the --squirrel-install and
// --squirrel-updated handlers

// Always quit when done
app.quit();

return true;
case '--squirrel-obsolete':
// This is called on the outgoing version of your app before
// we update to the new version - it's the opposite of
// --squirrel-updated
app.quit();
return true;
}
};

if (handleStartupEvent()) {
return;
}

var autoUpdater = require('auto-updater');

autoUpdater.setFeedUrl('http://files.canb.us/app/latest-'+process.platform+'?version=' + app.getVersion());
autoUpdater.on('update-downloaded', function(event, releaseNotes, releaseName, releaseDate, updateUrl, quitAndUpdate){
console.info(arguments);
new Notification("CANBus Triple", {"body":"An update has been downloaded for the CANBus Triple App", "icon":__dirname+"/www/img/cbt-128.png"});
quitAndUpdate();
});

autoUpdater.on('checking-for-update', function(){
console.info('checking-for-update');
});
autoUpdater.on('update-available', function(){
console.info('update-available');
});
autoUpdater.on('update-not-available', function(){
console.info('update-not-available');
});


// Report crashes to our server.
require('crash-reporter').start();
Expand All @@ -20,11 +86,12 @@ app.on('window-all-closed', function() {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
app.on('ready', function() {

// Create the browser window.
mainWindow = new BrowserWindow({width: 1280, height: 768, frame: false});

// and load the index.html of the app.
mainWindow.loadUrl('file://' + __dirname + '/www/index.html');
mainWindow.loadURL('file://' + __dirname + '/www/index.html');

// Open the devtools.
//mainWindow.openDevTools();
Expand All @@ -36,4 +103,7 @@ app.on('ready', function() {
// when you should delete the corresponding element.
mainWindow = null;
});

autoUpdater.checkForUpdates();

});
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"browser-sync": "^2.9.1",
"connect": "*",
"del": "^2.0.2",
"electron-installer-squirrel-windows": "^1.2.2",
"electron-prebuilt": "^0.36.7",
"electron-rebuild": "^1.1.2",
"gulp": "^3.9.0",
Expand All @@ -32,6 +33,9 @@
},
"dependencies": {
"cbt-wireshark": "^0.1.1",
"chip.avr.avr109": "^1.0.5",
"electron-squirrel-startup": "^0.1.4",
"intel-hex": "^0.1.1",
"noble": "^1.1.0",
"serialport": "^2.0.6"
}
Expand Down
2 changes: 1 addition & 1 deletion www/css/base.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions www/js/app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
// window.cbtAppDebug = true;

var remote = require('remote');
var app = remote.require('app');
var app = remote.require('electron').app;


/*
* Catch all errors
*/
window.onerror = function(message, url, lineNumber) {
console.error(message, url, lineNumber);
return true;
return false;
};


Expand Down Expand Up @@ -67,7 +67,7 @@ angular.module('cbt', ['ngAnimate', 'ionic', 'ngMaterial', 'LocalStorageModule']
};
}])

.constant('appVersion', '0.2.8-alpha3') // Set app version
.constant('appVersion', app.getVersion()) // Set app version

.config(function($stateProvider, $urlRouterProvider, localStorageServiceProvider) {

Expand Down
Loading

0 comments on commit 0946707

Please sign in to comment.