diff --git a/js/extension.js b/js/extension.js index a8de063..9a0b05f 100644 --- a/js/extension.js +++ b/js/extension.js @@ -7,7 +7,7 @@ this.id = 'matter-adapter'; - console.log("Adding matter-adapter addon to main menu"); + //console.log("Adding matter-adapter addon to main menu"); this.addMenuEntry('Matter'); this.discovered = null; @@ -75,7 +75,7 @@ // // This is called then the user clicks on the addon in the main menu, or when the page loads and is already on this addon's location. show() { - console.log("matter-adapter show called"); + //console.log("matter-adapter show called"); try{ clearInterval(window.matter_adapter_poll_interval); @@ -128,7 +128,8 @@ }); */ - // commission_with_code + + // Commission_with_code // Start pairing button press document.getElementById('extension-matter-adapter-start-normal-pairing-button').addEventListener('click', (event) => { if(this.debug){ @@ -138,17 +139,20 @@ const wifi_password = document.getElementById('extension-matter-adapter-wifi-password').value; const wifi_remember = document.getElementById('extension-matter-adapter-wifi-remember-checkbox').value; - if(wifi_ssid.length < 2){ - console.log("Wifi name is too short"); - alert("That wifi name is too short"); - return; - } - if(wifi_password.length < 8){ - console.log("Wifi password is too short"); - alert("That wifi password is too short"); - return; - } + document.getElementById('extension-matter-adapter-pairing-failed-hint').classList.add('extension-matter-adapter-hidden'); + if(this.wifi_credentials_available == false){ + if(wifi_ssid.length < 2){ + console.log("Wifi name is too short"); + alert("That wifi name is too short"); + return; + } + if(wifi_password.length < 8){ + console.log("Wifi password is too short"); + alert("That wifi password is too short"); + return; + } + } const code = this.pairing_code; if(this.debug){ @@ -189,8 +193,9 @@ 'pairing_type':'commission_with_code', 'code':code} ).then((body) => { - console.log("pair device via commission_with_code response: ", body); - + if(this.debug){ + console.log("pair device via commission_with_code response: ", body); + } }).catch((e) => { @@ -201,7 +206,7 @@ }); - // commission_on_network + // Commission_on_network // Start pairing via commission_on_network button press document.getElementById('extension-matter-adapter-start-network-pairing-button').addEventListener('click', (event) => { if(this.debug){ @@ -209,6 +214,8 @@ } const code = document.getElementById('extension-matter-adapter-network-pairing-code-input').value; //this.pairing_code;//document.getElementById('extension-matter-adapter-pairing-code').value; + document.getElementById('extension-matter-adapter-pairing-failed-hint').classList.add('extension-matter-adapter-hidden'); + if(code.length < 4){ console.log("code was too short"); alert("That code is too short"); @@ -266,7 +273,7 @@ // Pairing failed, try again button document.getElementById('extension-matter-adapter-pairing-failed-try-again-button').addEventListener('click', (event) => { - this.set_pairing_page(); + this.show_pairing_page(); }); @@ -584,7 +591,7 @@ // Show pairing page, triggered by opening the pairing page, or pressing the retry button if pairing failed show_pairing_page(){ if(this.debug){ - console.log("Matter adapter debug: in set_pairing_page"); + console.log("Matter adapter debug: in show_pairing_page"); } this.generate_qr(); @@ -600,9 +607,11 @@ document.getElementById('extension-matter-adapter-second-page').classList.add('extension-matter-adapter-pairing-questioning'); document.getElementById('extension-matter-adapter-second-page').classList.remove('extension-matter-adapter-pairing-normal'); document.getElementById('extension-matter-adapter-second-page').classList.remove('extension-matter-adapter-pairing-network'); + document.getElementById('extension-matter-adapter-second-page').classList.remove('extension-matter-adapter-busy-pairing'); document.getElementById('extension-matter-adapter-pairing-step-qr').classList.remove('extension-matter-adapter-hidden'); document.getElementById('extension-matter-adapter-save-manual-input-pairing-code-button').classList.remove('extension-matter-adapter-hidden'); document.getElementById('extension-matter-adapter-pairing-failed-hint').classList.add('extension-matter-adapter-hidden'); + } @@ -806,7 +815,7 @@ if(typeof this.nodez[thing_id] == 'undefined'){ if(this.debug){ - console.error("Matter adapter debug: ERROR, THING ID NOT PRESENT IN NODEZ: ", thing_id); + console.warning("Matter adapter debug: WARNING, THING ID NOT PRESENT IN NODEZ. user should delete thing: ", thing_id); } continue; } @@ -1098,6 +1107,8 @@ console.log("Matter adapter debug: delete confirm button clicked"); } + delete_confirm_button.classList.add('extension-matter-adapter-hidden'); + let item_el = event.currentTarget.closest(".extension-matter-adapter-item"); item_el.classList.add("extension-matter-adapter-delete"); @@ -1246,6 +1257,10 @@ if(list.innerHTML == ""){ list.innerHTML = '

