From c53d8eecdcbd63eb26e758d59f6135ac57f75a1f Mon Sep 17 00:00:00 2001 From: Jo Date: Thu, 28 Nov 2024 17:35:27 +0100 Subject: [PATCH] Cosmetics --- ble_api/index.html | 7 +++++++ ble_api/js/blx.js | 2 +- ble_api/js/blxdash.js | 4 ++-- ble_api/js/jodash.js | 2 +- ble_api/sw.js | 2 +- ble_api/sw.js.map | 2 +- 6 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ble_api/index.html b/ble_api/index.html index 7a6c81f..9e41bf4 100644 --- a/ble_api/index.html +++ b/ble_api/index.html @@ -2,8 +2,15 @@ + + diff --git a/ble_api/js/blx.js b/ble_api/js/blx.js index ad0ec5c..7177566 100644 --- a/ble_api/js/blx.js +++ b/ble_api/js/blx.js @@ -1 +1 @@ -let blx=(()=>{let te="V1.22 / 11.10.2024",ae="(C)JoEmbedded.de";async function _(t=1){return new Promise(e=>setTimeout(e,t))}let c=3988292384;function ie(t){let a=4294967295;for(let e=0;e>>0;for(let e=0;e<8;e++)1&a?a=a>>>1^c:a>>>=1}return a>>>0}let F={},g=!1,B,ne="5c170001-b5a3-f393-e0a9-a37f42997c22",d="5c170002-b5a3-f393-e0a9-a37f42997c22",f="5c170003-b5a3-f393-e0a9-a37f42997c22",M,R,u,L=!1,re=!1,P="",U=!1,m,K=!1,w=!1,V=0,S,o="?",G={total:0,incnew:0,max:-1,mode:0},E=!1,O=0,v=3,b=16,C=17,I=32,x=33,A=34,D=35,T=1e4,N="unknown.dat",p,oe,se,le,ce,de,h,y,k,fe,ue,z,ve=20,Re=40,be,ge,me=!1,we=!1,W="3",H="15",X;function pe(){R=void 0,u=void 0,L=!1,g=!1,re=!1,U=!1,m=void 0,!(K=!1)===w&&"R"!==o?(Q("Disconnected while Busy('"+o+"')"),V="ERROR: Disconnected ('"+o+"')"):Q("Disconnected"),w=!1,B&&(void 0!==M?B("CON",1,"Reconnectable"):B("CON",0,"Disconnected"))}function he(e){var e=new Uint8Array(e.target.value.buffer),r=e.length;if(r<2)Q("ERROR(Data): NUS RX blocklen: "+r),console.log(e);else{var o=e[0];if(o+2!==r)Q("ERROR(Data): NUS RX blocklen/dlen(0): "+r+"/"+o),console.log(e);else{var s,r=e[1],l=e.subarray(2);let a,i,n,t;switch(r){case D:if(Ve(),"~"===(a=(new TextDecoder).decode(l)).charAt(0)&&1=ve&&i<250?(Q("BLE Blocksize: "+(be=i)+" Bytes"),ii)V="ERROR: Too many data";else{y.set(l,k),k+=o;var b=Date.now();if(1e3=i)break;var o="Failed, Retry to connect ("+(i-t+1)+" left)...";B&&B("WARN",5,o),Q(o)}L&&(a&&await Ie(!1),await Y(),!0===U)&&ze(500)}}async function a(){if(g){g=!1;var e=F.deviceMAC+"_#BlxIDs";try{await blStore.set(e,F)}catch(e){V="ERROR(CheckIDs): "+e}}}async function q(e,t=T){if(!0===w)console.warn("*** BLX BUSY (Since "+(Date.now()-S).toFixed(0)+" msec) ***");else{if(!0!==L){if(void 0===M)return void(V="ERROR(DeviceCmd): Not Connected!");if(await ye(0,1),V)return}!1===(K=e.startsWith("#")?!0:K)&&(w=!0),o=e,S=Date.now();var[e,a=b]=[e],i=e.length,n=new Uint8Array(i+2),r=n.subarray(2),i=(n[0]=i,n[1]=a,(new TextEncoder).encodeInto(e,r));if(void 0!==i)try{R.writeValue(n.buffer)}catch(e){let t;t=!1===L?"Connection lost":e,V="ERROR(DeviceSend): "+t}if(await 0,!1===K){a=t;for(O=a;!0===w;)if(await _(10),(O-=10)<0){V="ERROR(DeviceCmd): Timeout ('"+o+"')";break}await 0,w=!1}}}function s(t){let a=-1;for(let e=0;ep?V="ERROR(SysCmd): Out of range of File":(de=t,B&&B("GET",e,n),await xe(t,e,i),V||(async()=>{if(void 0!==k&&k)if(void 0===y||y.length!==h)V="ERROR(Store): Inconsistent Data";else{var e=F.deviceMAC+"_"+N,t=[];t.total_len=p,t.pos0=de,t.akt_len=h,t.ctime=oe,t.crc32=se,t.ucl_flag=le,t.esync_flag=ce,t.bytebuf=y,t.tssync=void 0;try{await blStore.set(e,t)}catch(e){return V="ERROR(Store): "+e}Q("Save to Store '"+e+"'"),y=void 0,z=e}else V="ERROR(Store): No Data to store"})())}}}async function Se(e,t){var a,i,n=s(e);if(0<=n){if(await blStore.get(F.deviceMAC+"_"+e),void 0===(a=blStore.result())||!0===t)await ke([0,e],!1),V;else if(0<(t=F.disk.files[n].len-a.v.akt_len)&&(B&&B("GET",t,e),Q('Get File (Missing Part) "'+e+'": Len: '+t+" Bytes"),n=e,e=a.v.akt_len,i=t,p=-1,N=void 0,z=void 0,await q("N:"+n),await(!V&&!(p<0?V="ERROR(SysCmd): No File '"+n+"'":(se=0,le=!0,ce=!1,await xe(de=e,p=i,!1)))),!V))if(y.length!==t)V="ERROR(upload): Read Len";else{(n=new Uint8Array(a.v.bytebuf.length+t)).set(a.v.bytebuf),n.set(y,a.v.bytebuf.length),a.v.bytebuf=n,a.v.total_len+=t,a.v.akt_len+=t,a.v.tssync=void 0;try{await blStore.set(a.k,a.v)}catch(e){V="ERROR(upload): "+e}}}else V=""}async function Y(){for(let e=0;e<3&&(await _(1e3),X=-1,void 0===R?V="Disconnected":await q("CS",32e3),!V)&&!(0'data.edt.old'"),!0===e))try{await blStore.remove(F.deviceMAC+"_data.edt"),await blStore.set(i.k,i.v)}catch(e){return void(V="ERROR(Store): "+e)}if(null!=i&&(a<0||F.disk.files[a].date.getTime()!==i.v.ctime.getTime())&&(a=-1,!(i=void 0)===e))try{await blStore.remove(F.deviceMAC+"_data.edt.old")}catch(e){return void(V="ERROR(Store): "+e)}if(null!=n&&(t<0||F.disk.files[t].date.getTime()!==n.v.ctime.getTime())&&!(n=void 0)===e)try{await blStore.remove(F.deviceMAC+"_data.edt")}catch(e){return void(V="ERROR(Store): "+e)}0<=t&&(G.total+=F.disk.files[t].len),0<=a&&(G.total+=F.disk.files[a].len),G.incnew=G.total,null!=n&&(G.incnew-=n.v.akt_len),null!=i&&(G.incnew-=i.v.akt_len),V=0}async function Ce(e){var i=e.split(" ");let t,a;var n,r,o,s=i[0].toLowerCase();if(!0===K)V='ERROR(Modem): Exit Modem Terminal ("~")!';else switch(s){case"?":Q(`Blx Terminal Version: ${te}, `+ae);break;case"q":case"quit":Me();break;case"cls":$=[],void 0!==Z&&(document.getElementById("blxTerminalOut").innerText="(cleared)");break;case"s":case"store":try{if(i.length<=1){await blStore.count();let n=0,r=Date.now();Q("Store: "+blStore.result()+" Items"),await blStore.iterate(function(e){a=r-e.ts,t="",86400<=(a/=1e3)&&(a-=86400*(i=Math.floor(a/86400)),t+=i+"d"),a-=3600*(i=Math.floor(a/3600)),i<10&&(t+="0"),t+=i+"h",(i=Math.floor(a/60))<10&&(t+="0"),t+=i+"m",(a-=60*i)<10&&(t+="0");var t,a,i=t+=Math.floor(a)+"s";void 0!==e.v.akt_len?(a=e.v.akt_len,n+=a,Q("'"+e.k+"' ("+i+")': "+a+" Bytes")):Q("'"+e.k+"' ("+i+")'")}),Q("Total Data: "+(n/1024).toFixed(0)+" kB")}else switch(i[1]){case"c":case"clear":await blStore.clearStore(),Q("Store cleared");break;case"r":case"remove":{let e;e=i.length<3?z:i[2],await blStore.remove(e),Q("Removed '"+e+"' from Store")}break;case"l":case"list":try{let e;if(void 0===(e=i.length<3?z:i[2])){V="ERROR(Store): No Key";break}await blStore.get(e);var l=blStore.result();if(void 0===l){V="ERROR(Store): No Value for this Key";break}var c,d=(new TextDecoder).decode(l.v.bytebuf),f=d.replace(/\r/g,"").split(/\n/),u=(f.pop(),J);J "+f.length+" Lines");let t=0;for(c of f)Q(t+": "+(c.length?c:"(empty)")),t++;J=u}catch(e){V="ERROR(Store): "+e}break;case"m":case"modify":try{let e;var v=i[2];if(void 0===v){V="ERROR(Store): No Index";break}var R=i[3];if(void 0===(e=i.length<5?z:i[4])){V="ERROR(Store): No Key";break}await blStore.get(e);var b=blStore.result();if(void 0===b){V="ERROR(Store): No Value for this Key";break}var g=(new TextDecoder).decode(b.v.bytebuf).replace(/\r/g,"").split(/\n/);if(g.pop(),v<0||v>g.length){V="ERROR(Store): Index Range";break}var m=g[v],w=(Q("Old: "+v+": "+(m.length?m:"(empty)")),g[v]=R,Q("New: "+v+": "+((m=g[v]).length?m:"(empty)")),new TextEncoder),p=(b.v.bytebuf=w.encode(g.join("\n")+"\n"),b.v.bytebuf.length);b.v.akt_len=p,b.v.crc32=ie(b.v.bytebuf),b.v.ctime=new Date,b.v.pos0=0,b.v.total_len=p,b.v.ucl_flag=!1,b.v.tssync=void 0,await blStore.set(e,b.v)}catch(e){V="ERROR(Store): "+e}break;default:V="ERROR(Store): Unknown Cmd"}}catch(e){V="ERROR(Store): "+e}break;case"e":case"export":try{let e;e=i.length<2?z:i[1],await blStore.get(e);var h=blStore.result();if(void 0===h){V="ERROR(StoreExport): Key not found";break}var y=h;try{if(void 0!==y.v&&void 0!==y.v.total_len&&y.v.total_len){var k=y.k.lastIndexOf(".");let e="application/octet-binary";if(1{e=e.target.files[0];Q('Selected File:"'+e.name+'" Size:'+e.size+" LastModified: ["+e.lastModifiedDate.toLocaleDateString()+" "+e.lastModifiedDate.toLocaleTimeString()+"]");let t=new FileReader;t.onload=async function(){var e=new Uint8Array(t.result);e.length?rd&&(e=d);var f=new Uint8Array(e+2),u=(f[0]=e,f[1]=C,t.subarray(r,r+e));if(f.set(u,2),await R.writeValue(f.buffer),n-=e,r+=e,!n){var v=Date.now()-s;Q("Transfer OK ("+v/1e3+" sec, "+(t.length/v*1e3).toFixed(0)+" Bytes/sec)");break}1e3<(o=Date.now())-l&&(l=o,Q((100*r/t.length).toFixed(0)+"% / "+r+" Bytes"))}}catch(e){return void(V=!1===L?"ERROR: Connection lost":"ERROR: Transfer "+e)}await q("L",5e3),V||1e3{let a=e.target.files[0];if(Q('Selected File:"'+a.name+'" Size:'+a.size+" LastModified: ["+a.lastModifiedDate.toLocaleDateString()+" "+a.lastModifiedDate.toLocaleTimeString()+"]"),void 0!==r&&".sec"==r){e="firmware_typ"+F.deviceType+"_";if(!a.name.startsWith(e)&&"_firmware.sec"==!a.name)return void Q(V="ERROR: No Firmware File for this Device")}let i=new FileReader;i.onload=async function(){var t=new Uint8Array(i.result);if(t.length){let e=a.name;await Ae(t,e=void 0!==r&&".sec"==r?"_firmware.sec":e,n),V&&Q(V),void 0!==r&&".sec"==r&&(Q("Reset Device"),await q("R",2e3),await _(1e3),V=0)}else Q(V="ERROR: File is empty")},i.readAsArrayBuffer(a)},Q("Select File or Cancel"),e.click()}let Te=25,J,Z,$=[];function Q(e){for(void 0!==e?$.push(e):$[0]="*** BLX Terminal ***";$.length>J;)$.shift();void 0!==Z&&(document.getElementById("blxTerminalOut").innerText=$.join("\n"))}function Ne(e){13===e.keyCode||10===e.keycode?(e.preventDefault(),document.getElementById("blxTerminalSend").click()):27===e.keyCode&&(e.preventDefault(),document.getElementById("blxTerminalCmd").value="")}function _e(e){void 0!==Z&&(document.getElementById("blxTerminalSend").disabled=!e)}let Fe="";async function Be(){var e=document.getElementById("blxTerminalCmd");let t=e.value.trim();e.value="",e.focus(),Q("> "+t),_e(!1),ee(1e3,.05,.1),V=0,"*"==t&&Fe.length?t=Fe:t.length&&(Fe=t),"help"==t||"-h"==t||"/h"==t||"-?"==t||"/?"==t?(Q(HELP),Q(ae)):(t.startsWith(".")?await Ce(t.substring(1)):await q(t),await a(),V&&(Ge(),Q(V)),_e(!0))}function Me(e,t,a=Te){void 0!==e?(J=a,(Z=document.getElementById(e)).innerHTML="
",document.getElementById("blxTerminalCmd").addEventListener("keyup",Ne),document.getElementById("blxTerminalSend").addEventListener("click",Be),Q(),_e(!0)):(void 0!==Z&&(Z.innerHTML=""),Z=void 0),void 0!==t&&(B="function"==typeof t?t:void 0)}function l(t,e){var a="@"+e;for(let e=0;e 14 Parameters/Channel!";return e}function i(e,t,a){e=parseInt(e);return!!(isNaN(e)||e{if(t=t,Q("=> "+(e=(e=e).trim())),V=0,e.startsWith(".")?await Ce(e.substring(1)):null!=t?await q(e,t):await q(e),await a(),await!(V&&(Q(V),B)&&B("ERR",0,V)),V)throw V;if(!0===w)throw new Error("*** BLX BUSY (Since "+(Date.now()-S).toFixed(0)+" msec) ***")},terminalPrint:Q,getDevice:()=>F,getMemory:()=>G,getPinOK:()=>U,frq_ping:ee,chordsound:ze,getCrc32:ie,IparamAddChannel:function(t,a){let e=0;var i=parseInt(t[2]);let n;for(;;){var r=l(t,e);if(r<0)break;if(e++,n=r,e>=i)return!1}var o=Le(t);t.push("@"+e);for(let e=0;e{let te="V1.23 / 28.11.2024",ae="(C)JoEmbedded.de",a="";async function _(t=1){return new Promise(e=>setTimeout(e,t))}let c=3988292384;function ie(t){let a=4294967295;for(let e=0;e>>0;for(let e=0;e<8;e++)1&a?a=a>>>1^c:a>>>=1}return a>>>0}let F={},g=!1,B,ne="5c170001-b5a3-f393-e0a9-a37f42997c22",d="5c170002-b5a3-f393-e0a9-a37f42997c22",f="5c170003-b5a3-f393-e0a9-a37f42997c22",M,R,u,L=!1,re=!1,P="",U=!1,m,K=!1,w=!1,V=0,S,o="?",G={total:0,incnew:0,max:-1,mode:0},E=!1,O=0,v=3,b=16,C=17,I=32,x=33,A=34,D=35,T=1e4,N="unknown.dat",p,oe,se,le,ce,de,h,y,k,fe,ue,z,ve=20,Re=40,be,ge,me=!1,we=!1,W="3",H="15",X;function pe(){R=void 0,u=void 0,L=!1,g=!1,re=!1,U=!1,m=void 0,!(K=!1)===w&&"R"!==o?(Q("Disconnected while Busy('"+o+"')"),V="ERROR: Disconnected ('"+o+"')"):Q("Disconnected"),w=!1,B&&(void 0!==M?B("CON",1,"Reconnectable"):B("CON",0,"Disconnected"))}function he(e){var e=new Uint8Array(e.target.value.buffer),r=e.length;if(r<2)Q("ERROR(Data): NUS RX blocklen: "+r),console.log(e);else{var o=e[0];if(o+2!==r)Q("ERROR(Data): NUS RX blocklen/dlen(0): "+r+"/"+o),console.log(e);else{var s,r=e[1],l=e.subarray(2);let a,i,n,t;switch(r){case D:if(Ge(),"~"===(a=(new TextDecoder).decode(l)).charAt(0)&&1=ve&&i<250?(Q("BLE Blocksize: "+(be=i)+" Bytes"),ii)V="ERROR: Too many data";else{y.set(l,k),k+=o;var b=Date.now();if(1e3=i)break;var o="Failed, Retry to connect ("+(i-t+1)+" left)...";B&&B("WARN",5,o),Q(o)}L&&(a&&await xe(!1),await Y(),!0===U)&&We(500)}}async function ke(){if(g){g=!1;var e=F.deviceMAC+"_#BlxIDs";try{await blStore.set(e,F)}catch(e){V="ERROR(CheckIDs): "+e}}}async function q(e,t=T){if(!0===w)console.warn("*** BLX BUSY (Since "+(Date.now()-S).toFixed(0)+" msec) ***");else{if(!0!==L){if(void 0===M)return void(V="ERROR(DeviceCmd): Not Connected!");if(await ye(0,1),V)return}!1===(K=e.startsWith("#")?!0:K)&&(w=!0),o=e,S=Date.now();var[e,a=b]=[e],i=e.length,n=new Uint8Array(i+2),r=n.subarray(2),i=(n[0]=i,n[1]=a,(new TextEncoder).encodeInto(e,r));if(void 0!==i)try{R.writeValue(n.buffer)}catch(e){let t;t=!1===L?"Connection lost":e,V="ERROR(DeviceSend): "+t}if(await 0,!1===K){a=t;for(O=a;!0===w;)if(await _(10),(O-=10)<0){V="ERROR(DeviceCmd): Timeout ('"+o+"')";break}await 0,w=!1}}}function s(t){let a=-1;for(let e=0;ep?V="ERROR(SysCmd): Out of range of File":(de=t,B&&B("GET",e,n),await Ae(t,e,i),V||(async()=>{if(void 0!==k&&k)if(void 0===y||y.length!==h)V="ERROR(Store): Inconsistent Data";else{var e=F.deviceMAC+"_"+N,t=[];t.total_len=p,t.pos0=de,t.akt_len=h,t.ctime=oe,t.crc32=se,t.ucl_flag=le,t.esync_flag=ce,t.bytebuf=y,t.tssync=void 0;try{await blStore.set(e,t)}catch(e){return V="ERROR(Store): "+e}Q("Save to Store '"+e+"'"),y=void 0,z=e}else V="ERROR(Store): No Data to store"})())}}}async function Ee(e,t){var a,i,n=s(e);if(0<=n){if(await blStore.get(F.deviceMAC+"_"+e),void 0===(a=blStore.result())||!0===t)await Se([0,e],!1),V;else if(0<(t=F.disk.files[n].len-a.v.akt_len)&&(B&&B("GET",t,e),Q('Get File (Missing Part) "'+e+'": Len: '+t+" Bytes"),n=e,e=a.v.akt_len,i=t,p=-1,N=void 0,z=void 0,await q("N:"+n),await(!V&&!(p<0?V="ERROR(SysCmd): No File '"+n+"'":(se=0,le=!0,ce=!1,await Ae(de=e,p=i,!1)))),!V))if(y.length!==t)V="ERROR(upload): Read Len";else{(n=new Uint8Array(a.v.bytebuf.length+t)).set(a.v.bytebuf),n.set(y,a.v.bytebuf.length),a.v.bytebuf=n,a.v.total_len+=t,a.v.akt_len+=t,a.v.tssync=void 0;try{await blStore.set(a.k,a.v)}catch(e){V="ERROR(upload): "+e}}}else V=""}async function Y(){for(let e=0;e<3&&(await _(1e3),X=-1,void 0===R?V="Disconnected":await q("CS",32e3),!V)&&!(0'data.edt.old'"),!0===e))try{await blStore.remove(F.deviceMAC+"_data.edt"),await blStore.set(i.k,i.v)}catch(e){return void(V="ERROR(Store): "+e)}if(null!=i&&(a<0||F.disk.files[a].date.getTime()!==i.v.ctime.getTime())&&(a=-1,!(i=void 0)===e))try{await blStore.remove(F.deviceMAC+"_data.edt.old")}catch(e){return void(V="ERROR(Store): "+e)}if(null!=n&&(t<0||F.disk.files[t].date.getTime()!==n.v.ctime.getTime())&&!(n=void 0)===e)try{await blStore.remove(F.deviceMAC+"_data.edt")}catch(e){return void(V="ERROR(Store): "+e)}0<=t&&(G.total+=F.disk.files[t].len),0<=a&&(G.total+=F.disk.files[a].len),G.incnew=G.total,null!=n&&(G.incnew-=n.v.akt_len),null!=i&&(G.incnew-=i.v.akt_len),V=0}async function Ie(e){var i=e.split(" ");let t,a;var n,r,o,s=i[0].toLowerCase();if(!0===K)V='ERROR(Modem): Exit Modem Terminal ("~")!';else switch(s){case"?":Q(`Blx Terminal Version: ${te}, `+ae);break;case"q":case"quit":Le();break;case"cls":$=[],void 0!==Z&&(document.getElementById("blxTerminalOut").innerText="(cleared)");break;case"s":case"store":try{if(i.length<=1){await blStore.count();let n=0,r=Date.now();Q("Store: "+blStore.result()+" Items"),await blStore.iterate(function(e){a=r-e.ts,t="",86400<=(a/=1e3)&&(a-=86400*(i=Math.floor(a/86400)),t+=i+"d"),a-=3600*(i=Math.floor(a/3600)),i<10&&(t+="0"),t+=i+"h",(i=Math.floor(a/60))<10&&(t+="0"),t+=i+"m",(a-=60*i)<10&&(t+="0");var t,a,i=t+=Math.floor(a)+"s";void 0!==e.v.akt_len?(a=e.v.akt_len,n+=a,Q("'"+e.k+"' ("+i+")': "+a+" Bytes")):Q("'"+e.k+"' ("+i+")'")}),Q("Total Data: "+(n/1024).toFixed(0)+" kB")}else switch(i[1]){case"c":case"clear":await blStore.clearStore(),Q("Store cleared");break;case"r":case"remove":{let e;e=i.length<3?z:i[2],await blStore.remove(e),Q("Removed '"+e+"' from Store")}break;case"l":case"list":try{let e;if(void 0===(e=i.length<3?z:i[2])){V="ERROR(Store): No Key";break}await blStore.get(e);var l=blStore.result();if(void 0===l){V="ERROR(Store): No Value for this Key";break}var c,d=(new TextDecoder).decode(l.v.bytebuf),f=d.replace(/\r/g,"").split(/\n/),u=(f.pop(),J);J "+f.length+" Lines");let t=0;for(c of f)Q(t+": "+(c.length?c:"(empty)")),t++;J=u}catch(e){V="ERROR(Store): "+e}break;case"m":case"modify":try{let e;var v=i[2];if(void 0===v){V="ERROR(Store): No Index";break}var R=i[3];if(void 0===(e=i.length<5?z:i[4])){V="ERROR(Store): No Key";break}await blStore.get(e);var b=blStore.result();if(void 0===b){V="ERROR(Store): No Value for this Key";break}var g=(new TextDecoder).decode(b.v.bytebuf).replace(/\r/g,"").split(/\n/);if(g.pop(),v<0||v>g.length){V="ERROR(Store): Index Range";break}var m=g[v],w=(Q("Old: "+v+": "+(m.length?m:"(empty)")),g[v]=R,Q("New: "+v+": "+((m=g[v]).length?m:"(empty)")),new TextEncoder),p=(b.v.bytebuf=w.encode(g.join("\n")+"\n"),b.v.bytebuf.length);b.v.akt_len=p,b.v.crc32=ie(b.v.bytebuf),b.v.ctime=new Date,b.v.pos0=0,b.v.total_len=p,b.v.ucl_flag=!1,b.v.tssync=void 0,await blStore.set(e,b.v)}catch(e){V="ERROR(Store): "+e}break;default:V="ERROR(Store): Unknown Cmd"}}catch(e){V="ERROR(Store): "+e}break;case"e":case"export":try{let e;e=i.length<2?z:i[1],await blStore.get(e);var h=blStore.result();if(void 0===h){V="ERROR(StoreExport): Key not found";break}var y=h;try{if(void 0!==y.v&&void 0!==y.v.total_len&&y.v.total_len){var k=y.k.lastIndexOf(".");let e="application/octet-binary";if(1{e=e.target.files[0];Q('Selected File:"'+e.name+'" Size:'+e.size+" LastModified: ["+e.lastModifiedDate.toLocaleDateString()+" "+e.lastModifiedDate.toLocaleTimeString()+"]");let t=new FileReader;t.onload=async function(){var e=new Uint8Array(t.result);e.length?rd&&(e=d);var f=new Uint8Array(e+2),u=(f[0]=e,f[1]=C,t.subarray(r,r+e));if(f.set(u,2),await R.writeValue(f.buffer),n-=e,r+=e,!n){var v=Date.now()-s;Q("Transfer OK ("+v/1e3+" sec, "+(t.length/v*1e3).toFixed(0)+" Bytes/sec)");break}1e3<(o=Date.now())-l&&(l=o,Q((100*r/t.length).toFixed(0)+"% / "+r+" Bytes"))}}catch(e){return void(V=!1===L?"ERROR: Connection lost":"ERROR: Transfer "+e)}await q("L",5e3),V||1e3{let a=e.target.files[0];if(Q('Selected File:"'+a.name+'" Size:'+a.size+" LastModified: ["+a.lastModifiedDate.toLocaleDateString()+" "+a.lastModifiedDate.toLocaleTimeString()+"]"),void 0!==r&&".sec"==r){e="firmware_typ"+F.deviceType+"_";if(!a.name.startsWith(e)&&"_firmware.sec"==!a.name)return void Q(V="ERROR: No Firmware File for this Device")}let i=new FileReader;i.onload=async function(){var t=new Uint8Array(i.result);if(t.length){let e=a.name;await De(t,e=void 0!==r&&".sec"==r?"_firmware.sec":e,n),V&&Q(V),void 0!==r&&".sec"==r&&(Q("Reset Device"),await q("R",2e3),await _(1e3),V=0)}else Q(V="ERROR: File is empty")},i.readAsArrayBuffer(a)},Q("Select File or Cancel"),e.click()}let Ne=25,J,Z,$=[];function Q(e){for(void 0!==e?$.push(e):$[0]="*** BLX Terminal ***";$.length>J;)$.shift();void 0!==Z&&(document.getElementById("blxTerminalOut").innerText=$.join("\n"))}function _e(e){13===e.keyCode||10===e.keycode?(e.preventDefault(),document.getElementById("blxTerminalSend").click()):27===e.keyCode&&(e.preventDefault(),document.getElementById("blxTerminalCmd").value="")}function Fe(e){void 0!==Z&&(document.getElementById("blxTerminalSend").disabled=!e)}let Be="";async function Me(){var e=document.getElementById("blxTerminalCmd");let t=e.value.trim();e.value="",e.focus(),Q("> "+t),Fe(!1),ee(1e3,.05,.1),V=0,"*"==t&&Be.length?t=Be:t.length&&(Be=t),"help"==t||"-h"==t||"/h"==t||"-?"==t||"/?"==t?(Q(te+" - "+ae),Q(a)):(t.startsWith(".")?await Ie(t.substring(1)):await q(t),await ke(),V&&(ze(),Q(V)),Fe(!0))}function Le(e,t,a=Ne){void 0!==e?(J=a,(Z=document.getElementById(e)).innerHTML="
",document.getElementById("blxTerminalCmd").addEventListener("keyup",_e),document.getElementById("blxTerminalSend").addEventListener("click",Me),Q(),Fe(!0)):(void 0!==Z&&(Z.innerHTML=""),Z=void 0),void 0!==t&&(B="function"==typeof t?t:void 0)}function l(t,e){var a="@"+e;for(let e=0;e 14 Parameters/Channel!";return e}function i(e,t,a){e=parseInt(e);return!!(isNaN(e)||e{if(t=t,Q("=> "+(e=(e=e).trim())),V=0,e.startsWith(".")?await Ie(e.substring(1)):null!=t?await q(e,t):await q(e),await ke(),await!(V&&(Q(V),B)&&B("ERR",0,V)),V)throw V;if(!0===w)throw new Error("*** BLX BUSY (Since "+(Date.now()-S).toFixed(0)+" msec) ***")},terminalPrint:Q,getDevice:()=>F,getMemory:()=>G,getPinOK:()=>U,frq_ping:ee,chordsound:We,getCrc32:ie,IparamAddChannel:function(t,a){let e=0;var i=parseInt(t[2]);let n;for(;;){var r=l(t,e);if(r<0)break;if(e++,n=r,e>=i)return!1}var o=Pe(t);t.push("@"+e);for(let e=0;esectionMain.scrollIntoView(!0)),sidebuttonTerminal.addEventListener("click",()=>sectionTerminal.scrollIntoView(!1)),document.getElementById("bd-online")),bdOffline=document.getElementById("bd-offline"),lastOnlineState,blxInfoLine=(sidebuttonBluetooth.addEventListener("click",blxConnect),sidebuttonSetup.addEventListener("click",doSetupDialog),sidebuttonServersync.addEventListener("click",runServerSync),sidebuttonQRscan.addEventListener("click",bdRunQRscanner),document.getElementById("blxInfoLine")),blxGraph=document.getElementById("blxGraph");const blxCmdRes=document.getElementById("blxCmdRes");let blxConnectButtonText=document.getElementById("blxConnectButtonText"),blxMemory=document.getElementById("blxMemory"),blxSync=document.getElementById("blxSync"),blxSignal=document.getElementById("blxSignal"),blxMeasureData=document.getElementById("blxMeasureData"),blxDeviceName=document.getElementById("blxDeviceName"),blxMAC=document.getElementById("blxMAC"),blxType=document.getElementById("blxType"),blxFW=document.getElementById("blxFW"),blxPIN=document.getElementById("blxPIN"),blxPinEnter=document.getElementById("blxPinEnter"),blxSyncButton=document.getElementById("blxSyncButton"),blxMeasureButton=document.getElementById("blxMeasureButton"),blxEcholotCheck=document.getElementById("blxEcholot"),blxUploadButton=document.getElementById("blxUploadButton"),blxInfoButton=document.getElementById("blxInfoButton"),blxClearButton=document.getElementById("blxClearButton"),blxParametersButton=document.getElementById("blxParametersButton"),blxSysParButton=document.getElementById("blxSysParButton"),blxSyncButtonSpan=document.getElementById("blxSyncButtonSpan"),blxUploadButtonSpan=document.getElementById("blxUploadButtonSpan"),blxInfoButtonSpan=document.getElementById("blxInfoButtonSpan"),blxClearButtonSpan=document.getElementById("blxClearButtonSpan"),blxParametersSpan=document.getElementById("blxParametersSpan"),blxSetPinButton=document.getElementById("blxSetPinButton"),blxScanPinButton=document.getElementById("blxScanPinButton"),navDevicelist=(blxSetPinButton.addEventListener("click",blxSetPin),blxScanPinButton.addEventListener("click",blxScanPin),blxInfoButton.addEventListener("click",blxMemoryInfo),blxSyncButton.addEventListener("click",blxSyncTime),blxUploadButton.addEventListener("click",blxUpload),blxMeasureButton.addEventListener("click",blxMeasure),blxEcholotCheck.addEventListener("click",blxEcholotClick),blxClearButton.addEventListener("click",blxClearDevice),blxParametersButton.addEventListener("click",blxEditIparam),blxSysParButton.addEventListener("click",blxEditSysparam),document.getElementById("nav-devicelist")),bdurl=new URL(location);function ll(e){return I18.ll(e)}async function blxConnect(){let e=!1,t=(blxCmdRes&&(blxCmdRes.textContent="-"),disabler(!0),!1);try{2<=connectionLevel?(JD.spinnerShow("Bluetooth",""+ll("Disconnect"),10,!0),await _blxCmdSend(".d")):(void 0!==lastAdvertisingName&&(t=await JD.doDialogOK(""+ll("Reconnect?"),`${ll("Reconnect to Device?")}
${ll("Name")}: '${lastAdvertisingName}'
`+ll("OK to Reconnect (or close)"))),e=!0,t?await _blxCmdSend(".r"):await _blxCmdSend(".c"),await showLoggerDetails())}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BCo]")}JD.spinnerClose(),disabler(!1),e&&JD.sidebarMax(.3)}function disabler(e){var t=blx.getPinOK();e?sidebuttonBluetooth.classList.add("jo-disabled"):sidebuttonBluetooth.classList.remove("jo-disabled");let n="none";!0!==t&&!1===e&&3<=connectionLevel&&(n="block"),blxPinEnter&&(blxPinEnter.style.display=n),0!=connectionLevel&&!0===t||(e=!0),blxSyncButton&&(blxSyncButton.disabled=e),blxMeasureButton&&(blxMeasureButton.disabled=e),blxEcholotCheck&&(blxEcholotCheck.disabled=e),blxUploadButton&&(blxUploadButton.disabled=e),blxInfoButton&&(blxInfoButton.disabled=e),blxClearButton&&(blxClearButton.disabled=e),blxParametersButton&&(blxParametersButton.disabled=e),blxSysParButton&&(blxSysParButton.disabled=e),n=void 0!==blxDevice&&1e3<=blxDevice.deviceType?"block":"none",blxSyncButtonSpan&&(blxSyncButtonSpan.style.display=n),blxUploadButtonSpan&&(blxUploadButtonSpan.style.display=n),blxInfoButtonSpan&&(blxInfoButtonSpan.style.display=n),blxClearButtonSpan&&(blxClearButtonSpan.style.display=n),blxParametersSpan&&(blxParametersSpan.style.display=n)}async function showLoggerDetails(){if(3<=connectionLevel){blxDevice=blx.getDevice(),blxMAC&&(blxMAC.textContent=blxDevice.deviceMAC),blxType&&(blxType.textContent=blxDevice.deviceType),blxFW&&(blxFW.textContent=blxDevice.firmwareVersion),4==connectionLevel&&1e3<=blxDevice.deviceType&&(await calculateMemory(!0),await showLink());var t=blxDevice.deltaToApp;let e=t+" "+ll("sec");864e5${ll("Time lost!")}`:86400",e),_blxCmdBusyFlag=!1,_blxCmdRBCnt=0}catch(e){console.log("ERROR:",e),_blxCmdBusyFlag=!1,_blxCmdRBCnt=0,_blxCmdResult=e,connectionLevel<=2&&bleCallback("CON",0)}}async function calculateMemory(n){let l="???";try{n&&await _blxCmdSend(".m");var a=blx.getMemory();let e,t=(e=0 ${ll("Show Graph")}
(`+t.v.akt_len+" Byte, "+t.v.ctime.toLocaleString()+")")}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BsL]")}blxGraph.innerHTML=e}async function blxMemoryInfo(){disabler(!0),JD.spinnerShow(ll("Memory Info"),null,60,!0);try{await _blxCmdSend("v"),await calculateMemory(!0)}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BMI]")}JD.spinnerClose(),disabler(!1)}async function blxClearDevice(){if(disabler(!0),await JD.doDialogOK(ll("Clear Device?"),ll("OK to clear Device Memory?"),null,!0)){JD.spinnerShow(ll("Clear Device"),null,250);try{void 0!==blxDevice.diskCheckOK&&!0===blxDevice.diskCheckOK?(blxInfoLine&&(blxInfoLine.textContent=ll("Start new Measure, Clear all Data")),await _blxCmdSend("n")):(blxInfoLine&&(blxInfoLine.textContent=ll("Start new Measure, Clear all Data (Clean FlashDisk, may need up to 240 sec)")),await _blxCmdSend("n1",24e4)),document.getElementById("blxMemory").textContent="-",await blStore.remove(blxDevice.deviceMAC+"_xtract.edt"),await showLink()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BCD]")}JD.spinnerClose()}disabler(!1)}async function blxSetPin(){blxCmdRes&&(blxCmdRes.textContent="-");var e=blxPIN.value;disabler(!0),JD.spinnerShow(ll("Set PIN"),null,300);try{if(e.length<1)throw"ERROR: PIN EMPTY";await _blxCmdSend(".i "+e),blxPIN.value="",await showLoggerDetails()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BSP]")}JD.spinnerClose(),disabler(!1)}async function blxScanPin(){await bdRunQRscanner(blxDevice.deviceMAC)}async function blxSyncTime(){disabler(!0),JD.spinnerShow(ll("Sync Device Time"),null,30,!0);try{await _blxCmdSend(".t set"),blxSync.textContent=0}catch(e){JD.joPingError(),blxCmdRes=blxCmdRes&&e+" [BST]"}JD.spinnerClose(),disabler(!1)}async function blxUpload(){disabler(!0),JD.spinnerShow(ll("Upload Data"),null,600,!1);try{await _blxCmdSend(".u"),await calculateMemory(!1),await _blxCmdSend(".x"),await showLink()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BUp]")}await updateDeviceList(),JD.spinnerClose(),disabler(!1)}async function blxEcholotClick(){await _blxCmdSend(blxEcholotCheck.checked?".a 1":".a 0")}let measureData="???";async function blxMeasure(){disabler(!0),JD.spinnerShow(ll("Measure"),null,30,!0),blxMeasureData.innerHTML=ll("Wait...");try{await _blxCmdSend("e 1")}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BMe]")}JD.spinnerClose(),disabler(!1)}let p100_beschr=["*@100_System","*DEVICE_TYP","*MAX_CHANNELS","*HK_FLAGS","*NewCookie [Parameter 10-digit Timestamp.32]","Device_Name[BLE:$11/total:$41]","Period_sec[10..86400]","Period_Offset_sec[0..(Period_sec-1)]","Period_Alarm_sec[0..Period_sec]","Period_Internet_sec[0..604799]","Period_Internet_Alarm_sec[0..Period_Internet_sec]","UTC_Offset_sec[-43200..43200]","Flags (B0:Rec B1:Ring) (0: RecOff) B2:Compress","HK_flags (B0:Bat B1:Temp B2.Hum B3.Perc B4.Baro)","HK_reload[0..255]","Net_Mode (0:Off 1:OnOff 2:On_5min 3:Online)","ErrorPolicy (O:None 1:RetriesForAlarms, 2:RetriesForAll)","MinTemp_oC[-40..10]","Config0_U31 (B0:OffPer.Inet:On/Off B1,2:BLE:On/Mo/Li/MoLi B3:EnDS B4:CE:Off/On B5:Live:Off/On)","Configuration_Command[$79]","Internet_Starttime[Timestamp.32]"],pkan_beschr=["*@ChanNo","Action[0..65535] (B0:Meas B1:Cache B2:Alarms)","Physkan_no[0..65535]","Kan_caps_str[$8]","Src_index[0..255]","Unit[$8]","Mem_format[0..255]","DB_id[0..2e31]","Offset[float]","Factor[float]","Alarm_hi[float]","Alarm_lo[float]","Messbits[0..65535]","Xbytes[$32]"],p200_beschr=["*@200_Sys_Param","APN[$41]","Server/VPN[$41]","Script/Id[$41]","API Key[$41]","ConFlags[0..255] (B0:Verbose B1:RoamAllow B4:LOG_FILE (B5:LOG_UART) B7:Debug)","SIM Pin[0..65535] (opt)","APN User[$41]","APN Password[$41]","Max_creg[10..255]","Port[1..65535]","Server_timeout_0[1000..65535]","Server_timeout_run[1000..65535]","Modem Check Reload[60..3600]","Bat. Capacity (mAh)[0..100000]","Bat. Volts 0%[float]","Bat. Volts 100%[float]","Max Ringsize (Bytes)[1000..2e31]","mAmsec/Measure[0..1e9]","Mobile Protocol[0..255] B0:0/1:HTTP/HTTPS B1:PUSH B2,3:TCP/UDPSetup"],original_par;async function editParamDialogDo(e){var t="
";let n;return e?n=JD.prepareCustomDialog(ll("Edit Parameter")+" 'sys_param'",t,ll("Send...")):(n=JD.prepareCustomDialog(ll("Edit Parameter")+" 'iparam'",t,ll("Send..."),``)).querySelector("#editBtnAddChannel").addEventListener("click",()=>{try{blxEditedParamGet(0),blx.IparamAddChannel(blxDevice.iparam,!0),blxParametersCopy(!1,0);var e=document.getElementById("blxParameterEdit");e.innerHTML=blxParametersGetHtml(0),e.scrollTop=e.scrollHeight,JD.joPing()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BaC]")}}),document.getElementById("blxParameterEdit").innerHTML=blxParametersGetHtml(e),await JD.doCustomDialog(0)}function blxParCancel(e){e?blxDevice.sys_param=original_par:blxDevice.iparam=original_par,blxCmdRes&&(blxCmdRes.textContent=ll("Edit Parameters cancelled"))}function blxEditedParamGet(n){var e=(n?blxDevice.sys_param:blxDevice.iparam).length;for(let t=0;t


${e}
`,null),t=e}else try{blxEditedParamGet(0),blx.CompactIparam(blxDevice.iparam),blxParametersCopy(!1,0);var o=blx.IparamValidate(blxDevice.iparam);if(o)throw"ERROR: Iparam-Check(3):\n"+o;var r=(new TextEncoder).encode(blxDevice.iparam.join("\n")+"\n"),s=blx.getCrc32(r);await blStore.get(blxDevice.deviceMAC+"_iparam.lxp");let e=blStore.result();if(void 0!==e&&s===e.v.crc32&&r.length===e.v.akt_len&&!1===blxDevice.iparam_dirtyflag)return blxCmdRes&&(blxCmdRes.textContent=ll("(No Changes)")),JD.spinnerClose(),t;void 0===e&&(e={v:{}}),blxEditedParamGet(0),blxDevice.iparam[4]=(Date.now()/1e3).toFixed(0),blxDevice.iparam_dirtyflag=!0;var d=new TextEncoder;if(e.v.bytebuf=d.encode(blxDevice.iparam.join("\n")+"\n"),e.v.crc32=blx.getCrc32(e.v.bytebuf),e.v.total_len=e.v.bytebuf.length,e.v.akt_len=e.v.total_len,e.v.ctime=new Date(1e3*blxDevice.iparam[4]),e.v.esync_flag=!0,e.v.tssync=void 0,await blStore.set(blxDevice.deviceMAC+"_iparam.lxp",e.v),await _blxCmdSend(".fput "+blxDevice.deviceMAC+"_iparam.lxp"),_blxCmdResult)throw _blxCmdResult;if(await _blxCmdSend("X"),_blxCmdResult)throw _blxCmdResult;blxDevice.iparam_dirtyflag=!1,await blStore.set(blxDevice.deviceMAC+"_#BAK_iparam.lxp",e.v)}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+"[BPa]"),await JD.doDialogOK(ll("ERROR"),ll("Parameter Check")+` 'iparam'


${e}
`,null),t=e}return await updateDeviceList(),JD.spinnerClose(),t}function blxParametersCopy(e,t){var n=t?blxDevice.sys_param:blxDevice.iparam;if(!0===e)if(original_par=[],void 0===n)JD.doDialogOK(ll("ERROR")+": Iparam-Check(1)","No Parameters found!",null);else{for(let e=0;e"):i++;var s,d=void 0!==a[i]?a[i]:"(unknown)";let e,t=(d.indexOf("Timestamp.32")&&1e9[${n}+(+${i})] - '${a[i]}'
`,o+=t}return o}async function blxEditIparam(){for(blxParametersCopy(!0,0);;){if("OK"!==await editParamDialogDo(0)){blxParCancel(0);break}if(!await blxParSend(0))break}}async function blxEditSysparam(){for(blxParametersCopy(!0,1);;){if("OK"!==await editParamDialogDo(1)){blxParCancel(1);break}if(!await blxParSend(1))break}}function bleCallback(l,a,i){switch(l){case"CON":switch(connectionLevel=a,console.log("CON-Level: "+a),a){case 0:case 1:blxConnectButtonText&&(blxConnectButtonText.textContent=ll("Connect")),blxInfoLine&&(blxInfoLine.textContent=ll("Disconnect")),blxMemory&&(blxMemory.textContent="-"),blxSync&&(blxSync.textContent="-"),blxSignal&&(blxSignal.hidden=!0),blxMeasureData&&(blxMeasureData.innerHTML="-"),sidebuttonBluetooth.querySelector("i").classList.remove("jo-icon-ani-beat"),disabler(!1);break;case 2:lastAdvertisingName=blx.getDevice().advertisingName,blxDeviceName&&(blxDeviceName.textContent=lastAdvertisingName),blxMAC&&(blxMAC.textContent="-"),blxType&&(blxType.textContent="-"),blxFW&&(blxFW.textContent="-"),sidebuttonBluetooth.querySelector("i").classList.add("jo-icon-ani-beat"),blxSignal&&(blxSignal.textContent="... dBm"),blxSignal&&(blxSignal.style.backgroundColor="gray");var o=`${ll("Connecting")} '${lastAdvertisingName}'...`;blxConnectButtonText&&(blxConnectButtonText.textContent=o),blxInfoLine&&(blxInfoLine.textContent=o),blxGraph&&(blxGraph.innerHTML=""),JD.spinnerGetBusy()||JD.spinnerShow("Bluetooth",o,30,!0);break;case 3:JD.spinnerGetBusy()&&JD.spinnerSetInfo(ll("Reading IDs...")),blxInfoLine&&(blxInfoLine.textContent=ll("Reading IDs...")),blxConnectButtonText&&(blxConnectButtonText.textContent=`'${lastAdvertisingName}'`);break;case 4:blxSignal&&(blxSignal.hidden=!1),disabler(!1)}break;case"UPLOAD":uplStatus={totalsize:a,mode:i,sumsize:0,filesize:0,filename:"",fproc:0,ndata:!0};break;case"GET":uplStatus.filesize=a,uplStatus.filename=i,uplStatus.ndata=!0,blxInfoLine&&(blxInfoLine.textContent=ll("File")+`:'${i}' ${a} Byte`);break;case"PROG":uplStatus.fproc=a,uplStatus.ndata=!0;let e,t;t=uplStatus.totalsize?(r=uplStatus.sumsize/uplStatus.totalsize*100,d=uplStatus.filesize/uplStatus.totalsize*uplStatus.fproc,`${e=(r+d).toFixed(0)}% of ${(uplStatus.totalsize/1024).toFixed(0)} kB`):(e=a)+"%",JD.spinnerGetBusy()&&(JD.spinnerSetProgress(e),JD.spinnerSetInfo(t)),blxInfoLine&&(blxInfoLine.textContent=e+"%");break;case"GET_OK":uplStatus.sumsize+=a,uplStatus.ndata=!0,blxInfoLine&&(blxInfoLine.textContent=`OK (${a} ${i} )`);break;case"RSSI":var r=.273*a+28;let n="limegreen";0<=r&&(r<4?n="gray":r<8&&(n="orange")),blxSignal&&(blxSignal.textContent=a+" dBm"),blxSignal&&(blxSignal.style.backgroundColor=n),l=void 0;break;case"VSENS":blxInfoLine&&(blxInfoLine.textContent="VSENS "+i+": "+a),l=void 0;break;case"INFO":blxInfoLine&&(blxInfoLine.textContent=i);break;case"MSG":blxInfoLine&&(blxInfoLine.textContent="MSG "+a+":"+i);break;case"WARN":blxCmdRes&&(blxCmdRes.textContent="WARNING "+a+":"+i);break;case"ERR":blxCmdRes&&(blxCmdRes.textContent="ERROR "+a+":"+i);break;case"BZY":var s=parseInt(i);if(blxInfoLine)switch(a){case 1:blxInfoLine.textContent=2sectionMain.scrollIntoView(!0)),sidebuttonTerminal.addEventListener("click",()=>sectionTerminal.scrollIntoView(!1)),document.getElementById("bd-online")),bdOffline=document.getElementById("bd-offline"),lastOnlineState,blxInfoLine=(sidebuttonBluetooth.addEventListener("click",blxConnect),sidebuttonSetup.addEventListener("click",doSetupDialog),sidebuttonServersync.addEventListener("click",runServerSync),sidebuttonQRscan.addEventListener("click",bdRunQRscanner),document.getElementById("blxInfoLine")),blxGraph=document.getElementById("blxGraph");const blxCmdRes=document.getElementById("blxCmdRes");let blxConnectButtonText=document.getElementById("blxConnectButtonText"),blxMemory=document.getElementById("blxMemory"),blxSync=document.getElementById("blxSync"),blxSignal=document.getElementById("blxSignal"),blxMeasureData=document.getElementById("blxMeasureData"),blxDeviceName=document.getElementById("blxDeviceName"),blxMAC=document.getElementById("blxMAC"),blxType=document.getElementById("blxType"),blxFW=document.getElementById("blxFW"),blxPIN=document.getElementById("blxPIN"),blxPinEnter=document.getElementById("blxPinEnter"),blxSyncButton=document.getElementById("blxSyncButton"),blxMeasureButton=document.getElementById("blxMeasureButton"),blxEcholotCheck=document.getElementById("blxEcholot"),blxUploadButton=document.getElementById("blxUploadButton"),blxInfoButton=document.getElementById("blxInfoButton"),blxClearButton=document.getElementById("blxClearButton"),blxParametersButton=document.getElementById("blxParametersButton"),blxSysParButton=document.getElementById("blxSysParButton"),blxSyncButtonSpan=document.getElementById("blxSyncButtonSpan"),blxUploadButtonSpan=document.getElementById("blxUploadButtonSpan"),blxInfoButtonSpan=document.getElementById("blxInfoButtonSpan"),blxClearButtonSpan=document.getElementById("blxClearButtonSpan"),blxParametersSpan=document.getElementById("blxParametersSpan"),blxSetPinButton=document.getElementById("blxSetPinButton"),blxScanPinButton=document.getElementById("blxScanPinButton"),navDevicelist=(blxSetPinButton.addEventListener("click",blxSetPin),blxPIN.addEventListener("keyup",blxPinKeyUpEvent),blxScanPinButton.addEventListener("click",blxScanPin),blxInfoButton.addEventListener("click",blxMemoryInfo),blxSyncButton.addEventListener("click",blxSyncTime),blxUploadButton.addEventListener("click",blxUpload),blxMeasureButton.addEventListener("click",blxMeasure),blxEcholotCheck.addEventListener("click",blxEcholotClick),blxClearButton.addEventListener("click",blxClearDevice),blxParametersButton.addEventListener("click",blxEditIparam),blxSysParButton.addEventListener("click",blxEditSysparam),document.getElementById("nav-devicelist")),bdurl=new URL(location),cbSpinner=(isUrlGit=bdurl.host.includes("github."),!1);function ll(e){return I18.ll(e)}async function blxConnect(){let e=!1,t=(blxCmdRes&&(blxCmdRes.textContent="-"),disabler(!0),!1);try{2<=connectionLevel?(JD.spinnerShow("Bluetooth",""+ll("Disconnect"),10,!0),await _blxCmdSend(".d")):(void 0!==lastAdvertisingName&&(t=await JD.doDialogOK(""+ll("Reconnect?"),`${ll("Reconnect to Device?")}
${ll("Name")}: '${lastAdvertisingName}'
`+ll("OK to Reconnect (or close)"))),e=!0,t?await _blxCmdSend(".r"):await _blxCmdSend(".c"),await showLoggerDetails())}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BCo]")}cbSpinner=!1,JD.spinnerClose(),disabler(!1),e&&JD.sidebarMax(.3)}function disabler(e){var t=blx.getPinOK();e?sidebuttonBluetooth.classList.add("jo-disabled"):sidebuttonBluetooth.classList.remove("jo-disabled");let n="none";!0!==t&&!1===e&&3<=connectionLevel&&(n="block"),blxPinEnter&&(blxPinEnter.style.display=n),0!=connectionLevel&&!0===t||(e=!0),blxSyncButton&&(blxSyncButton.disabled=e),blxMeasureButton&&(blxMeasureButton.disabled=e),blxEcholotCheck&&(blxEcholotCheck.disabled=e),blxUploadButton&&(blxUploadButton.disabled=e),blxInfoButton&&(blxInfoButton.disabled=e),blxClearButton&&(blxClearButton.disabled=e),blxParametersButton&&(blxParametersButton.disabled=e),blxSysParButton&&(blxSysParButton.disabled=e),n=void 0!==blxDevice&&1e3<=blxDevice.deviceType?"block":"none",blxSyncButtonSpan&&(blxSyncButtonSpan.style.display=n),blxUploadButtonSpan&&(blxUploadButtonSpan.style.display=n),blxInfoButtonSpan&&(blxInfoButtonSpan.style.display=n),blxClearButtonSpan&&(blxClearButtonSpan.style.display=n),blxParametersSpan&&(blxParametersSpan.style.display=n)}async function showLoggerDetails(){if(3<=connectionLevel){blxDevice=blx.getDevice(),blxMAC&&(blxMAC.textContent=blxDevice.deviceMAC),blxType&&(blxType.textContent=blxDevice.deviceType),blxFW&&(blxFW.textContent=blxDevice.firmwareVersion),4==connectionLevel&&1e3<=blxDevice.deviceType&&(await calculateMemory(!0),await showLink());var t=blxDevice.deltaToApp;let e=t+" "+ll("sec");864e5${ll("Time lost!")}`:86400",e),_blxCmdBusyFlag=!1,_blxCmdRBCnt=0}catch(e){console.log("ERROR:",e),_blxCmdBusyFlag=!1,_blxCmdRBCnt=0,_blxCmdResult=e,connectionLevel<=2&&bleCallback("CON",0)}}async function calculateMemory(n){let l="???";try{n&&await _blxCmdSend(".m");var a=blx.getMemory();let e,t=(e=0 ${ll("Show Graph")}
(`+t.v.akt_len+" Byte, "+t.v.ctime.toLocaleString()+")")}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BsL]")}blxGraph.innerHTML=e}async function blxMemoryInfo(){disabler(!0),JD.spinnerShow(ll("Memory Info"),null,60,!0);try{await _blxCmdSend("v"),await calculateMemory(!0)}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BMI]")}JD.spinnerClose(),disabler(!1)}async function blxClearDevice(){if(disabler(!0),await JD.doDialogOK(ll("Clear Device?"),ll("OK to clear Device Memory?"),null,!0)){JD.spinnerShow(ll("Clear Device"),null,250);try{void 0!==blxDevice.diskCheckOK&&!0===blxDevice.diskCheckOK?(blxInfoLine&&(blxInfoLine.textContent=ll("Start new Measure, Clear all Data")),await _blxCmdSend("n")):(blxInfoLine&&(blxInfoLine.textContent=ll("Start new Measure, Clear all Data (Clean FlashDisk, may need up to 240 sec)")),await _blxCmdSend("n1",24e4)),document.getElementById("blxMemory").textContent="-",await blStore.remove(blxDevice.deviceMAC+"_xtract.edt"),await showLink()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BCD]")}JD.spinnerClose()}disabler(!1)}async function blxPinKeyUpEvent(e){13!==e.keyCode&&10!==e.keycode||(e.preventDefault(),blxSetPin())}async function blxSetPin(){blxCmdRes&&(blxCmdRes.textContent="-");var e=blxPIN.value;disabler(!0),JD.spinnerShow(ll("Set PIN"),null,300);try{if(e.length<1)throw"ERROR: PIN EMPTY";await _blxCmdSend(".i "+e),blxPIN.value="",await showLoggerDetails()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BSP]")}JD.spinnerClose(),disabler(!1)}async function blxScanPin(){await bdRunQRscanner(blxDevice.deviceMAC)}async function blxSyncTime(){disabler(!0),JD.spinnerShow(ll("Sync Device Time"),null,30,!0);try{await _blxCmdSend(".t set"),blxSync.textContent=0}catch(e){JD.joPingError(),blxCmdRes=blxCmdRes&&e+" [BST]"}JD.spinnerClose(),disabler(!1)}async function blxUpload(){disabler(!0),JD.spinnerShow(ll("Upload Data"),null,600,!1);try{await _blxCmdSend(".u"),await calculateMemory(!1),await _blxCmdSend(".x"),await showLink()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BUp]")}await updateDeviceList(),JD.spinnerClose(),disabler(!1)}async function blxEcholotClick(){await _blxCmdSend(blxEcholotCheck.checked?".a 1":".a 0")}let measureData="???";async function blxMeasure(){disabler(!0),JD.spinnerShow(ll("Measure"),null,30,!0),blxMeasureData.innerHTML=ll("Wait...");try{await _blxCmdSend("e 1")}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BMe]")}JD.spinnerClose(),disabler(!1)}let p100_beschr=["*@100_System","*DEVICE_TYP","*MAX_CHANNELS","*HK_FLAGS","*NewCookie [Parameter 10-digit Timestamp.32]","Device_Name[BLE:$11/total:$41]","Period_sec[10..86400]","Period_Offset_sec[0..(Period_sec-1)]","Period_Alarm_sec[0..Period_sec]","Period_Internet_sec[0..604799]","Period_Internet_Alarm_sec[0..Period_Internet_sec]","UTC_Offset_sec[-43200..43200]","Flags (B0:Rec B1:Ring) (0: RecOff) B2:Compress","HK_flags (B0:Bat B1:Temp B2.Hum B3.Perc B4.Baro)","HK_reload[0..255]","Net_Mode (0:Off 1:OnOff 2:On_5min 3:Online)","ErrorPolicy (O:None 1:RetriesForAlarms, 2:RetriesForAll)","MinTemp_oC[-40..10]","Config0_U31 (B0:OffPer.Inet:On/Off B1,2:BLE:On/Mo/Li/MoLi B3:EnDS B4:CE:Off/On B5:Live:Off/On)","Configuration_Command[$79]","Internet_Starttime[Timestamp.32]"],pkan_beschr=["*@ChanNo","Action[0..65535] (B0:Meas B1:Cache B2:Alarms)","Physkan_no[0..65535]","Kan_caps_str[$8]","Src_index[0..255]","Unit[$8]","Mem_format[0..255]","DB_id[0..2e31]","Offset[float]","Factor[float]","Alarm_hi[float]","Alarm_lo[float]","Messbits[0..65535]","Xbytes[$32]"],p200_beschr=["*@200_Sys_Param","APN[$41]","Server/VPN[$41]","Script/Id[$41]","API Key[$41]","ConFlags[0..255] (B0:Verbose B1:RoamAllow B4:LOG_FILE (B5:LOG_UART) B7:Debug)","SIM Pin[0..65535] (opt)","APN User[$41]","APN Password[$41]","Max_creg[10..255]","Port[1..65535]","Server_timeout_0[1000..65535]","Server_timeout_run[1000..65535]","Modem Check Reload[60..3600]","Bat. Capacity (mAh)[0..100000]","Bat. Volts 0%[float]","Bat. Volts 100%[float]","Max Ringsize (Bytes)[1000..2e31]","mAmsec/Measure[0..1e9]","Mobile Protocol[0..255] B0:0/1:HTTP/HTTPS B1:PUSH B2,3:TCP/UDPSetup"],original_par;async function editParamDialogDo(e){var t="
";let n;return e?n=JD.prepareCustomDialog(ll("Edit Parameter")+" 'sys_param'",t,ll("Send...")):(n=JD.prepareCustomDialog(ll("Edit Parameter")+" 'iparam'",t,ll("Send..."),``)).querySelector("#editBtnAddChannel").addEventListener("click",()=>{try{blxEditedParamGet(0),blx.IparamAddChannel(blxDevice.iparam,!0),blxParametersCopy(!1,0);var e=document.getElementById("blxParameterEdit");e.innerHTML=blxParametersGetHtml(0),e.scrollTop=e.scrollHeight,JD.joPing()}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+" [BaC]")}}),document.getElementById("blxParameterEdit").innerHTML=blxParametersGetHtml(e),await JD.doCustomDialog(0)}function blxParCancel(e){e?blxDevice.sys_param=original_par:blxDevice.iparam=original_par,blxCmdRes&&(blxCmdRes.textContent=ll("Edit Parameters cancelled"))}function blxEditedParamGet(n){var e=(n?blxDevice.sys_param:blxDevice.iparam).length;for(let t=0;t


${e}
`,null),t=e}else try{blxEditedParamGet(0),blx.CompactIparam(blxDevice.iparam),blxParametersCopy(!1,0);var o=blx.IparamValidate(blxDevice.iparam);if(o)throw"ERROR: Iparam-Check(3):\n"+o;var r=(new TextEncoder).encode(blxDevice.iparam.join("\n")+"\n"),s=blx.getCrc32(r);await blStore.get(blxDevice.deviceMAC+"_iparam.lxp");let e=blStore.result();if(void 0!==e&&s===e.v.crc32&&r.length===e.v.akt_len&&!1===blxDevice.iparam_dirtyflag)return blxCmdRes&&(blxCmdRes.textContent=ll("(No Changes)")),JD.spinnerClose(),t;void 0===e&&(e={v:{}}),blxEditedParamGet(0),blxDevice.iparam[4]=(Date.now()/1e3).toFixed(0),blxDevice.iparam_dirtyflag=!0;var d=new TextEncoder;if(e.v.bytebuf=d.encode(blxDevice.iparam.join("\n")+"\n"),e.v.crc32=blx.getCrc32(e.v.bytebuf),e.v.total_len=e.v.bytebuf.length,e.v.akt_len=e.v.total_len,e.v.ctime=new Date(1e3*blxDevice.iparam[4]),e.v.esync_flag=!0,e.v.tssync=void 0,await blStore.set(blxDevice.deviceMAC+"_iparam.lxp",e.v),await _blxCmdSend(".fput "+blxDevice.deviceMAC+"_iparam.lxp"),_blxCmdResult)throw _blxCmdResult;if(await _blxCmdSend("X"),_blxCmdResult)throw _blxCmdResult;blxDevice.iparam_dirtyflag=!1,await blStore.set(blxDevice.deviceMAC+"_#BAK_iparam.lxp",e.v)}catch(e){JD.joPingError(),blxCmdRes&&(blxCmdRes.textContent=e+"[BPa]"),await JD.doDialogOK(ll("ERROR"),ll("Parameter Check")+` 'iparam'


${e}
`,null),t=e}return await updateDeviceList(),JD.spinnerClose(),t}function blxParametersCopy(e,t){var n=t?blxDevice.sys_param:blxDevice.iparam;if(!0===e)if(original_par=[],void 0===n)JD.doDialogOK(ll("ERROR")+": Iparam-Check(1)","No Parameters found!",null);else{for(let e=0;e"):i++;var s,d=void 0!==a[i]?a[i]:"(unknown)";let e,t=(d.indexOf("Timestamp.32")&&1e9[${n}+(+${i})] + '${a[i]}'
`,o+=t}return o}async function blxEditIparam(){for(blxParametersCopy(!0,0);;){if("OK"!==await editParamDialogDo(0)){blxParCancel(0);break}if(!await blxParSend(0))break}}async function blxEditSysparam(){for(blxParametersCopy(!0,1);;){if("OK"!==await editParamDialogDo(1)){blxParCancel(1);break}if(!await blxParSend(1))break}}function bleCallback(l,a,i){switch(l){case"CON":switch(connectionLevel=a,console.log("CON-Level: "+a),a){case 0:case 1:blxConnectButtonText&&(blxConnectButtonText.textContent=ll("Connect")),blxInfoLine&&(blxInfoLine.textContent=ll("Disconnect")),blxMemory&&(blxMemory.textContent="-"),blxSync&&(blxSync.textContent="-"),blxSignal&&(blxSignal.hidden=!0),blxMeasureData&&(blxMeasureData.innerHTML="-"),sidebuttonBluetooth.querySelector("i").classList.remove("jo-icon-ani-beat"),disabler(!1);break;case 2:lastAdvertisingName=blx.getDevice().advertisingName,blxDeviceName&&(blxDeviceName.textContent=lastAdvertisingName),blxMAC&&(blxMAC.textContent="-"),blxType&&(blxType.textContent="-"),blxFW&&(blxFW.textContent="-"),sidebuttonBluetooth.querySelector("i").classList.add("jo-icon-ani-beat"),blxSignal&&(blxSignal.textContent="... dBm"),blxSignal&&(blxSignal.style.backgroundColor="gray");var o=`${ll("Connecting")} '${lastAdvertisingName}'...`;blxConnectButtonText&&(blxConnectButtonText.textContent=o),blxInfoLine&&(blxInfoLine.textContent=o),blxGraph&&(blxGraph.innerHTML=""),JD.spinnerGetBusy()||(cbSpinner=!0,JD.spinnerShow("Bluetooth",o,30,!0));break;case 3:JD.spinnerGetBusy()&&JD.spinnerSetInfo(ll("Reading IDs...")),blxInfoLine&&(blxInfoLine.textContent=ll("Reading IDs...")),blxConnectButtonText&&(blxConnectButtonText.textContent=`'${lastAdvertisingName}'`);break;case 4:blxSignal&&(blxSignal.hidden=!1),disabler(!1),cbSpinner&&(cbSpinner=!1,JD.spinnerClose())}break;case"UPLOAD":uplStatus={totalsize:a,mode:i,sumsize:0,filesize:0,filename:"",fproc:0,ndata:!0};break;case"GET":uplStatus.filesize=a,uplStatus.filename=i,uplStatus.ndata=!0,blxInfoLine&&(blxInfoLine.textContent=ll("File")+`:'${i}' ${a} Byte`);break;case"PROG":uplStatus.fproc=a,uplStatus.ndata=!0;let e,t;t=uplStatus.totalsize?(r=uplStatus.sumsize/uplStatus.totalsize*100,d=uplStatus.filesize/uplStatus.totalsize*uplStatus.fproc,`${e=(r+d).toFixed(0)}% of ${(uplStatus.totalsize/1024).toFixed(0)} kB`):(e=a)+"%",JD.spinnerGetBusy()&&(JD.spinnerSetProgress(e),JD.spinnerSetInfo(t)),blxInfoLine&&(blxInfoLine.textContent=e+"%");break;case"GET_OK":uplStatus.sumsize+=a,uplStatus.ndata=!0,blxInfoLine&&(blxInfoLine.textContent=`OK (${a} ${i} )`);break;case"RSSI":var r=.273*a+28;let n="limegreen";0<=r&&(r<4?n="gray":r<8&&(n="orange")),blxSignal&&(blxSignal.textContent=a+" dBm"),blxSignal&&(blxSignal.style.backgroundColor=n),l=void 0;break;case"VSENS":blxInfoLine&&(blxInfoLine.textContent="VSENS "+i+": "+a),l=void 0;break;case"INFO":blxInfoLine&&(blxInfoLine.textContent=i);break;case"MSG":blxInfoLine&&(blxInfoLine.textContent="MSG "+a+":"+i);break;case"WARN":blxCmdRes&&(blxCmdRes.textContent="WARNING "+a+":"+i);break;case"ERR":blxCmdRes&&(blxCmdRes.textContent="ERROR "+a+":"+i);break;case"BZY":var s=parseInt(i);if(blxInfoLine)switch(a){case 1:blxInfoLine.textContent=2...");break;case"MEAS_V":if("*"==i[0]&&(i=`(${ll("ALARM")}) `+i.substring(1)),90==a&&void 0!==blxDevice.sys_param&&void 0!==blxDevice.sys_param[16]){var r=parseFloat(blxDevice.sys_param[15]),d=parseFloat(blxDevice.sys_param[16]);if(r("+a+") "+i,blxMeasureData&&(blxMeasureData.innerHTML=measureData)}void 0!==l&&console.log("BLX: ",l,a,i)}async function getSetupOptions(){await blStore.get("#blxDash_#SETUP");var e=blStore.result();void 0!==e&&((setupOptions=e.v).dtheme&&JD.dashToggleTheme(),setupOptions.font&&JD.dashSetFont(setupOptions.font/100),setupOptions.lang)&&I18.i18localize(setupOptions.lang)}async function doSetupDialog(){var e=await blStore.quotaget(),e=`
diff --git a/ble_api/js/jodash.js b/ble_api/js/jodash.js index 1ea30ef..e2e8123 100644 --- a/ble_api/js/jodash.js +++ b/ble_api/js/jodash.js @@ -20,4 +20,4 @@ let VERSION="V0.10 / 10.10.2024",COPYRIGHT="(C)JoEmbedded.de";async function das
`,customdialogbusy=!1,customdialogresult;function prepareCustomDialog(e,o,n=null,t=null){try{if(joPing(),customdialogbusy)throw"Custom Dialog busy";customdialogbusy=!0,null==customDialog&&((customDialog=document.createElement("dialog")).id="custom-dialog",customDialog.innerHTML=customDialogHtml,document.body.appendChild(customDialog),customDialog.querySelector(".jo-dialog-buttonclose").addEventListener("click",()=>{customdialogresult="X",customdialogbusy=!1}),customDialog.querySelector(".jo-dialog-buttonok").addEventListener("click",()=>{customdialogresult="OK",customdialogbusy=!1}));var i=customDialog.querySelector(".jo-dialog-buttonok");customDialog.querySelector(".jo-dialog-header").innerHTML=e,customDialog.querySelector(".jo-dialog-content").innerHTML=o,i.innerHTML=n||"✔ OK",customDialog.querySelector(".jo-dialog-buttons-customextra").innerHTML=t||""}catch(e){console.error("ERROR(prepareCustomDialog): "+e)}return customDialog}async function doCustomDialog(e=0){try{for(customdialogresult="?",customDialog.showModal();;){if(await dashSleepMs(100),0

(Spinner)

-
(Info)

`,spinnerBusy=0,spinnerReason,spinnerInfo,spinnerProgress,spinner_time_max,spinner_time_cnt,spinner_show_time,requestWakeLock=async()=>{try{await navigator.wakeLock.request("screen")}catch(e){console.warn("ERROR(requestWakeLock): "+e)}};function spinnerShow(e,o,n,t=!1){try{null==spinnerDialog&&((spinnerDialog=document.createElement("dialog")).id="spinner-dialog",spinnerDialog.innerHTML=spinnerHtml,document.body.appendChild(spinnerDialog),spinnerReason=document.getElementById("spinnerReason"),spinnerInfo=document.getElementById("spinnerInfo"),spinnerProgress=document.querySelector(".jo-spinner-progress")),spinner_show_time=t,spinner_time_max=n,spinnerProgress.max=t?n:100,spinnerProgress.value=spinner_time_cnt=0,spinnerReason.innerHTML=e,spinnerInfo.innerHTML=o||"",spinnerBusy||(spinnerDialog.showModal(),"wakeLock"in navigator&&requestWakeLock()),spinnerBusy++}catch(e){console.error("ERROR(spinnerShow): "+e)}}function spinnerClose(e=!1){return!spinnerBusy||(spinnerBusy--,spinnerBusy=e?0:spinnerBusy)||spinnerDialog.close(),spinnerBusy}function spinnerSetReason(e){spinnerReason.innerHTML=e}function spinnerSetInfo(e){spinnerInfo.innerHTML=e}function spinnerSetProgress(e){spinnerProgress.value=e}function spinnerSetTime(e){spinner_show_time=!0,spinner_time_max=e,spinnerProgress.max=e,spinnerProgress.value=spinner_time_cnt=0}function spinnerGetBusy(){return spinnerBusy}let callback1sec;function dashInternalTimerSec(){spinnerBusy&&(spinner_time_cnt++>=spinner_time_max?spinnerClose():spinner_show_time&&(spinnerProgress.value=spinner_time_cnt)),void 0!==callback1sec&&callback1sec()}function dashSetTimer1sec(e){callback1sec=e}function sidebarMax(e){document.documentElement.clientWidth*e{"BeforeInstallPromptEvent"in window?console.log("PWA[1] BeforeInstallPromptEvent supported but not fired yet"):console.log("PWA[2] BeforeInstallPromptEvent NOT supported"),joInstallApp.addEventListener("click",installApp)});let o;async function installApp(){var e;o&&(o.prompt(),console.log("PWA[5] Installation Dialog opened"),e=(await o.userChoice).outcome,o=null,"accepted"===e?console.log("PWA[6] User accepted the install prompt.",!0):"dismissed"===e&&console.log("PWA[7] User dismissed the install prompt"),joInstallApp.style.display="none")}window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),o=e,joInstallApp.style.display="block",console.log("PWA[3] BeforeInstallPromptEvent fired")}),window.addEventListener("appinstalled",e=>{console.log("PWA[4] AppInstalled fired")})}window.addEventListener("load",dashInit),console.log("jodash.js init, Version:",VERSION);export{VERSION,COPYRIGHT,dashSleepMs,dashSetFont,dashToggleTheme,joPing,joPingError,joSagmal,doDialogOK,prepareCustomDialog,doCustomDialog,closeCustomDialog,spinnerShow,spinnerClose,spinnerSetReason,spinnerSetInfo,spinnerSetProgress,spinnerSetTime,spinnerGetBusy,dashSetTimer1sec,sidebarMax,isFullInViewportHeight}; \ No newline at end of file +
(Info)

`,spinnerBusy=0,spinnerReason,spinnerInfo,spinnerProgress,spinner_time_max,spinner_time_cnt,spinner_show_time,requestWakeLock=async()=>{try{await navigator.wakeLock.request("screen")}catch(e){console.warn("ERROR(requestWakeLock): "+e)}};function spinnerShow(e,o,n,t=!1){try{null==spinnerDialog&&((spinnerDialog=document.createElement("dialog")).id="spinner-dialog",spinnerDialog.innerHTML=spinnerHtml,document.body.appendChild(spinnerDialog),spinnerReason=document.getElementById("spinnerReason"),spinnerInfo=document.getElementById("spinnerInfo"),spinnerProgress=document.querySelector(".jo-spinner-progress")),spinner_show_time=t,spinner_time_max=n,spinnerProgress.max=t?n:100,spinnerProgress.value=spinner_time_cnt=0,spinnerReason.innerHTML=e,spinnerInfo.innerHTML=o||"",spinnerBusy||(spinnerDialog.showModal(),spinnerDialog.blur(),"wakeLock"in navigator&&requestWakeLock()),spinnerBusy++}catch(e){console.error("ERROR(spinnerShow): "+e)}}function spinnerClose(e=!1){return!spinnerBusy||(spinnerBusy--,spinnerBusy=e?0:spinnerBusy)||spinnerDialog.close(),spinnerBusy}function spinnerSetReason(e){spinnerReason.innerHTML=e}function spinnerSetInfo(e){spinnerInfo.innerHTML=e}function spinnerSetProgress(e){spinnerProgress.value=e}function spinnerSetTime(e){spinner_show_time=!0,spinner_time_max=e,spinnerProgress.max=e,spinnerProgress.value=spinner_time_cnt=0}function spinnerGetBusy(){return spinnerBusy}let callback1sec;function dashInternalTimerSec(){spinnerBusy&&(spinner_time_cnt++>=spinner_time_max?spinnerClose():spinner_show_time&&(spinnerProgress.value=spinner_time_cnt)),void 0!==callback1sec&&callback1sec()}function dashSetTimer1sec(e){callback1sec=e}function sidebarMax(e){document.documentElement.clientWidth*e{"BeforeInstallPromptEvent"in window?console.log("PWA[1] BeforeInstallPromptEvent supported but not fired yet"):console.log("PWA[2] BeforeInstallPromptEvent NOT supported"),joInstallApp.addEventListener("click",installApp)});let o;async function installApp(){var e;o&&(o.prompt(),console.log("PWA[5] Installation Dialog opened"),e=(await o.userChoice).outcome,o=null,"accepted"===e?console.log("PWA[6] User accepted the install prompt.",!0):"dismissed"===e&&console.log("PWA[7] User dismissed the install prompt"),joInstallApp.style.display="none")}window.addEventListener("beforeinstallprompt",e=>{e.preventDefault(),o=e,joInstallApp.style.display="block",console.log("PWA[3] BeforeInstallPromptEvent fired")}),window.addEventListener("appinstalled",e=>{console.log("PWA[4] AppInstalled fired")})}window.addEventListener("load",dashInit),console.log("jodash.js init, Version:",VERSION);export{VERSION,COPYRIGHT,dashSleepMs,dashSetFont,dashToggleTheme,joPing,joPingError,joSagmal,doDialogOK,prepareCustomDialog,doCustomDialog,closeCustomDialog,spinnerShow,spinnerClose,spinnerSetReason,spinnerSetInfo,spinnerSetProgress,spinnerSetTime,spinnerGetBusy,dashSetTimer1sec,sidebarMax,isFullInViewportHeight}; \ No newline at end of file diff --git a/ble_api/sw.js b/ble_api/sw.js index 5d8d67c..581d9e8 100644 --- a/ble_api/sw.js +++ b/ble_api/sw.js @@ -1,2 +1,2 @@ -if(!self.define){let e,s={};const i=(i,r)=>(i=new URL(i+".js",r).href,s[i]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()})).then((()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e})));self.define=(r,c)=>{const a=e||("document"in self?document.currentScript.src:"")||location.href;if(s[a])return;let n={};const o=e=>i(e,a),f={module:{uri:a},exports:n,require:o};s[a]=Promise.all(r.map((e=>f[e]||o(e)))).then((e=>(c(...e),n)))}}define(["./workbox-2e7151d3"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.precacheAndRoute([{url:"css/jodash.css",revision:"7ba87d02cd05a16dee8e76919a2093b6"},{url:"css/qrscanner.css",revision:"d9afdd33d6a9398cd7289af26f8f7090"},{url:"index.html",revision:"640aeaf754c7625712dee402006f2cb5"},{url:"js/blStore.js",revision:"40ded8652b6dc76b7b88c4610263699d"},{url:"js/blx.js",revision:"4b824126a5440f73e44aa6374bfc5c36"},{url:"js/blxdash.js",revision:"d9077779215f9afb3707b728b9c36545"},{url:"js/FileSaver.js",revision:"25561894dca7cb2506d64df529987e62"},{url:"js/intmain_i18n.js",revision:"d26f527708fa74ea408267828c62fd28"},{url:"js/jodash.js",revision:"b2a0adb4175caab13b4b2a2f3655ec29"},{url:"js/qrscanner.js",revision:"a143743e6ece343d9c8b3f84cba81c2e"},{url:"manifest.webmanifest",revision:"570178ed3b2209baf62d2a4d02ad42a3"},{url:"static/favicon.ico",revision:"5b48c6125a55da335f09ed8fd555f277"},{url:"static/favicon.svg",revision:"f2cee656f163f4735a2b1a086846f621"},{url:"static/icons/bootstrap-icons.min.css",revision:"5605c44f8b24ea5de37a959955b71eb6"},{url:"static/icons/fonts/bootstrap-icons.woff",revision:"ba49e844892321d8540ea3b7c088cf97"},{url:"static/icons/fonts/bootstrap-icons.woff2",revision:"cc1e5eda776be5f0ff614285c31d4892"},{url:"static/preview1024x768.png",revision:"4606894e6fa5300618b660f2b63ee6d2"},{url:"static/preview512.png",revision:"bce3d7151098b5feddfcac9ba62d3f6a"}],{ignoreURLParametersMatching:[/^utm_/,/^fbclid$/]})})); +if(!self.define){let e,s={};const i=(i,r)=>(i=new URL(i+".js",r).href,s[i]||new Promise((s=>{if("document"in self){const e=document.createElement("script");e.src=i,e.onload=s,document.head.appendChild(e)}else e=i,importScripts(i),s()})).then((()=>{let e=s[i];if(!e)throw new Error(`Module ${i} didn’t register its module`);return e})));self.define=(r,c)=>{const n=e||("document"in self?document.currentScript.src:"")||location.href;if(s[n])return;let o={};const f=e=>i(e,n),d={module:{uri:n},exports:o,require:f};s[n]=Promise.all(r.map((e=>d[e]||f(e)))).then((e=>(c(...e),o)))}}define(["./workbox-2e7151d3"],(function(e){"use strict";self.addEventListener("message",(e=>{e.data&&"SKIP_WAITING"===e.data.type&&self.skipWaiting()})),e.precacheAndRoute([{url:"css/jodash.css",revision:"7ba87d02cd05a16dee8e76919a2093b6"},{url:"css/qrscanner.css",revision:"d9afdd33d6a9398cd7289af26f8f7090"},{url:"index.html",revision:"fc91c2d2a8dc15abe36f9076d9f3897f"},{url:"js/blStore.js",revision:"40ded8652b6dc76b7b88c4610263699d"},{url:"js/blx.js",revision:"59bf89745bef54674469a6805e410d38"},{url:"js/blxdash.js",revision:"6f39837d3fe355ab4cdd32022865182f"},{url:"js/FileSaver.js",revision:"25561894dca7cb2506d64df529987e62"},{url:"js/intmain_i18n.js",revision:"d26f527708fa74ea408267828c62fd28"},{url:"js/jodash.js",revision:"68b566290586017559ef72d90d879c7f"},{url:"js/qrscanner.js",revision:"a143743e6ece343d9c8b3f84cba81c2e"},{url:"manifest.webmanifest",revision:"570178ed3b2209baf62d2a4d02ad42a3"},{url:"static/favicon.ico",revision:"5b48c6125a55da335f09ed8fd555f277"},{url:"static/favicon.svg",revision:"f2cee656f163f4735a2b1a086846f621"},{url:"static/icons/bootstrap-icons.min.css",revision:"5605c44f8b24ea5de37a959955b71eb6"},{url:"static/icons/fonts/bootstrap-icons.woff",revision:"ba49e844892321d8540ea3b7c088cf97"},{url:"static/icons/fonts/bootstrap-icons.woff2",revision:"cc1e5eda776be5f0ff614285c31d4892"},{url:"static/preview1024x768.png",revision:"4606894e6fa5300618b660f2b63ee6d2"},{url:"static/preview512.png",revision:"bce3d7151098b5feddfcac9ba62d3f6a"}],{ignoreURLParametersMatching:[/^utm_/,/^fbclid$/]})})); //# sourceMappingURL=sw.js.map diff --git a/ble_api/sw.js.map b/ble_api/sw.js.map index 16ebc27..84e55bb 100644 --- a/ble_api/sw.js.map +++ b/ble_api/sw.js.map @@ -1 +1 @@ -{"version":3,"file":"sw.js","sources":["../../../Users/jwick/AppData/Local/Temp/5533a92a9f1abe2d4182954ea1ade618/sw.js"],"sourcesContent":["import {precacheAndRoute as workbox_precaching_precacheAndRoute} from 'C:/Users/jwick/AppData/Roaming/npm/node_modules/workbox-cli/node_modules/workbox-precaching/precacheAndRoute.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.addEventListener('message', (event) => {\n if (event.data && event.data.type === 'SKIP_WAITING') {\n self.skipWaiting();\n }\n});\n\n\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"css/jodash.css\",\n \"revision\": \"7ba87d02cd05a16dee8e76919a2093b6\"\n },\n {\n \"url\": \"css/qrscanner.css\",\n \"revision\": \"d9afdd33d6a9398cd7289af26f8f7090\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"640aeaf754c7625712dee402006f2cb5\"\n },\n {\n \"url\": \"js/blStore.js\",\n \"revision\": \"40ded8652b6dc76b7b88c4610263699d\"\n },\n {\n \"url\": \"js/blx.js\",\n \"revision\": \"4b824126a5440f73e44aa6374bfc5c36\"\n },\n {\n \"url\": \"js/blxdash.js\",\n \"revision\": \"d9077779215f9afb3707b728b9c36545\"\n },\n {\n \"url\": \"js/FileSaver.js\",\n \"revision\": \"25561894dca7cb2506d64df529987e62\"\n },\n {\n \"url\": \"js/intmain_i18n.js\",\n \"revision\": \"d26f527708fa74ea408267828c62fd28\"\n },\n {\n \"url\": \"js/jodash.js\",\n \"revision\": \"b2a0adb4175caab13b4b2a2f3655ec29\"\n },\n {\n \"url\": \"js/qrscanner.js\",\n \"revision\": \"a143743e6ece343d9c8b3f84cba81c2e\"\n },\n {\n \"url\": \"manifest.webmanifest\",\n \"revision\": \"570178ed3b2209baf62d2a4d02ad42a3\"\n },\n {\n \"url\": \"static/favicon.ico\",\n \"revision\": \"5b48c6125a55da335f09ed8fd555f277\"\n },\n {\n \"url\": \"static/favicon.svg\",\n \"revision\": \"f2cee656f163f4735a2b1a086846f621\"\n },\n {\n \"url\": \"static/icons/bootstrap-icons.min.css\",\n \"revision\": \"5605c44f8b24ea5de37a959955b71eb6\"\n },\n {\n \"url\": \"static/icons/fonts/bootstrap-icons.woff\",\n \"revision\": \"ba49e844892321d8540ea3b7c088cf97\"\n },\n {\n \"url\": \"static/icons/fonts/bootstrap-icons.woff2\",\n \"revision\": \"cc1e5eda776be5f0ff614285c31d4892\"\n },\n {\n \"url\": \"static/preview1024x768.png\",\n \"revision\": \"4606894e6fa5300618b660f2b63ee6d2\"\n },\n {\n \"url\": \"static/preview512.png\",\n \"revision\": \"bce3d7151098b5feddfcac9ba62d3f6a\"\n }\n], {\n \"ignoreURLParametersMatching\": [/^utm_/, /^fbclid$/]\n});\n\n\n\n\n\n\n\n\n"],"names":["self","addEventListener","event","data","type","skipWaiting","workbox_precaching_precacheAndRoute","url","revision","ignoreURLParametersMatching"],"mappings":"0nBAmBAA,KAAKC,iBAAiB,WAAYC,IAC5BA,EAAMC,MAA4B,iBAApBD,EAAMC,KAAKC,MAC3BJ,KAAKK,aACP,IAWFC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,iBACPC,SAAY,oCAEd,CACED,IAAO,oBACPC,SAAY,oCAEd,CACED,IAAO,aACPC,SAAY,oCAEd,CACED,IAAO,gBACPC,SAAY,oCAEd,CACED,IAAO,YACPC,SAAY,oCAEd,CACED,IAAO,gBACPC,SAAY,oCAEd,CACED,IAAO,kBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,eACPC,SAAY,oCAEd,CACED,IAAO,kBACPC,SAAY,oCAEd,CACED,IAAO,uBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,uCACPC,SAAY,oCAEd,CACED,IAAO,0CACPC,SAAY,oCAEd,CACED,IAAO,2CACPC,SAAY,oCAEd,CACED,IAAO,6BACPC,SAAY,oCAEd,CACED,IAAO,wBACPC,SAAY,qCAEb,CACDC,4BAA+B,CAAC,QAAS"} \ No newline at end of file +{"version":3,"file":"sw.js","sources":["../../../Users/jwick/AppData/Local/Temp/e3b093b2447916b82449aa3955ae256d/sw.js"],"sourcesContent":["import {precacheAndRoute as workbox_precaching_precacheAndRoute} from 'C:/Users/jwick/AppData/Roaming/npm/node_modules/workbox-cli/node_modules/workbox-precaching/precacheAndRoute.mjs';/**\n * Welcome to your Workbox-powered service worker!\n *\n * You'll need to register this file in your web app.\n * See https://goo.gl/nhQhGp\n *\n * The rest of the code is auto-generated. Please don't update this file\n * directly; instead, make changes to your Workbox build configuration\n * and re-run your build process.\n * See https://goo.gl/2aRDsh\n */\n\n\n\n\n\n\n\n\nself.addEventListener('message', (event) => {\n if (event.data && event.data.type === 'SKIP_WAITING') {\n self.skipWaiting();\n }\n});\n\n\n\n\n/**\n * The precacheAndRoute() method efficiently caches and responds to\n * requests for URLs in the manifest.\n * See https://goo.gl/S9QRab\n */\nworkbox_precaching_precacheAndRoute([\n {\n \"url\": \"css/jodash.css\",\n \"revision\": \"7ba87d02cd05a16dee8e76919a2093b6\"\n },\n {\n \"url\": \"css/qrscanner.css\",\n \"revision\": \"d9afdd33d6a9398cd7289af26f8f7090\"\n },\n {\n \"url\": \"index.html\",\n \"revision\": \"fc91c2d2a8dc15abe36f9076d9f3897f\"\n },\n {\n \"url\": \"js/blStore.js\",\n \"revision\": \"40ded8652b6dc76b7b88c4610263699d\"\n },\n {\n \"url\": \"js/blx.js\",\n \"revision\": \"59bf89745bef54674469a6805e410d38\"\n },\n {\n \"url\": \"js/blxdash.js\",\n \"revision\": \"6f39837d3fe355ab4cdd32022865182f\"\n },\n {\n \"url\": \"js/FileSaver.js\",\n \"revision\": \"25561894dca7cb2506d64df529987e62\"\n },\n {\n \"url\": \"js/intmain_i18n.js\",\n \"revision\": \"d26f527708fa74ea408267828c62fd28\"\n },\n {\n \"url\": \"js/jodash.js\",\n \"revision\": \"68b566290586017559ef72d90d879c7f\"\n },\n {\n \"url\": \"js/qrscanner.js\",\n \"revision\": \"a143743e6ece343d9c8b3f84cba81c2e\"\n },\n {\n \"url\": \"manifest.webmanifest\",\n \"revision\": \"570178ed3b2209baf62d2a4d02ad42a3\"\n },\n {\n \"url\": \"static/favicon.ico\",\n \"revision\": \"5b48c6125a55da335f09ed8fd555f277\"\n },\n {\n \"url\": \"static/favicon.svg\",\n \"revision\": \"f2cee656f163f4735a2b1a086846f621\"\n },\n {\n \"url\": \"static/icons/bootstrap-icons.min.css\",\n \"revision\": \"5605c44f8b24ea5de37a959955b71eb6\"\n },\n {\n \"url\": \"static/icons/fonts/bootstrap-icons.woff\",\n \"revision\": \"ba49e844892321d8540ea3b7c088cf97\"\n },\n {\n \"url\": \"static/icons/fonts/bootstrap-icons.woff2\",\n \"revision\": \"cc1e5eda776be5f0ff614285c31d4892\"\n },\n {\n \"url\": \"static/preview1024x768.png\",\n \"revision\": \"4606894e6fa5300618b660f2b63ee6d2\"\n },\n {\n \"url\": \"static/preview512.png\",\n \"revision\": \"bce3d7151098b5feddfcac9ba62d3f6a\"\n }\n], {\n \"ignoreURLParametersMatching\": [/^utm_/, /^fbclid$/]\n});\n\n\n\n\n\n\n\n\n"],"names":["self","addEventListener","event","data","type","skipWaiting","workbox_precaching_precacheAndRoute","url","revision","ignoreURLParametersMatching"],"mappings":"0nBAmBAA,KAAKC,iBAAiB,WAAYC,IAC5BA,EAAMC,MAA4B,iBAApBD,EAAMC,KAAKC,MAC3BJ,KAAKK,aACP,IAWFC,EAAAA,iBAAoC,CAClC,CACEC,IAAO,iBACPC,SAAY,oCAEd,CACED,IAAO,oBACPC,SAAY,oCAEd,CACED,IAAO,aACPC,SAAY,oCAEd,CACED,IAAO,gBACPC,SAAY,oCAEd,CACED,IAAO,YACPC,SAAY,oCAEd,CACED,IAAO,gBACPC,SAAY,oCAEd,CACED,IAAO,kBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,eACPC,SAAY,oCAEd,CACED,IAAO,kBACPC,SAAY,oCAEd,CACED,IAAO,uBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,qBACPC,SAAY,oCAEd,CACED,IAAO,uCACPC,SAAY,oCAEd,CACED,IAAO,0CACPC,SAAY,oCAEd,CACED,IAAO,2CACPC,SAAY,oCAEd,CACED,IAAO,6BACPC,SAAY,oCAEd,CACED,IAAO,wBACPC,SAAY,qCAEb,CACDC,4BAA+B,CAAC,QAAS"} \ No newline at end of file