How communicate to a remote device ?
-
Hi,
I made a local device communicate with my application.
But how do I make to communicate to a remote device ?Is possible to do this using ip or dns ? (because the ip changes sometimes).
-
Hi Valter,
What do you mean by remote? I suspect you mean a device with which you cannot exchange a WhoIs/IAm, but please confirm.
If this is the case, you will need to manually instantiate a RemoteDevice by explicitly providing the IP, port, and instance id. Then, you will be able to send messages to it.
Regarding using a domain name, BACnet only deals with IP addresses, so you will need to handle domain name resolution yourself.
-
@mlohbihler said:
Hi Valter,
What do you mean by remote? I suspect you mean a device with which you cannot exchange a WhoIs/IAm, but please confirm.
If this is the case, you will need to manually instantiate a RemoteDevice by explicitly providing the IP, port, and instance id. Then, you will be able to send messages to it.
Regarding using a domain name, BACnet only deals with IP addresses, so you will need to handle domain name resolution yourself.
I mean, a device that is not in my network.
There's some example in the test folder that could use for that ? -
I don't think so, but it's not hard. The only trick is that you need to know the instance id of the device.
RemoteDevice rd = new RemoteDevice(...); localDevice.addRemoteDevice(rd); // This may not actually be necessary localDevice.send(rd, myRequest);
Where "myRequest" is, say, a read property with pid of objectList. If your setting are correct, you should get the object list of the remote device.
-
@mlohbihler said:
I don't think so, but it's not hard. The only trick is that you need to know the instance id of the device.
RemoteDevice rd = new RemoteDevice(...); localDevice.addRemoteDevice(rd); // This may not actually be necessary localDevice.send(rd, myRequest);
Where "myRequest" is, say, a read property with pid of objectList. If your setting are correct, you should get the object list of the remote device.
I found the id of my device, it's 101, but I have some doubts about it :
public static void main(String[] args) throws Exception { // How to initialize the LocalDevice ? LocalDevice ld = new LocalDevice (???); // let's say my ip is : 1.2.3.4, is this correct ? RemoteDevice rd = new RemoteDevice(101, new Address(new byte[] { (byte) 1, (byte) 2, 3, (byte) 4 }, 47808), null); ld.addRemoteDevice(rd); // now I have the remote device, in the localDevice, now I should be able to use the method 'getObjectList()' ? // how to use this 'myRequest' (I don't understand what you said about it ) ? localDevice.send(rd, myRequest); ... }
-
Ok, now i'm wondering what you meant when you said:
I made a local device communicate with my application.
Anyway, a request is a key component of BACnet. It's how all communication is done with BACnet peers (aka RemoteDevices). Have a look at LocalDevice.findRemoteDevice (and ignore the code that i provided previously). You should be able to see what is going on.
-
@Valter Henrique said:
@mlohbihler said:
I don't think so, but it's not hard. The only trick is that you need to know the instance id of the device.RemoteDevice rd = new RemoteDevice(...); localDevice.addRemoteDevice(rd); // This may not actually be necessary localDevice.send(rd, myRequest);
Where "myRequest" is, say, a read property with pid of objectList. If your setting are correct, you should get the object list of the remote device.
I found the id of my device, it's 101, but I have some doubts about it :
public static void main(String[] args) throws Exception { // How to initialize the LocalDevice ? LocalDevice ld = new LocalDevice (???); // let's say my ip is : 1.2.3.4, is this correct ? RemoteDevice rd = new RemoteDevice(101, new Address(new byte[] { (byte) 1, (byte) 2, 3, (byte) 4 }, 47808), null); ld.addRemoteDevice(rd); // now I have the remote device, in the localDevice, now I should be able to use the method 'getObjectList()' ? // how to use this 'myRequest' (I don't understand what you said about it ) ? localDevice.send(rd, myRequest); ... }
Hi mlohbihler ,
Can u give an example of how u instantiate myRequest?
Regards,
WenJun -
Anyway, a request is a key component of BACnet. It's how all communication is done with BACnet peers (aka RemoteDevices). Have a look at LocalDevice.findRemoteDevice (and ignore the code that i provided previously). You should be able to see what is going on.
-
In the end I created a server (which runs in the computer that's locally placed in my network) and then communicate via socket.
Until I found out how implement a RemoteDevice that you said, thanks mlohbihler.