11< html >
2- < head >
2+ < head >
33 < script src ="../dist/legoino-navigator-serial.js "> </ script >
4- </ head >
5- < body >
4+ </ head >
5+ < body >
66 < div >
7- < button onclick ="devicesManager.updateDevices() "> updateDevices</ button >
8- < button onclick ="devicesManager.requestDevices() "> requestDevices</ button >
9- < input type ="text " value ="h " id ="command ">
10- < button onclick ="sendCommand() "> sendCommand</ button >
7+ < button onclick ="devicesManager.updateDevices() "> updateDevices</ button >
8+ < button onclick ="devicesManager.requestDevices() "> requestDevices</ button >
9+ < input type ="text " value ="h " id ="command " / >
10+ < button onclick ="sendCommand() "> sendCommand</ button >
1111 </ div >
12-
12+
1313 < textarea id ="result " cols ="50 " rows ="30 "> </ textarea >
1414 < div id ="devices "> </ div >
15- < script >
16- const devicesManager = new LegoinoSerial . DevicesManager ( navigator . serial ) ;
15+ < script >
16+ const devicesManager = new LegoinoSerial . DevicesManager ( navigator . serial ) ;
1717 async function doAll ( ) {
1818 await devicesManager . updateDevices ( ) ;
1919 let devices = devicesManager . getDevicesList ( ) ;
2020
21- devicesManager . continuousUpdateDevices ( { callback : ( devices ) => {
22- const table = devicesToTable ( devices ) ;
23- document . getElementById ( 'devices' ) . innerHTML = table ;
24- } } ) ;
25-
21+ devicesManager . continuousUpdateDevices ( {
22+ callback : ( devices ) => {
23+ const table = devicesToTable ( devices ) ;
24+ document . getElementById ( 'devices' ) . innerHTML = table ;
25+ } ,
26+ } ) ;
2627 }
2728 doAll ( ) ;
2829
2930 async function sendCommand ( ) {
30- let command = document . getElementById ( 'command' ) . value ;
31- let result = await devicesManager . sendCommand ( "57332" , command ) ;
32- document . getElementById ( 'result' ) . value = result
31+ let command = document . getElementById ( 'command' ) . value ;
32+ let result = await devicesManager . sendCommand ( '21569' , command ) ;
33+ document . getElementById ( 'result' ) . value = result ;
3334 }
3435
3536 function devicesToTable ( devices ) {
36- let result = '<table border="1">' ;
37+ let result = '<table border="1">' ;
3738 for ( let device of devices ) {
38- result += " <tr>" ;
39- for ( let key of Object . keys ( device ) ) {
40- result += " <td>" + device [ key ] + " </td>" ;
41- }
42- result += " </tr>" ;
39+ result += ' <tr>' ;
40+ for ( let key of Object . keys ( device ) ) {
41+ result += ' <td>' + device [ key ] + ' </td>' ;
42+ }
43+ result += ' </tr>' ;
4344 }
44- result += " </table>" ;
45+ result += ' </table>' ;
4546 return result ;
4647 }
47- </ script >
48- </ body >
49- </ html >
48+ </ script >
49+ </ body >
50+ </ html >
0 commit comments