mirror of
https://github.com/sensebox/blockly-app
synced 2026-02-22 17:35:22 +01:00
fix senseBox connection
This commit is contained in:
parent
aff688eac9
commit
657db355ec
1 changed files with 9 additions and 6 deletions
|
|
@ -7,7 +7,7 @@ declare var WifiWizard2: any;
|
||||||
|
|
||||||
// corresponding to the initial MCU firmware
|
// corresponding to the initial MCU firmware
|
||||||
const SSID_PREFIX = 'sensebox';
|
const SSID_PREFIX = 'sensebox';
|
||||||
const SENSEBOX_API = 'http://192.168.0.1:80';
|
const SENSEBOX_API = 'http://192.168.1.1';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Interface for uploading a binary to a senseBox MCU.
|
Interface for uploading a binary to a senseBox MCU.
|
||||||
|
|
@ -45,7 +45,8 @@ export class OtaWifiProvider {
|
||||||
return WifiWizard2.scan()
|
return WifiWizard2.scan()
|
||||||
.then(networks => {
|
.then(networks => {
|
||||||
if (filterSsids)
|
if (filterSsids)
|
||||||
networks = networks.filter(n => n.SSID.includes(SSID_PREFIX))
|
networks = networks.filter(n => n.SSID.toLowerCase().includes(SSID_PREFIX))
|
||||||
|
networks = networks.filter(n => n.capabilities.includes('[ESS]'))
|
||||||
|
|
||||||
return networks.map(n => n.SSID)
|
return networks.map(n => n.SSID)
|
||||||
})
|
})
|
||||||
|
|
@ -55,15 +56,17 @@ export class OtaWifiProvider {
|
||||||
if (this.strategy != WifiStrategy.Automatic)
|
if (this.strategy != WifiStrategy.Automatic)
|
||||||
throw new Error('can not connect to WiFi network on this platform')
|
throw new Error('can not connect to WiFi network on this platform')
|
||||||
|
|
||||||
return this.platform.is('ios')
|
await this.platform.is('ios')
|
||||||
? WifiWizard2.iOSConnectNetwork(ssid)
|
? WifiWizard2.iOSConnectNetwork(ssid)
|
||||||
: WifiWizard2.connect(ssid, true)
|
: WifiWizard2.connect(ssid, true)
|
||||||
|
|
||||||
// TODO: validate that the MCU server is available
|
// validate that the MCU server is available
|
||||||
|
return this.http.get(`${SENSEBOX_API}/version`).toPromise()
|
||||||
}
|
}
|
||||||
|
|
||||||
async uploadFirmware (blob: ArrayBufferLike): Promise<any> {
|
async uploadFirmware (binary: string): Promise<any> {
|
||||||
return this.http.post(SENSEBOX_API, blob)
|
// TODO: send checksum?
|
||||||
|
return this.http.post(`${SENSEBOX_API}/flash`, binary).toPromise()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue