Push dev work to master #2
|
@ -70,6 +70,8 @@
|
|||
<select id="bluetooth">
|
||||
<option>N/A</option>
|
||||
</select>
|
||||
<button id="disconnect" onclick="mobile.ble.disconnect();">DISCONNECT</button>
|
||||
<button id="scan" class="active" onclick="mobile.ble.scan();">SCAN FOR DEVICE</button>
|
||||
</div>
|
||||
<div class="ble">
|
||||
<h2>WIFI</h2>
|
||||
|
@ -79,6 +81,7 @@
|
|||
<div>
|
||||
<input type="password" id="password" placeholder="Wifi Password" />
|
||||
</div>
|
||||
<button id="wifi" onclick="alert('WIFI');">CONNECT</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mscript" class="page">
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
6
index.js
6
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) {
|
||||
|
|
|
@ -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')
|
||||
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue