diff --git a/app/www/index.html b/app/www/index.html
index 7298e13..86f1631 100644
--- a/app/www/index.html
+++ b/app/www/index.html
@@ -70,6 +70,8 @@
+
+
WIFI
@@ -79,6 +81,7 @@
+
diff --git a/app/www/static/css/index.css b/app/www/static/css/index.css
index d64fc43..675d780 100644
--- a/app/www/static/css/index.css
+++ b/app/www/static/css/index.css
@@ -37,7 +37,7 @@ html,body,button,h2,label,input{
}
body{
- padding-top: 15px;
+ padding-top: 35px;
}
.page{
padding: 5px 10% 0 10%;
@@ -142,7 +142,7 @@ button{
border-radius: 5px;
color: #fff;
font-size: 18px;
- background: transparent;
+ background: #363636;
-webkit-appearance: none;
box-shadow: none;
outline: none;
@@ -274,3 +274,11 @@ footer > div.selected{
#spinner{
margin-top: 200px;
}
+
+#disconnect,#scan{
+ display: none;
+}
+#disconnect.active,
+#scan.active{
+ display: block;
+}
diff --git a/app/www/static/js/intval.mobile.js b/app/www/static/js/intval.mobile.js
index 46669ce..6254471 100644
--- a/app/www/static/js/intval.mobile.js
+++ b/app/www/static/js/intval.mobile.js
@@ -19,15 +19,15 @@ mobile.ble.scan = function () {
mobile.ble.devices = [];
setTimeout(() => {
if (!mobile.ble.connected) {
- ble.stopScan(() => {}, mobile.ble.onError);
spinnerHide();
alert('No INTVAL devices found.');
+ settingsPage();
}
}, 5000)
};
mobile.ble.onDiscover = function (device) {
- if (device && device.name && device.name === 'intval3') {
+ if (device && device.name && device.name.indexOf('intval3') !== -1) {
console.log('BLE - Discovered INTVAL');
console.dir(device);
mobile.ble.devices.push(device);
@@ -47,19 +47,36 @@ mobile.ble.connect = function (device) {
};
mobile.ble.onConnect = function (peripheral, device) {
+ const elem = document.getElementById('bluetooth')
+ const option = document.createElement('option')
+ const disconnect = document.getElementById('disconnect');
+ const scan = document.getElementById('scan');
+
spinnerHide();
- ble.stopScan(() => {}, moble.ble.onError);
console.log(`BLE - Connected to ${device.id}`);
console.log(peripheral);
console.dir(device);
+
mobile.ble.device = device;
mobile.ble.connected = true;
-
+
+ elem.innerHTML = '';
+ option.text = device.name;
+ option.value = device.id;
+ elem.add(option);
+
+ disconnect.classList.add('active');
+ scan.classList.remove('active');
+
getState();
};
mobile.ble.disconnect = function () {
- let device
+ const elem = document.getElementById('bluetooth');
+ const option = document.createElement('option');
+ const disconnect = document.getElementById('disconnect');
+ const scan = document.getElementById('scan');
+ let device;
if (!mobile.ble.connected) {
console.warn('Not connected to any device')
return false
@@ -67,6 +84,13 @@ mobile.ble.disconnect = function () {
device = mobile.ble.device
console.log(`BLE - Disconnecting from ${device.id}`)
ble.disconnect(device.id, mobile.ble.onDisconnect, mobile.ble.onDisconnect);
+
+ elem.innerHTML = '';
+ option.text = 'N/A';
+ elem.add(option);
+
+ disconnect.classList.remove('active');
+ scan.classList.add('active');
};
mobile.ble.onDisconnect = function (res) {
diff --git a/index.js b/index.js
index c2159cb..193cd2c 100644
--- a/index.js
+++ b/index.js
@@ -314,10 +314,10 @@ function bFrame (obj, cb) {
}
}
log.info('frame', { method : 'ble', dir : dir, exposure : exposure })
- /*intval.frame(dir, exposure, (len) => {
+ intval.frame(dir, exposure, (len) => {
return cb()
- })*/
- setTimeout(cb, exposure === 0 ? 630 : exposure)
+ })
+ //setTimeout(cb, exposure === 0 ? 630 : exposure)
}
function bDir (obj, cb) {
diff --git a/lib/ble/index.js b/lib/ble/index.js
index c4812a3..4351dea 100644
--- a/lib/ble/index.js
+++ b/lib/ble/index.js
@@ -9,13 +9,14 @@ const os = require('os')
const log = require('../log')('ble')
const wifi = require('../wifi')
-const DEVICE_NAME = process.env.DEVICE_ID || 'intval3'
+const DEVICE_NAME = process.env.DEVICE_NAME || 'intval3'
const SERVICE_ID = process.env.SERVICE_ID || 'intval3_ble'
const CHAR_ID = process.env.CHAR_ID || 'intval3char'
const WIFI_ID = process.env.WIFI_ID || 'wifichar'
const NETWORK = os.networkInterfaces()
const MAC = getMac() || spoofMac()
+//Give the device a unique device name, needs to be in env
process.env.BLENO_DEVICE_NAME += '_' + MAC
const bleno = require('bleno')
diff --git a/process.json b/process.json
index f62bc31..c38a3d6 100644
--- a/process.json
+++ b/process.json
@@ -6,7 +6,7 @@
"watch" : false,
"env" : {
"BLENO_DEVICE_NAME" : "intval3",
- "DEVICE_ID" : "intval3",
+ "DEVICE_NAME" : "intval3",
"SERVICE_ID" : "149582bd-d49d-4b5c-acd1-1ae503d09e7a",
"CHAR_ID" : "47bf69fb-f62f-4ef8-9be8-eb727a54fae4",
"WIFI_ID" : "3fe7d9cf-7bd2-4ff0-97c5-ebe87288c2cc",