Skip to content

Commit 05294dd

Browse files
committed
refactor(client): rework client interface and adapt to documentation
1 parent 58c1683 commit 05294dd

2 files changed

Lines changed: 9 additions & 13 deletions

File tree

index.js

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ module.exports = function(settings) {
2222
self.enum = baEnum;
2323

2424
// Public functions
25-
self.whoIs = function(lowLimit, highLimit, receiver) {
26-
client.whoIs(lowLimit, highLimit, null, function(address, deviceId, maxAdpu, segmentation, vendorId) {
25+
self.whoIs = function(lowLimit, highLimit, address) {
26+
client.whoIs(lowLimit, highLimit, address, function(address, deviceId, maxAdpu, segmentation, vendorId) {
2727
self.emit('iAm', address, deviceId, maxAdpu, segmentation, vendorId);
2828
});
2929
};
@@ -36,12 +36,8 @@ module.exports = function(settings) {
3636
client.writeProperty(address, objectType, objectInstance, propertyId, priority, valueList);
3737
};
3838

39-
self.readPropertyMultiple = function(address, objectType, objectInstance, propertyIdAndArrayIndex, next) {
40-
client.readPropertyMultiple(address, objectType, objectInstance, propertyIdAndArrayIndex, next);
41-
};
42-
43-
self.writePropertyMultiple = function() {
44-
39+
self.readPropertyMultiple = function(address, propertyIdAndArrayIndex, next) {
40+
client.readPropertyMultiple(address, propertyIdAndArrayIndex, next);
4541
};
4642

4743
return self;

lib/bacnet-client.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ module.exports = function(settings) {
1717
var lastSequenceNumber = -1;
1818
var invokeStore = {};
1919
var segmentStore = [];
20-
20+
2121
var transport = baTransport({
2222
port: settings.port,
2323
interface: settings.interface,
@@ -243,17 +243,17 @@ module.exports = function(settings) {
243243
};
244244

245245
// Public Functions
246-
self.whoIs = function(lowLimit, highLimit, receiver, handler) {
246+
self.whoIs = function(lowLimit, highLimit, address, handler) {
247247
whoIsHandler = handler;
248248

249249
var buffer = getBuffer();
250-
receiver = receiver || transport.getBroadcastAddress();
251-
baNpdu.Encode(buffer, baEnum.BacnetNpduControls.PriorityNormalMessage, receiver, null, DEFAULT_HOP_COUNT, baEnum.BacnetNetworkMessageTypes.NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, 0);
250+
address = address || transport.getBroadcastAddress();
251+
baNpdu.Encode(buffer, baEnum.BacnetNpduControls.PriorityNormalMessage, address, null, DEFAULT_HOP_COUNT, baEnum.BacnetNetworkMessageTypes.NETWORK_MESSAGE_WHO_IS_ROUTER_TO_NETWORK, 0);
252252
baAdpu.encodeUnconfirmedServiceRequest(buffer, baEnum.BacnetPduTypes.PDU_TYPE_UNCONFIRMED_SERVICE_REQUEST, baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_WHO_IS);
253253
baServices.EncodeWhoIsBroadcast(buffer, lowLimit, highLimit);
254254
// TODO: Differentiate between uni & broadcast
255255
baBvlc.encode(buffer.buffer, baEnum.BacnetBvlcFunctions.BVLC_ORIGINAL_BROADCAST_NPDU, buffer.offset);
256-
transport.send(buffer.buffer, buffer.offset, receiver);
256+
transport.send(buffer.buffer, buffer.offset, address);
257257
};
258258

259259
self.readProperty = function(address, objectType, objectInstance, propertyId, arrayIndex) {

0 commit comments

Comments
 (0)