No Matter devices paired yet

Click on the (+) button in the bottom right corner if you want to connect a new Matter device.

'; } + else{ + // Show refresh button + document.getElementById('extension-matter-adapter-refresh-paired-list-button').classList.remove('extension-matter-adapter-hidden'); + } if(this.updating_firmware){ // Disable all update buttons an update is in progress @@ -1276,9 +1291,6 @@ catch (e) { console.log("Matter adapter: general error while generating items: ", e); } - - // Show refresh button - document.getElementById('extension-matter-adapter-refresh-paired-list-button').classList.remove('extension-matter-adapter-hidden'); } diff --git a/pkg/matter_adapter.py b/pkg/matter_adapter.py index e549586..b3c6c12 100644 --- a/pkg/matter_adapter.py +++ b/pkg/matter_adapter.py @@ -114,7 +114,7 @@ def __init__(self, verbose=False): verbose -- whether or not to enable verbose logging """ - print("Starting adapter init") + print("Starting Matter adapter init") self.ready = False # set this to True once the init process is complete. self.addon_id = 'matter-adapter' @@ -158,7 +158,7 @@ def __init__(self, verbose=False): self.device_was_deleted = False # set to True is a device is deleted from the Matter fabric pwd = run_command('pwd') - print("\n\n\n\n\n\n\n\n\n\n\n\n\n" + str(pwd)) + print("PWD:" + str(pwd)) @@ -347,12 +347,14 @@ def __init__(self, verbose=False): os.mkdir(self.data_path) if not os.path.isdir(self.certs_dir_path): + print("making certificates directory") os.system('mkdir -p ' + self.certs_dir_path) # /data if not os.path.isdir("/data"): print("Error! Could not find /data, which the server will be looking for") - + time.sleep(30) + exit() # Download the latest certificates self.download_certs() @@ -866,6 +868,8 @@ def download_certs(self): if self.DEBUG: print("download_certs_output: " + str(download_certs_output)) + self.certificates_updated = True + if len(download_certs_output) < 5: self.certificates_updated = True #self.last_certificates_download_time = time.time() @@ -1225,8 +1229,7 @@ def unload(self): #if self.client != None: # self.client.stop() - if self.server != None: - self.server.stop() + # loop = asyncio.get_event_loop() # loop.stop() @@ -1242,7 +1245,14 @@ def unload(self): # A final chance to save the data. self.save_persistent_data() - #if self.DEBUG: + + + if self.server != None: + self.server.stop() + time.sleep(5) + exit() + + # does it reach this? if self.DEBUG: print("goodbye") return diff --git a/views/content.html b/views/content.html index 7e423a1..5b33920 100644 --- a/views/content.html +++ b/views/content.html @@ -85,7 +85,7 @@

Provide WiFi credentials

If it's a WiFi based device you will also need to provide the WiFi name and password.

Wifi credentials will be shared for: ...

- +

@@ -183,11 +183,11 @@

Please enter the pairing pin code

Ready to pair

Using pairing code: Error!

-
+
-

Updating certificates... please wait

+

Updating certificates... please wait