Skip to content

Instantly share code, notes, and snippets.

@markterrill
Created December 8, 2017 01:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markterrill/7c07891607e79474304e3af34daf5591 to your computer and use it in GitHub Desktop.
Save markterrill/7c07891607e79474304e3af34daf5591 to your computer and use it in GitHub Desktop.
import {Component, Input, ViewChild} from '@angular/core';
import {IonicPage, NavController, NavParams, AlertController} from 'ionic-angular';
import {Logger} from '@nsalaun/ng-logger';
import {FormBuilder, FormGroup} from '@angular/forms';
import {AuthService} from '../../providers/auth-service';
import {LoginPage} from "../login/login"; // required if we need to boot them out
import {SoftAPSetup} from "softap-setup-ts";
import {SmartfireService} from '../../services/smartfire-service';
import {PitType, PitTypeService} from "../../services/pit-type-service";
import {DeviceTypeService} from "../../services/device-type-service";
import {Storage} from '@ionic/storage';
import {ToastController} from 'ionic-angular';
import swal from 'sweetalert2'
let self: SetupPage;
declare let WifiWizard: any;
@IonicPage
({
name: 'Setup',
defaultHistory: ['HomePage'],
segment: 'setup/:preselected'
})
@Component({
selector: 'setup',
templateUrl: 'setup.html',
providers: [PitTypeService, DeviceTypeService]
})
export class SetupPage {
formGroup: FormGroup;
deviceConfig: any = {};
deviceStatus: any = {};
bleDeviceList: any = {}; // subscribing to the smartfire service scan
nearbyList: any = [];
deviceList: any = [];
developmentMode: boolean = false;
sectionProgress: string = "welcome"; //"welcome";
tourStarted: boolean = false; // to deactivate the tour button
private setupMethod: any = null;
private wifi: any = {
securities: [
{value: 'wpa2_aes', label: 'WPA2 AES'},
{value: 'wpa2_mixed', label: 'WPA2 Mixed'},
{value: 'wpa2_tkip', label: 'WPA2 TKIP'},
{value: 'wpa_aes', label: 'WPA AES'},
{value: 'wep_shared', label: 'WEP Shared'},
{value: 'wep_tkip', label: 'WEP TKIP'},
{value: 'open', label: 'Open'}
],
networks: [],
devices: [],
ssid: '',
security: '',
channel: 1,
password: '',
connectedToSFHotspot: false // simple flag for display help text
}; // lets hold a lookup table and what networks we've found
private bleDeviceMAC: string = "";
private bleDeviceName: string = "";
private objSAP: any; // to hold the particle softap browser object
private intervalToCheckSSID: any;
private scanning: boolean = false;
pageTitle: string = "Setup"; // assume large screen is normal
constructor(private logger: Logger,
public smartfireService: SmartfireService,
private _auth: AuthService,
public params: NavParams,
private pitTypeService: PitTypeService,
private deviceTypeService: DeviceTypeService,
public toastCtrl: ToastController,
private storage: Storage,
private fb: FormBuilder,
public navCtrl: NavController) {
// get the current info
this.deviceConfig = smartfireService.getConfig();
self = this;
this.intervalToCheckSSID = null;
smartfireService.configObservable.subscribe(eventData => {
this.deviceConfig = eventData;
});
smartfireService.statusObservable.subscribe(eventData => {
this.deviceStatus = eventData;
for (let deviceID of Object.keys(this.deviceConfig)) {
let wifiConnected = false;
this.logger.debug("setup.ts found statusobservable event " + deviceID);
this.logger.debug(this.deviceStatus[deviceID]);
this.logger.debug("json version:");
this.logger.debug(JSON.stringify(this.deviceStatus[deviceID]));
if (typeof this.deviceStatus[deviceID] != "undefined"
&& this.deviceStatus[deviceID].hasOwnProperty('wifiConnected')) {
if (this.deviceStatus[deviceID].wifiConnected) {
this.logger.log("devices.ts deviceStatus has wifiConnected TRUE");
} else {
this.logger.log("devices.ts deviceStatus has wifiConnected FALSE");
}
//this.logger.debug("current deviceList " + JSON.stringify(this.deviceList));
for (let i in this.deviceList) {
//this.logger.debug("comparing " + this.deviceList[i].id + " == " + deviceID);
if (this.deviceList[i].id == deviceID) {
// Set it to whether we're online
this.deviceList[i].wifiConnected = this.deviceStatus[deviceID].wifiConnected;
this.logger.log("devices.ts statusobs setting " + deviceID + " to " + (this.deviceList[i].wifiConnected ? "online" : "offline"));
}
}
}
}
});
smartfireService.BLEDevicesObservable.subscribe(devices => {
this.bleDeviceList = devices;
/*
'smartfireID': null,
'bleName': null,
'bleMAC': null,
'type': 'controller',
'ignore': false,
'connection': null,
*/
this.nearbyList = Object.keys(devices)
.filter(function (BLEMAC) {
// Don't show BLE devices in 'nearby' list if they're already on the account
//if (img.src.split('.').pop() === "json") {
var foundDevice = false;
for (let i in this.deviceList) {
this.logger.debug("trying devicelist " + i + " : " + this.deviceList[i].bleMAC + " | " + devices[BLEMAC].bleMAC);
if (this.deviceList[i].bleMAC == devices[BLEMAC].bleMAC) {
this.deviceList[i].btAdvertising = true;
//this.deviceList[i].bleMAC == BLEMAC;
this.logger.debug("deviceList updated with BLE: " + JSON.stringify(this.deviceList[i]));
foundDevice = true;
// Connect to it
this.connectBLE(BLEMAC);
// exit the loop
return;
}
}
return !foundDevice;
}, this)
.map(function (BLEMAC) {
//let deviceConfig = smartfireService.getConfig();
console.log("in setup.ts nearby subscribe " + BLEMAC + " " + JSON.stringify(devices[BLEMAC]));
//let deviceConfig = eventData[deviceID];
//let typeObj = deviceTypeService.getDeviceTypeFromSerial(deviceConfig[deviceID].nickname);
var foundDevice = false;
if (foundDevice) {
return false;
} else {
return {
smartfireID: devices[BLEMAC].smartfireID,
'bleName': devices[BLEMAC].bleName,
display: devices[BLEMAC].bleName,
owner: smartfireService.getBLEOwner(devices[BLEMAC].bleMAC),
'bleMAC': devices[BLEMAC].bleMAC,
'type': devices[BLEMAC].type,
icon: 'flame',
btAdvertising: true,
networks: devices[BLEMAC].networks
};
}
}, this);
});
//this.deviceList = Object.keys(smartfireService.getConfig()).map(deviceId => this.deviceConfig[deviceId]);
//this.logger.log(this.deviceList);
_auth.authState.subscribe(data => {
if (this.smartfireService.deviceInfo.smallScreen) {
this.logger.error("thinks its smallScreen!");
this.pageTitle = "Setup";
}
if (_auth.authenticated() == false) {
this.smartfireService.startFresh();
this.logger.warn('NOT authenticated');
//let modal = this.modalCtrl.create(LoginPage, {probe: 2});
//modal.present();
this.navCtrl.push(LoginPage);
}
});
swal.setDefaults({
confirmButtonColor: '#EA161B',
reverseButtons: true,
});
}
getWifiForBle() {
if (this.scanning){
return false;
}
this.scanning = true;
this.wifi.networks = [];
this.logger.debug("in getwififorble for " + this.bleDeviceMAC);
// Trigger a scan for nearby wifi networks
self.smartfireService.scanWifiBLE(self.bleDeviceMAC);
self.setupMethod = 'bt';
self.sectionProgress = 'configure';
// simple timeout is enough as scan is only 4 secs
setTimeout(() => { //<<<--- using ()=> syntax
this.scanning = false;
this.logger.debug("nearbyList is: \n " + JSON.stringify(this.nearbyList));
for (let i in this.nearbyList) {
if (this.nearbyList[i].bleMAC == this.bleDeviceMAC) {
let networks = this.nearbyList[i].networks;
this.logger.debug("in getwififorble, found networks " + JSON.stringify(networks));
/*
// Lets arrange them alphabetically
networks.sort(function (name1, name2) {
if (name1.ssid < name2.ssid) {
return -1;
} else if (name1.ssid > name2.ssid) {
return 1;
} else {
return 0;
}
});
*/
this.wifi.networks = networks;
}
}
}, 3000);
}
ngOnInit() {
//console.log("ngOnInit para lay1", this.probe); // prints [1 ,2, 3]
this.formGroup = this.fb.group({
ssid: [''],
security: [''],
password: '' // this.developmentMode ? 'smartfireWIFI' : ''
});
this.logger.log('doing init for formGroup');
this.formGroup.valueChanges.subscribe((data: any) => {
this.logger.debug('Form changes', data);
if (data.security.length) {
this.wifi.security = data.security;
}
if (data.password.length) {
this.wifi.password = data.password;
}
/*
if (this.boolReceivedDeviceConfig){
//Object.assign(this.deviceConfig, data); // later objects take precedence!
this.deviceConfig.pit.alg.air = data.air;
this.deviceConfig.pit.lid = data.lid;
this.deviceConfig.pit.alg.pWord = data.pWord;
this.deviceConfig.pit.alg.iWord = data.iWord;
this.deviceConfig.pit.alg.dWord = data.dWord;
this.logger.log(' deviceConfig', this.deviceConfig);
// Update the database via smartfireService
// SmartfireService will already have the device config due to object copy
// It's nice to tell smartfireService that it was this device ID and probe that needs updating
this.smartfireService.saveDeviceConfig(this.deviceID); //, this.probeConfig);
}
*/
});
}
onSSIDChange(event) {
this.logger.debug("received onSSIDChange, value is: ", event);
// So now we need to lookup the security via the SSID name
for (let i in this.wifi.networks) {
if (this.wifi.networks[i].label == event) {
this.wifi.security = this.wifi.networks[i].sec;
this.wifi.channel = this.wifi.networks[i].channel;
this.formGroup.controls['security'].setValue(this.wifi.security);
}
}
// Leave this to the end, as soon as its set then security & password are displayed
this.wifi.ssid = event;
if (this.wifi.ssid == 'smartfire')
this.formGroup.controls['password'].setValue('smartfireWIFI');
}
doSaveWifi() {
if (this.setupMethod == 'wifi') {
this.logger.debug("Ready to do config with ", this.wifi);
// Kick off the chain reaction
wifiKey();
} else {
// Trim down the object to what we need
let newSettings = {
ssid: this.wifi.ssid,
channel: this.wifi.channel,
password: this.wifi.password,
security: this.wifi.security
};
// TODO: this.wifi.security needs to be WEP/WPA/WPA2
this.logger.debug("in doSaveWifi, starting BLE based config with " + JSON.stringify(newSettings));
let bleDevice = this.smartfireService.getBLEDeviceByMAC(this.bleDeviceMAC);
this.bleDeviceName = bleDevice.bleName;
this.logger.debug("auth value return bleDevice: " + JSON.stringify(bleDevice));
const promise = this._auth.associateSmartfireDevice(bleDevice.smartfireID, bleDevice.smartfireMD5Auth, bleDevice.smartfireMD5Unix);
promise
.then(_ => {
let msg = 'received fulfilled promise in doSaveWifi, proceeding to sendBLESetCredentials';
this.logger.debug(msg);
// Send wifi creds to BLE device via BLE
this.smartfireService.sendBLESetCredentials(this.bleDeviceMAC, newSettings);
self.logger.debug('Successfully sent connect request. Now wait for breathing cyan!');
self.sectionProgress = 'wificomplete';
// ** By adding a device claim via associateSmartfireDevice it will have triggered a subscription
// within auth-service to add the device to smartfireservice. The following doubles up but forces
// a new connection etc
// We give the firebase database a 1 second head start before trying to connect
setTimeout(() => { //<<<--- using ()=> syntax
// Let's add a firebase database connection to this new device
// This will populate it with default data
// It will also use the BLE device data that is known
let reconnectDatabase = true;
this.smartfireService.addNew(bleDevice.smartfireID, bleDevice, reconnectDatabase);
}, 1050);
})
.catch(err => {
let msg = 'received REJECTED promise in doSaveWifi';
this.logger.error(err, msg)
});
}
/*
function wifiClaim(err, dat) {
if (err) {
console.error('Error getting claim code', err);
return;
}
console.log(dat);
console.log('-------');
console.log('Obtained device information. Setting claim code...');
this.objSAP.setClaimCode('wat', wifiKey);
}
*/
function wifiKey() {
/*
if (err) {
throw err;
}
console.log(dat);
*/
console.log('-------');
console.log('Requesting public key...');
//this.objSAP.publicKey(wifiKeyCB);
self.objSAP.publicKey(wifiConfigure);
}
function wifiKeyCB(err, dat) {
if (err) {
throw err;
}
console.log("wifiKey: " + dat);
//wifiConfigure()
}
function wifiConfigure(err, dat) {
if (err) {
throw err;
}
console.log(dat);
console.log('-------');
console.log('Scanned APs. Configuring device...');
/*
var config = new Config();
let newSettings = {
ssid: config.get('ssid')
, channel: config.get('channel') || 11
, password: config.get('password') || undefined
, security: config.get('security') || undefined
};
*/
// //self.wifi.networks.push({"value": "devTest Network", "label": "devTest Network", "channel": 11, "sec": "wpa2_aes"});
let newSettings = {
ssid: self.wifi.ssid,
channel: self.wifi.channel,
password: self.wifi.password,
security: self.wifi.security
};
self.logger.debug('going to be using ', newSettings);
self.objSAP.configure(newSettings, wifiConnect);
}
function wifiConnect(err, dat) {
if (err) {
throw err;
}
self.logger.debug('Configured device. Issuing connect request...');
self.objSAP.connect(wifiDone);
}
function wifiDone(err, dat) {
if (err) {
throw err;
}
self.logger.debug('Successfully sent connect request. Now wait for breathing cyan!');
self.sectionProgress = 'wificomplete';
//self.startTour();
}
}
startTour() {
// Lets not accept double clicks as navCtrl.pop doesn't like it
if (!this.tourStarted) {
this.tourStarted = true;
this.logger.debug('hi, starting tour');
setTimeout(() => { //<<<--- using ()=> syntax
this.logger.debug('hi, starting tour timeout');
this.presentToast(
'Look up here! We\'ll start a guided tour via tips that will appear here'
, 4500 // how long to present it for
);
setTimeout(() => { //<<<--- using ()=> syntax
this.navCtrl.pop();
this.tourStarted = false;
}, 5000);
}, 10); // delay before starting
}
}
scanBLE() {
// Are we already scanning, disable double click
if (this.scanning) {
return false;
}
// Clear out the current list
this.nearbyList = [];
this.wifi.devices = [];
this.wifi.networks = [];
// flag for page display
this.scanning = true;
this.smartfireService.scanBLE();
// So we're showing up to date info everywhere
//this.deviceStatus = this.smartfireService.getStatus();
this.objSAP = new SoftAPSetup(
{
protocol: 'http',
host: '192.168.0.1',
timeout: 8000 // this is longer as if it actually finds something it may take a while
});
/*
Quick section on checking current SSID
*/
if (typeof WifiWizard !== 'undefined') {
this.logger.log("WifiSSID has BEEN FOUND!");
WifiWizard.getCurrentSSID(this.wifiSSIDFoundCB, this.wifiFailCB);
}
else {
this.logger.warn('WifiWizard not loaded');
}
// Are we sure its not running already?
if (this.intervalToCheckSSID == null) {
// Run the first one immediately
this.objSAP.deviceInfo(this.checkForDeviceCB);
// Create an interval
this.intervalToCheckSSID = setInterval(() => {
this.logger.debug('finished intervalToCheckSSID');
/*
// Lets not accidentally run this at the same time
if (directModeSelected || directModeDesired ){
//console.debug("disabling ssid interval due to directmode selected or desired");
//stopIntervalToCheckSSID();
} else {
// Run the scan
this.objSAP.deviceInfo(checkForDeviceCB);
}
*/
// Run the scan
this.objSAP.deviceInfo(this.checkForDeviceCB);
},
2500); // 2.5 second between scans, interval will be cancelled by the timeout below. stopIntervalToCheckSSID() will also cancel its next run if the callback finds wifi
} else {
this.logger.debug('intervalToCheckSSID already going, skipping');
}
// simple timeout is enough as scan is only 4 secs
setTimeout(() => { //<<<--- using ()=> syntax
this.scanning = false;
this.stopIntervalToCheckSSID();
if (this.developmentMode) {
this.logger.error("in page specific development mode, manually adding test items");
// Add to the networks array
//self.wifi.networks.push({"value": "devTest Network", "label": "devTest Network", "channel": 11, "sec": "wpa2_aes"});
// , "secCode": self.lookupWicedCode('wpa2_aes')
}
}, 4000);
}
stopIntervalToCheckSSID() {
this.logger.debug("running stopIntervalToCheckSSID");
// Lets delete the interval so it doesn't repeat
clearInterval(this.intervalToCheckSSID);
this.intervalToCheckSSID = null;
}
presentToast(message: string, duration?: number) {
const toast = this.toastCtrl.create({
message: message,
duration: duration || 3000,
position: 'top'
});
toast.onDidDismiss(() => {
this.logger.log('Dismissed toast');
});
toast.present();
}
wifiScanForNetworks() {
/*
if (err) {
throw err;
}
console.log(dat);
console.log('-------');
console.log('Received public key. Scanning for APs...');
*/
this.objSAP.scan(this.wifiScanResults);
}
wifiScanResults(err, dat) {
if (err) {
throw err;
}
self.wifi.networks = [];
// Loop through the found networks
for (let i in dat) {
// Find what network type it is based on the numeric code
let sec = self.lookupWicedCode(dat[i].sec);
// Add to the networks array
self.wifi.networks.push({"value": dat[i].ssid, "label": dat[i].ssid, "channel": dat[i].ch, "sec": sec});
}
self.logger.debug('new networks', self.wifi.networks);
// Log to console the network list
self.logger.debug(JSON.stringify(self.wifi.networks));
}
lookupWicedCode(code) {
// Default security to open
var sec = 'open';
console.log('looking up: ' + code);
// Switch between the wiced codes
// https://github.com/asmcos/wiced-emw3165/blob/master/resources/config/scan_page_outer.html
switch (code) {
case 32769:
//sec = 'wep-shared'; // wiced version
sec = "wep_shared"; // soft-ap version
break;
case 2097154:
//sec = 'WPA-TKIP';
sec = "wpa_tkip";
break;
case 2097156:
//sec = 'WPA-AES';
sec = "wpa_aes";
break;
case 4194306:
//sec = 'WPA2-TKIP';
sec = "wpa2_tkip";
break;
case 4194308:
//sec = 'WPA2-AES';
sec = "wpa2_aes";
break;
case 4194310:
//sec = 'WPA2-Mixed';
sec = "wpa2_mixed";
break;
}
// Return the value
return sec;
}
wifiSSIDFoundCB(name) {
self.logger.log("in wifi SSID Found2");
let newName = name.replace(/\"/g, "");
self.logger.debug("WIFI SSID currently is " + newName);
if (newName.indexOf("Smartfire") > -1) {
self.logger.info("Currently connected to a Smartfire device hotspot");
self.wifi.connectedToSFHotspot = true;
self.wifi.ssid = newName;
} else {
self.logger.debug("NOT currently connected to a Smartfire device hotspot");
self.wifi.connectedToSFHotspot = false;
self.wifi.ssid = null;
}
}
wifiFailCB() {
self.logger.error("WifiFail trying to findout current SSID");
self.wifi.connectedToSFHotspot = false;
self.wifi.ssid = null;
}
checkForDeviceCB(err, dat) {
//
if (err) {
// supersonic.logger.error('checkForDeviceCB did NOT find device');
console.debug('checkForDeviceCB did NOT find device');
console.debug(err);
/*
self.checkForDeviceCBErrCount++;
if (self.checkForDeviceCBErrCount > 200) {
self.checkForDeviceCBErrCount = 0;
// Close the page and stop the counter
self.stopIntervalToCheckSSID();
}
*/
}
else {
self.logger.debug("Device ID: ", dat.id, " claimed: ", (dat.claimed ? "yes" : "no"));
self.wifi.devices.push(dat);
self.wifiScanForNetworks();
/*
$scope.deviceStatus = 'search';
console.debug('trying the device id in checkfordevicecb');
// Update the device cached in scope
$scope.device = dat;
//$scope.device.id = $scope.device.id.toLowerCase();
// Get the public key
this.objSAP.publicKey(publicKeyCB);
*/
// Cancel the automatic check for the device
self.stopIntervalToCheckSSID();
}
}
ionViewWillEnter() {
this.logger.debug("ionViewWillEnter trigger on devices.ts");
// Preselected is to enable folk to choose to go to setup from the devices page
// it'll either be 'wifi' to continue with hotspot setup, or a BLE MAC
let preselected = this.params.get('preselected');
this.logger.debug("preselected is ", preselected);
if (typeof preselected == "undefined") {
this.scanBLE();
}
else {
if (preselected == 'wifi') {
// Simply means we're actively connected to the wifi hotspot and the user wants to continue setup
this.logger.debug("We preselected to continue wifi setup");
this.setupMethod = 'wifi';
this.sectionProgress = 'configure';
} else if (preselected.indexOf(":") > -1) {
// Means we're BLE and got a MAC
this.logger.debug("We preselected to start BLE setup with: " + preselected);
// Remember the chosen one
this.bleDeviceMAC = preselected;
// Trigger a scan for nearby wifi networks
this.smartfireService.scanWifiBLE(this.bleDeviceMAC);
this.setupMethod = 'ble';
this.sectionProgress = 'configure';
this.logger.warn("got nothing in here, more to do!!")
//TODO: BLE connection etc etc, make sure we've got their scanned networks, etc.
} else {
this.sectionProgress = preselected;
if (preselected == 'wificomplete') {
//self.startTour();
}
}
}
}
deviceSelected(device: string) {
this.logger.log('open device settings with: ', device);
this.navCtrl.push('DeviceSettings', {'id': device});
}
connectBLE(bleDeviceMAC: string) {
this.smartfireService.connectBLE(bleDeviceMAC);
}
promptWifi() {
swal({
//input: 'number',
showCancelButton: true,
confirmButtonText: 'Yes',
title: 'Confirm device',
html: "You are connected to <br>" +
this.wifi.ssid + "<br> Continue?",
/*
showLoaderOnConfirm: true,
preConfirm: function (n) {
return new Promise(function (resolve, reject) {
//let msg = 'Please enter a valid pit target';
return "done";
})
},
*/
allowOutsideClick: false
}).then(function () {
self.logger.debug("about to go to wifi setup mode for " + self.wifi.ssid);
self.setupMethod = 'wifi';
self.sectionProgress = 'configure';
/*
swal({
type: 'success',
title: 'Smartfire connected',
text: 'Set pit target to ' + bleDeviceMAC,
timer: 2000
}).catch(swal.noop);
*/
},
function (dismiss) {
// dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
if (dismiss === 'cancel') {
/*
swal(
'Cancelled',
'Your imaginary file is safe :)',
'error'
)
*/
}
});
}
promptBLE(bleDeviceMAC: string) {
let doIt = false;
if (this.developmentMode && doIt) {
this.nearbyList["D8:80:39:F0:CB:D3"] = {
smartfireID: "makebelieveID",
'bleName': "SMARTFIRE CTL-DEV!",
display: "SMARTFIRE CTL-DEV!",
owner: this.smartfireService.getBLEOwner("D8:80:39:F0:CB:D3"),
'bleMAC': "D8:80:39:F0:CB:D3",
'type': "controller",
icon: 'flame',
btAdvertising: true,
networks: []
};
}
this.logger.debug("nearbyList is currently");
this.logger.debug(JSON.stringify(this.nearbyList));
let nearbyIndex = '';
for (let i in this.nearbyList) {
//this.logger.debug("trying " + i);
if (this.nearbyList[i].bleMAC == bleDeviceMAC) {
nearbyIndex = i;
this.logger.debug('found it ' + i);
}
}
if (nearbyIndex == '') {
this.logger.error("somehow the device disappeared from nearby list");
return false;
}
let owner = '';
this.nearbyList[nearbyIndex].owner.then(res => {
owner = res;
this.logger.debug("BLE device owner: " + owner); // will resolve to null if it couldn't find it
let display = this.nearbyList[nearbyIndex].display;
let htmlString = display + "<br>";
if (owner != null && owner.length) {
htmlString += owner + "<br>";
}
htmlString += "<br>Continue?";
swal({
//input: 'number',
showCancelButton: true,
confirmButtonText: 'Yes',
title: 'Confirm device',
html: htmlString,
/*,
showLoaderOnConfirm: true,
preConfirm: function () {
return new Promise(function (resolve, reject) {
/*
setTimeout(function() {
if (email === 'taken@example.com') {
reject('This email is already taken.')
} else {
resolve()
}
}, 2000)
* /
});
},
*/
allowOutsideClick: false
}).then(function () {
self.logger.debug("confirmed " + bleDeviceMAC + " in setup");
// Remember the chosen one
self.bleDeviceMAC = bleDeviceMAC;
self.getWifiForBle();
/*
swal({
type: 'success',
title: 'Smartfire connected',
text: 'Set pit target to ' + bleDeviceMAC,
timer: 2000
}).catch(swal.noop);
*/
}, function (dismiss) {
// dismiss can be 'overlay', 'cancel', 'close', 'esc', 'timer'
if (dismiss === 'cancel') {
self.logger.debug("cancelled the ble connect");
}
});
});
}
addNewDevice() {
this.logger.log('add new device button click');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment