@@ -158,6 +158,32 @@ button:disabled {
158158 max-width: 500px;
159159}
160160
161+
162+ #csispairbox {
163+ display: flex;
164+ position: fixed;
165+ left: 0;
166+ top: 0;
167+ width: 100vw;
168+ height: 100vh;
169+
170+ background: rgba(255, 255, 255, 0.8);
171+ backdrop-filter: blur(10px);
172+
173+ z-index: 900;
174+ }
175+
176+ #csispairbox.hidden {
177+ display: none;
178+ }
179+
180+ .csispaircontent {
181+ margin: auto;
182+ position: relative;
183+ width: 90%;
184+ max-width: 500px;
185+ }
186+
161187#splashbox {
162188 display: flex;
163189 position: fixed;
@@ -240,6 +266,16 @@ button:disabled {
240266 </div>
241267</div>
242268
269+ <div id="csispairbox" class="hidden">
270+ <div class="csispaircontent">
271+ <div class="col">
272+ <h2>Do you want to pair coordinated set?</h2>
273+ <button id='paircsisbutton'>Yes</button>
274+ <button id='cancelcsisbutton'>No</button>
275+ </div>
276+ </div>
277+ </div>
278+
243279<div id="splashbox">
244280 <div class="splashcontent">
245281 <div class="col">
@@ -293,6 +329,9 @@ export class MainApp extends HTMLElement {
293329 this . bauFound = this . bauFound . bind ( this ) ;
294330 this . requestBC = this . requestBC . bind ( this ) ;
295331 this . bcReceived = this . bcReceived . bind ( this ) ;
332+ this . sirkFound = this . sirkFound . bind ( this ) ;
333+ this . pairCSIS = this . pairCSIS . bind ( this ) ;
334+ this . closeCSISPair = this . closeCSISPair . bind ( this ) ;
296335 }
297336
298337 initializeModels ( ) {
@@ -366,6 +405,12 @@ export class MainApp extends HTMLElement {
366405 const button = this . shadowRoot ?. querySelector ( '#connect' ) ;
367406 button ?. addEventListener ( 'click' , WebUSBDeviceService . scan ) ;
368407
408+ const pairCSISButton = this . shadowRoot ?. querySelector ( '#paircsisbutton' ) ;
409+ pairCSISButton ?. addEventListener ( 'click' , this . pairCSIS ) ;
410+
411+ const cancelCSISButton = this . shadowRoot ?. querySelector ( '#cancelcsisbutton' ) ;
412+ cancelCSISButton ?. addEventListener ( 'click' , this . closeCSISPair ) ;
413+
369414 const splashbox = this . shadowRoot ?. querySelector ( '#splashbox' ) ;
370415 WebUSBDeviceService . addEventListener ( 'connected' , ( ) => { splashbox ?. classList . add ( 'hidden' ) } ) ;
371416 WebUSBDeviceService . addEventListener ( 'disconnected' , ( ) => { splashbox ?. classList . remove ( 'hidden' ) } ) ;
@@ -374,7 +419,6 @@ export class MainApp extends HTMLElement {
374419
375420 this . #stopScanButton = this . shadowRoot ?. querySelector ( '#stop_scan' ) ;
376421 this . #stopScanButton. addEventListener ( 'click' , this . sendStopScan ) ;
377- this . #stopScanButton. addEventListener ( 'click' , this . sendStopScan ) ;
378422 // this.#stopScanButton.disabled = true;
379423
380424 this . #scanSinkButton = this . shadowRoot ?. querySelector ( '#sink_scan' ) ;
@@ -398,6 +442,8 @@ export class MainApp extends HTMLElement {
398442 this . #model. addEventListener ( 'scan-stopped' , this . scanStopped ) ;
399443 this . #model. addEventListener ( 'sink-scan-started' , this . sinkScanStarted ) ;
400444 this . #model. addEventListener ( 'source-scan-started' , this . sourceScanStarted ) ;
445+ this . #model. addEventListener ( 'sirk-found' , this . sirkFound ) ;
446+ this . #model. addEventListener ( 'csis-pairing-complete' , this . closeCSISPair ) ;
401447
402448 const activityLog = this . shadowRoot ?. querySelector ( '#activity' ) ;
403449 if ( this . #pageState. get ( 'log' ) === 'y' ) {
@@ -502,6 +548,51 @@ export class MainApp extends HTMLElement {
502548 qrscannerbox ?. classList . add ( 'hidden' ) ;
503549 }
504550
551+ sirkFound ( evt ) {
552+ console . log ( "SIRK found" ) ;
553+
554+ const sirk = evt . detail . sirk ;
555+ const set_size = evt . detail . set_size ;
556+
557+ if ( window [ "pairedSetMembers" ] > 0 ) {
558+ return ;
559+ }
560+
561+ window [ "sirk" ] = sirk ;
562+ window [ "set_size" ] = set_size ;
563+
564+ const csispairbox = this . shadowRoot ?. querySelector ( '#csispairbox' ) ;
565+
566+ csispairbox ?. classList . remove ( 'hidden' ) ;
567+ }
568+
569+ closeCSISPair ( ) {
570+ console . log ( "Close CSIS pairing query" ) ;
571+
572+ const csispairbox = this . shadowRoot ?. querySelector ( '#csispairbox' ) ;
573+
574+ window [ "setPairingInProgress" ] = 0 ;
575+ csispairbox ?. classList . add ( 'hidden' ) ;
576+ }
577+
578+ pairCSIS ( ) {
579+ console . log ( "Pairing coordinated set" ) ;
580+
581+ const csispairbox = this . shadowRoot ?. querySelector ( '#csispairbox' ) ;
582+
583+ const sirk = window [ "sirk" ] ;
584+ const set_size = window [ "set_size" ] ;
585+ window [ "setPairingInProgress" ] = 1 ;
586+ window [ "pairedSetMembers" ] = 1 ;
587+
588+ // Pair all already-found members first
589+ this . #model. handlePrefoundSetMembers ( set_size , sirk ) ;
590+
591+ setTimeout ( ( ) => {
592+ this . #model. findSetMembers ( set_size , sirk ) ;
593+ } , 500 ) ;
594+ }
595+
505596 bauFound ( evt ) {
506597 const { decoded, raw} = evt . detail ;
507598
0 commit comments