Skip to content

Commit

Permalink
Merge f4ab0e3 into b40b32e
Browse files Browse the repository at this point in the history
  • Loading branch information
fh1ch committed Apr 2, 2018
2 parents b40b32e + f4ab0e3 commit 851d73b
Show file tree
Hide file tree
Showing 32 changed files with 127 additions and 127 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -68,13 +68,13 @@ following services are already supported at this point in time:
const bacnet = require('bacstack');

// Initialize BACStack
const client = new bacnet({adpuTimeout: 6000});
const client = new bacnet({apduTimeout: 6000});

// Discover Devices
client.on('iAm', (device) => {
console.log('address: ', device.address);
console.log('deviceId: ', device.deviceId);
console.log('maxAdpu: ', device.maxAdpu);
console.log('maxApdu: ', device.maxApdu);
console.log('segmentation: ', device.segmentation);
console.log('vendorId: ', device.vendorId);
});
Expand Down
8 changes: 4 additions & 4 deletions lib/adpu.js → lib/apdu.js
Expand Up @@ -26,9 +26,9 @@ module.exports.getDecodedInvokeId = (buffer, offset) => {
}
};

module.exports.encodeConfirmedServiceRequest = (buffer, type, service, maxSegments, maxAdpu, invokeId, sequencenumber, proposedWindowSize) => {
module.exports.encodeConfirmedServiceRequest = (buffer, type, service, maxSegments, maxApdu, invokeId, sequencenumber, proposedWindowSize) => {
buffer.buffer[buffer.offset++] = type;
buffer.buffer[buffer.offset++] = maxSegments | maxAdpu;
buffer.buffer[buffer.offset++] = maxSegments | maxApdu;
buffer.buffer[buffer.offset++] = invokeId;
if ((type & baEnum.PduConReqBits.SEGMENTED_MESSAGE) > 0) {
buffer.buffer[buffer.offset++] = sequencenumber;
Expand All @@ -41,7 +41,7 @@ module.exports.decodeConfirmedServiceRequest = (buffer, offset) => {
const orgOffset = offset;
const type = buffer[offset++];
const maxSegments = buffer[offset] & 0xF0;
const maxAdpu = buffer[offset++] & 0x0F;
const maxApdu = buffer[offset++] & 0x0F;
const invokeId = buffer[offset++];
let sequencenumber = 0;
let proposedWindowNumber = 0;
Expand All @@ -55,7 +55,7 @@ module.exports.decodeConfirmedServiceRequest = (buffer, offset) => {
type: type,
service: service,
maxSegments: maxSegments,
maxAdpu: maxAdpu,
maxApdu: maxApdu,
invokeId: invokeId,
sequencenumber: sequencenumber,
proposedWindowNumber: proposedWindowNumber
Expand Down
178 changes: 89 additions & 89 deletions lib/client.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion lib/services/cov-notify.js
Expand Up @@ -22,7 +22,7 @@ module.exports.encode = (buffer, subscriberProcessId, initiatingDeviceId, monito
if (value.priority === baEnum.ASN1_NO_PRIORITY) {
baAsn1.encodeContextUnsigned(buffer, 3, value.priority);
}
// TODO: Handle to too large telegrams -> ADPU limit
// TODO: Handle to too large telegrams -> APDU limit
});
baAsn1.encodeClosingTag(buffer, 4);
};
Expand Down
2 changes: 1 addition & 1 deletion test/compliance/who-is.spec.js
Expand Up @@ -6,7 +6,7 @@ const bacnet = require('../../');
describe('bacstack - whoIs compliance', () => {
let client;

beforeEach(() => client = new bacnet({adpuTimeout: 1000}));
beforeEach(() => client = new bacnet({apduTimeout: 1000}));
afterEach(() => client.close());

it('should find the device simulator', (next) => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/acknowledge-alarm.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - acknowledgeAlarm integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.acknowledgeAlarm('127.0.0.1', {type: 2, instance: 3}, 2, 'Alarm Acknowledge Test', {value: new Date(), type: 2}, {value: new Date(), type: 2}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/add-list-element.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - addListElement integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.addListElement('127.0.0.1', {type: 19, instance: 101}, {id: 80, index: 0}, [
{type: 1, value: true}
], (err, value) => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/confirmed-event-notification.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - confirmedEventNotification integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
const date = new Date();
date.setMilliseconds(880);
client.confirmedEventNotification('127.0.0.1', {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/confirmed-private-transfer.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - confirmedPrivateTransfer integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.confirmedPrivateTransfer('127.0.0.1', 0, 8, [0x00, 0xaa, 0xfa, 0xb1, 0x00], (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/create-object.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - createObject integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.createObject('127.0.0.1', {type: 2, instance: 300}, [
{property: {id: 85, index: 1}, value: [{type: 1, value: true}]}
], (err, value) => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/delete-object.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - deleteObject integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.deleteObject('127.0.0.1', {type: 2, instance: 15}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/device-communication-control.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - deviceCommunicationControl integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.deviceCommunicationControl('127.0.0.1', 60, 1, {password: 'Test1234'}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/get-alarm-summary.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - getAlarmSummary integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.getAlarmSummary('127.0.0.1', (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/get-enrollment-summary.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - getEnrollmentSummary integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.getEnrollmentSummary('127.0.0.1', 0, {notificationClassFilter: 5}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/get-event-information.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - getEventInformation integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.getEventInformation('127.0.0.1', {type: 5, instance: 33}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read-file.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - readFile integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.readFile('127.0.0.1', {type: 10, instance: 100}, 0, 100, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read-property-multiple.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - readPropertyMultiple integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
const requestArray = [
{objectId: {type: 8, instance: 4194303}, properties: [{id: 8}]}
];
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read-property.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - readProperty integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.readProperty('127.0.0.1', {type: 8, instance: 44301}, 28, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/read-range.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - readRange integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.readRange('127.0.0.1', {type: 20, instance: 0}, 0, 200, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/reinitialize-sevice.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - reinitializeDevice integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.reinitializeDevice('127.0.0.1', 1, {password: 'Test1234'}, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/remove-list-element.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - removeListElement integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.removeListElement('127.0.0.1', {type: 19, instance: 100}, {id: 80, index: 0}, [
{type: 1, value: true}
], (err, value) => {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/subscribe-cov.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - subscribeCOV integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.subscribeCOV('127.0.0.1', {type: 5, instance: 3}, 7, false, false, 0, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/subscribe-property.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - subscribeProperty integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.subscribeProperty('127.0.0.1', {type: 5, instance: 33}, {id: 80, index: 0}, 8, false, false, (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/time-sync-utc.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - timeSyncUTC integration', () => {
it('should send a time UTC sync package', () => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.timeSyncUTC('127.0.0.1', new Date());
client.close();
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/time-sync.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - timeSync integration', () => {
it('should send a time sync package', () => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.timeSync('127.0.0.1', new Date());
client.close();
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/unconfirmed-event-notification.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - unconfirmedEventNotification integration', () => {
it('should correctly send a telegram', () => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
const date = new Date();
date.setMilliseconds(880);
client.unconfirmedEventNotification('127.0.0.1', {
Expand Down
2 changes: 1 addition & 1 deletion test/integration/unconfirmed-private-transfer.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - unconfirmedPrivateTransfer integration', () => {
it('should correctly send a telegram', () => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.unconfirmedPrivateTransfer('127.0.0.1', 0, 7, [0x00, 0xaa, 0xfa, 0xb1, 0x00]);
client.close();
});
Expand Down
4 changes: 2 additions & 2 deletions test/integration/who-is.spec.js
Expand Up @@ -5,8 +5,8 @@ const utils = require('./utils');

describe('bacstack - whoIs integration', () => {
it('should not invoke a event if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
client.on('iAm', (address, deviceId, maxAdpu, segmentation, vendorId) => {
const client = new utils.bacnetClient({apduTimeout: 200});
client.on('iAm', (address, deviceId, maxApdu, segmentation, vendorId) => {
client.close();
next(new Error('Unallowed Callback'));
});
Expand Down
2 changes: 1 addition & 1 deletion test/integration/write-file.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - writeFile integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.writeFile('127.0.0.1', {type: 10, instance: 2}, 0, [[5, 6, 7, 8], [5, 6, 7, 8]], (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
2 changes: 1 addition & 1 deletion test/integration/write-property-multiple.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - writePropertyMultiple integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
const values = [
{objectId: {type: 8, instance: 44301}, values: [
{property: {id: 28, index: 12}, value: [{type: 1, value: true}], priority: 8}
Expand Down
2 changes: 1 addition & 1 deletion test/integration/write-property.spec.js
Expand Up @@ -5,7 +5,7 @@ const utils = require('./utils');

describe('bacstack - writeProperty integration', () => {
it('should return a timeout error if no device is available', (next) => {
const client = new utils.bacnetClient({adpuTimeout: 200});
const client = new utils.bacnetClient({apduTimeout: 200});
client.writeProperty('127.0.0.1', {type: 8, instance: 44301}, 28, [{type: 4, value: 100}], (err, value) => {
expect(err.message).to.eql('ERR_TIMEOUT');
expect(value).to.eql(undefined);
Expand Down
6 changes: 3 additions & 3 deletions test/unit/bacnet-apdu.spec.js
Expand Up @@ -2,7 +2,7 @@

const expect = require('chai').expect;
const utils = require('./utils');
const baApdu = require('../../lib/adpu');
const baApdu = require('../../lib/apdu');

describe('bacstack - APDU layer', () => {
describe('decodedType', () => {
Expand Down Expand Up @@ -37,7 +37,7 @@ describe('bacstack - APDU layer', () => {
type: 0,
service: 41,
maxSegments: 176,
maxAdpu: 12,
maxApdu: 12,
invokeId: 44,
sequencenumber: 0,
proposedWindowNumber: 0
Expand All @@ -53,7 +53,7 @@ describe('bacstack - APDU layer', () => {
type: 8,
service: 47,
maxSegments: 208,
maxAdpu: 14,
maxApdu: 14,
invokeId: 50,
sequencenumber: 51,
proposedWindowNumber: 52
Expand Down

0 comments on commit 851d73b

Please sign in to comment.