This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Listen to bus on website
#1
Hi all,

On my intranet I was listening to the KNX Bus via long polling and ajax requests using

/cgi-bin/scada-vis/general/objects-update.cgi


Since updating to firmware 20160927, this no longer works, I haven't had time to dig into it yet. Is there a new state-of-the-art way to listen to the bus which will update values on a webpage without reloading the page (i.e. to update a field containing a temperature value, or switch status, etc.)

Best regards,
Robin
Reply
#2
Hi Robin,

Long polling is changed to websocket connection.

Never done external from other server but should be possible i guess.

Lets wait what admin say (:
Reply
#3
Hi Erwin
Thank you! Therefore we'll wait for the admin.
Reply
#4
Long polling is still there, but only for the admin part, so as a temporary solution you can access it via /scada-main/objects/update
I'll prepare a WebSocket example later on.
Reply
#5
Websocket example would be fantastic!
Reply
#6
Hello , I have a question. Should websocket use a different port http port ? Or can we use same TCP port ?

Regards
Reply
#7
Same port is used for both WebSockets and standard HTTP requests.
Reply
#8
Hi All,

Can anyone share a Websocket example which is working with same HTTP port ?

Thanks
BR
Ceyhan
Reply
#9
Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.
Code:
<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <script src="http://192.168.1.9/apps/js/jquery.js.gz"></script>
  <script src="http://192.168.1.9/apps/js/localbus.js.gz"></script>
  <script src="http://192.168.1.9/scada/vis/busdecode.js.gz"></script>
</head>
<body>
<script>
$(function() {
  // listen to all groupwrite telegrams
  localbus.listen('groupwrite', function(event) {
    console.log(event);
  });

  // listen to a single object
  localbus.listen('object', '1/1/1', function(value) {
    console.log(value);
  });

  localbus.init('http://192.168.1.9');
});
</script>
</body>
</html>

(28.12.2016, 12:29)ceyhanc Wrote: Can anyone share a Websocket example which is working with same HTTP port ?
Can you explain which kind of data do you want to send over websocket?
Reply
#10
(03.01.2017, 11:26) pid=\2913' Wrote:Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.
Code:
<!DOCTYPE html>
<html>
<head>
 <meta charset="UTF-8">
 <script src="http://192.168.1.9/apps/js/jquery.js.gz"></script>
 <script src="http://192.168.1.9/apps/js/localbus.js.gz"></script>
 <script src="http://192.168.1.9/scada/vis/busdecode.js.gz"></script>
</head>
<body>
<script>
$(function() {
 // listen to all groupwrite telegrams
 localbus.listen('groupwrite', function(event) {
   console.log(event);
 });

 // listen to a single object
 localbus.listen('object', '1/1/1', function(value) {
   console.log(value);
 });

 localbus.init('http://192.168.1.9');
});
</script>
</body>
</html>

(28.12.2016, 12:29)ceyhanc Wrote: Can anyone share a Websocket example which is working with same HTTP port ?
Can you explain which kind of data do you want to send over websocket?

I need to ask, when localbus.init runs;
1. Does websocket server runs at same ip/port with visualisation ?
2. when we try to listen 1 object; will server push to chaged data or actual data to client ?
3. can we listen multiple objects with [ localbus.listen('object', ] notation ?


We want to take some binary objects true/false values to our native Android/IOS app.
Our aims;
1. We use several alarm objects and get informations of them fastly (like TCP socket communication)
2. We want to server will push to alarm info to client.
3. We want to do all communications with one port. (All LM Visualisation and this information)
4. We dont want to use JSON/XML  (It requires reconnect to server for getting informations every 5 sec.)


Thanks
Ceyhan
Reply
#11
(03.01.2017, 11:26)admin Wrote: Here's a short example for how it can work via WebSocket, the problem is that this example requires latest beta firmware and work won't on 2016.09.30.

Thanks.

1. Will everything else keep working if I upgrade to the latest beta firmware?
2. Will the websocket code still run in the next official firmware release? (I do not want to reprogram my intranet with every release)

3.
Quote:Long polling is still there, but only for the admin part, so as a temporary solution you can access it via /scada-main/objects/update
Can't get this work, what is the name of the .cgi file in the folder you mentioned?
Many thanks!
Reply
#12
Quote:1. Does websocket server runs at same ip/port with visualisation ?
Yes

Quote:2. when we try to listen 1 object; will server push to chaged data or actual data to client ?
All bus telegrams are pushed no matter how many objects you listen to

Quote:3. can we listen multiple objects with [ localbus.listen('object', ] notation ?
You can have many listeners for each object or use a single telegram listener and filter event by dst group address param

Quote:1. Will everything else keep working if I upgrade to the latest beta firmware?
Nobody knows as it's not fully tested yet Smile

Quote:2. Will the websocket code still run in the next official firmware release? (I do not want to reprogram my intranet with every release)
Yes

Quote:Can't get this work, what is the name of the .cgi file in the folder you mentioned?
The path is http://LM_IP/scada-main/objects/update
Reply
#13
(03.01.2017, 15:48)admin Wrote:
Quote:The path is http://LM_IP/scada-main/objects/update

Thanks. But whats the name of the .cgi file? Is it still objects-update.cgi (http://LM_IP/scada-main/objects/update/o...update.cgi)? I always got a 404...

Edit: oh- I might have had a /cgi in my path. Will check tonight.

Does websocket also work the other way round, e.g. what is the code to send a grp.write from html/js/jquery?
Reply
#14
Tried to fix the polling function, no success. Can you please take at look at this:

Code:
poll = function() {
  $.ajax({
    //url: 'http://10.0.x.xx/cgi-bin/scada-vis/general/objects-update.cgi',
     url: 'http://10.0.x.xx/scada-main/objects/update/objects-update.cgi',
    type: 'GET',
    data: { upd: upd },
    error: check,
    success: check,
    timeout: 60 * 1000
  });
};

Code:
function read() {
 $.ajax({
   // url: host + '/cgi-bin/scada-vis/general/request.cgi?_module=objects&_action=main',
    url: host + '/scada-main/objects/update/request.cgi?_module=objects&_action=main',
   type: 'POST',
   dataType: 'json',
   data: { updatetime: time, skiptags: 1 },
   error: poll,
   success: update,
   timeout: 15 * 1000
 });
}

I tried altering the path as described a few posts above, did not work, see my code snippets above. I also tried adding /cgi-bin/ at the beginning of the altered path, also no success. I'd really like to fix this that my site is up and running again and switch to websocket as soon as the beta firmware is final. Thank you!
Reply
#15
First url should be:
http://10.0.x.xx/scada-main/objects/update

Second one should be:
http://10.0.x.xx/scada-main/objects/main
Reply
#16
As for sending values from client you can use these functions (keep in mind that only group addresses can be used here, not object names):
Code:
localbus.write('1/1/1', true);  // same as grp.write('1/1/1', true)
localbus.update('1/1/2', 42); // same as grp.update('1/1/2', 42)
Reply
#17
(04.01.2017, 07:24)admin Wrote: First url should be:
http://10.0.x.xx/scada-main/objects/update

Second one should be:
http://10.0.x.xx/scada-main/objects/main

This does not work. I get a Cross origin error in the web console for http://10.0.x.x/scada-main/objects/updat....cgi?upd=0. Reason "CORS-Header 'Access-Control-Allow-Origin' missing". Ideas?


(04.01.2017, 09:01)admin Wrote: As for sending values from client you can use these functions (keep in mind that only group addresses can be used here, not object names):
Code:
localbus.write('1/1/1', true);  // same as grp.write('1/1/1', true)
localbus.update('1/1/2', 42); // same as grp.update('1/1/2', 42)

Great, looking forward to that firmware!
Reply
#18
Unfortunately it won't work with current FW due to browser security checks. I can provide beta FW for you test if you want.
Reply
#19
That would be great, can you please send the beta firmware to the email I am registered here in the forum? Furthermore, do the packages for MySQL work on the beta firmware? Many thanks!
Reply
#20
Which device do you need the FW for? MySQL will work, but you will have to re-install the packages, because custom packages are not kept during FW upgrade.
Reply


Forum Jump: