@@ -6,6 +6,7 @@ import decodeBson from './bson';
66import { codes } from './codes' ;
77import unMap from './unmap' ;
88import { AsyncConfirm , AsyncPrompt } from './ui/dialog' ;
9+ import { changeRSSI , makeRSSI } from './ui/rssi' ;
910
1011const timeout = 2000 ;
1112const anim_s = '.11s' ;
@@ -29,6 +30,7 @@ export default class Settings {
2930 transOut = null ;
3031 authF = false ;
3132 granted = false ;
33+ firstBuild = true ;
3234 auth = 0 ;
3335 ping_prd = 2000 ;
3436
@@ -62,10 +64,10 @@ export default class Settings {
6264 ]
6365 } ,
6466 {
65- tag : 'sup ' ,
66- class : 'error_sup ' ,
67- text : 'Offline! ' ,
68- var : 'offline' ,
67+ tag : 'div ' ,
68+ class : 'rssi ' ,
69+ var : 'rssi ' ,
70+ html : makeRSSI ( ) ,
6971 }
7072 ]
7173 } ,
@@ -275,8 +277,7 @@ export default class Settings {
275277 const res = await this . send ( 'load' ) ;
276278 this . parse ( res ) ;
277279 if ( ! res ) {
278- this . $offline . style . display = 'inline' ;
279- this . offline = true ;
280+ this . setOffline ( true ) ;
280281 this . restartPing ( ) ;
281282 }
282283 }
@@ -334,19 +335,18 @@ export default class Settings {
334335 this . ping_int = setInterval ( async ( ) => {
335336 const res = await this . send ( this . offline ? 'load' : 'ping' ) ;
336337 this . parse ( res ) ;
337- if ( res ) {
338- this . offline = false ;
339- } else {
340- this . offline = true ;
341- this . authF = false ;
342- }
343- this . $offline . style . display = this . offline ? 'inline' : 'none' ;
338+ if ( ! res ) this . authF = false ;
339+ this . setOffline ( ! res ) ;
344340 } , this . ping_prd ) ;
345341 }
346342 stopPing ( ) {
347343 if ( this . ping_int ) clearInterval ( this . ping_int ) ;
348344 this . ping_int = null ;
349345 }
346+ setOffline ( offline ) {
347+ this . offline = offline ;
348+ if ( offline ) changeRSSI ( this . $rssi , 0 ) ;
349+ }
350350
351351 parse ( packet ) {
352352 if ( ! packet ) return ;
@@ -365,13 +365,14 @@ export default class Settings {
365365 this . $auth . style . backgroundColor = this . granted ? 'var(--accent)' : 'var(--error)' ;
366366 this . $ota . style . display = this . granted ? 'inline-block' : 'none' ;
367367 this . $upload . style . display = this . granted ? 'inline-block' : 'none' ;
368- if ( ! this . granted ) popup ( 'Unauthorized' ) ;
368+ if ( ! this . granted && this . firstBuild ) popup ( 'Unauthorized' ) ;
369369 } else {
370370 this . $auth . style . backgroundColor = 'var(--font_tint)' ;
371371 this . granted = true ;
372372 }
373373 }
374374 if ( packet . gzip ) this . $upload_ota . accept = '.gz' ;
375+ this . firstBuild = false ;
375376 break ;
376377
377378 case 'update' :
@@ -384,6 +385,7 @@ export default class Settings {
384385 this . renderFS ( packet ) ;
385386 break ;
386387 }
388+ if ( packet . rssi ) changeRSSI ( this . $rssi , packet . rssi ) ;
387389 }
388390
389391 renderUI ( json ) {
@@ -514,7 +516,7 @@ export default class Settings {
514516 this . restartPing ( ) ;
515517 }
516518 makeUrl ( cmd , params = { } ) {
517- // const base_url = 'http://192.168.1.54 ';
519+ // const base_url = 'http://192.168.1.95 ';
518520 const base_url = window . location . origin ;
519521
520522 if ( this . auth ) params . auth = this . auth . toString ( 16 ) ;
0 commit comments