Skip to content

Commit

Permalink
feat(bacnet-client): implement additional unsupported services
Browse files Browse the repository at this point in the history
  • Loading branch information
fh1ch committed Jun 18, 2017
1 parent b5b8d78 commit d82fefe
Showing 1 changed file with 27 additions and 7 deletions.
34 changes: 27 additions & 7 deletions lib/bacnet-client.js
Expand Up @@ -132,18 +132,38 @@ module.exports = function(settings) {
};

var processUnconfirmedServiceRequest = function(address, type, service, buffer, offset, length) {
var result;
debug('Handle processUnconfirmedServiceRequest');
if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_I_AM) {
var result = baServices.decodeIamBroadcast(buffer, offset);
result = baServices.decodeIamBroadcast(buffer, offset);
if (!result) return debug('Received invalid iAm message');
self.events.emit('iAm', address, result.deviceId, result.maxApdu, result.segmentation, result.vendorId);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_WHO_IS) {
return debug('TODO: Implement');
// TODO: Implement
/*var result = baServices.decodeWhoIsBroadcast(buffer, offset, length);
if (!result) return debug('Received invalid whoIs message');
OnWhoIs(this, address, result.lowLimit, result.highLimit);
*/
result = baServices.DecodeWhoIsBroadcast(buffer, offset, length);
if (!result) return debug('Received invalid WhoIs message');
self.events.emit('whoIs', address, result.lowLimit, result.highLimit);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_WHO_HAS) {
result = baServices.DecodeWhoHasBroadcast(buffer, offset, length);
if (!result) return debug('Received invalid WhoHas message');
self.events.emit('whoHas', address, result.lowLimit, result.highLimit, result.objId, result.objName);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_COV_NOTIFICATION) {
debug('TODO: Implement COVNotify');
//result = baServices.DecodeCOVNotifyUnconfirmed(buffer, offset, length);
//if (!result) return debug('Received invalid COVNotify message');
//self.events.emit('covNotify', address, result.subscriberProcessIdentifier, result.initiatingDeviceIdentifier, result.monitoredObjectIdentifier, result.timeRemaining, result.values);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION) {
result = baServices.DecodeTimeSync(buffer, offset, length);
if (!result) return debug('Received invalid TimeSync message');
self.events.emit('timeSync', address, result.dateTime);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION) {
result = baServices.DecodeTimeSync(buffer, offset, length);
if (!result) return debug('Received invalid TimeSyncUTC message');
self.events.emit('timeSyncUTC', address, result.dateTime);
} else if (service === baEnum.BacnetUnconfirmedServices.SERVICE_UNCONFIRMED_EVENT_NOTIFICATION) {
debug('TODO: Implement EventNotify');
//result = baServices.DecodeEventNotifyData(buffer, offset, length);
//if (!result) return debug('Received invalid EventNotify message');
//self.events.emit('eventNotify', address, result.eventData);
} else {
debug('Received unsupported unconfirmed service request');
}
Expand Down

0 comments on commit d82fefe

Please sign in to comment.