@@ -22,9 +22,15 @@ const iconURI = "";
2222// eslint-disable-next-line max-len
2323const menuIconURI = "" ;
2424
25- // const wsServerURL = `${window.location.protocol}//${window.location.hostname}:7000`;
25+ // Determine the appropriate protocol and URL for socket.io connection
26+ const getSocketURL = ( ) => {
27+ const protocol = window . location . protocol === 'https:' ? 'https:' : 'http:' ;
28+ const hostname = window . location . hostname || '192.168.1.39' ;
29+ const port = 7000 ;
30+ return `${ protocol } //${ hostname } :${ port } ` ;
31+ } ;
2632
27- const wsServerURL = `ws://192.168.1.39:7000` ;
33+ const wsServerURL = getSocketURL ( ) ;
2834
2935/**
3036 * RGB color constants for confidence visualization
@@ -71,6 +77,7 @@ class ArduinoObjectDetection {
7177 this . io = io ( wsServerURL , {
7278 path : "/socket.io" ,
7379 transports : [ "polling" , "websocket" ] ,
80+ secure :true ,
7481 autoConnect : true ,
7582 } ) ;
7683
@@ -171,14 +178,14 @@ ArduinoObjectDetection.prototype.getInfo = function() {
171178 {
172179 opcode : "getDetectedObjectsCount" ,
173180 blockType : BlockType . REPORTER ,
174- text : "number of detected objects " ,
181+ text : "number" ,
175182 func : "getDetectedObjectsCount" ,
176183 arguments : { } ,
177184 } ,
178185 {
179186 opcode : "getDetectedLabelsAsString" ,
180187 blockType : BlockType . REPORTER ,
181- text : "detected object labels" ,
188+ text : "labels" ,
182189 func : "getDetectedLabelsAsString" ,
183190 arguments : { } ,
184191 } ,
0 commit comments