alp-lib
v1.2.0
Published
Parsing and Building for the ALP protocol.
Downloads
13
Readme
This library allows building and parsing DASH7 ALP packets.
Methods:
parse(payload)
Parses a ALP encoded packets.
payload
: The payload to parse. Can either be a Buffer or an array containing bytes (integers between 0 and 255).- Return value: Array of parsed ALP packets.
Example:
var alp = require("alp-lib");
var hex_payload = "41000008"; // Read 8 first bytes of file 0
var payload = new Buffer(hex_payload, "hex");
var parsed = alp.parse(payload);
console.log(parsed);
build(packets)
Encodes packets into bytes following the ALP protocol.
packets
: Array containing the informations concerning the ALP packets to build. The specification of the required informations can be found in the filealp_spec.xml
included in the folder of this module.- Return value: An array of bytes.
Example:
var alp = require ("alp-lib");
var pkt = {
opcode : 1, // Read file
resp : true, // We want a response
group : false, // This action is not grouped with the next
file_id : 0, // We want to read the file 0
file_offset : 0, // We want to read from the offset 0
length : 8, // We want to read 8 bytes
};
var payload = alp.build([pkt]);
console.log("Array:", payload);
var buf = new Buffer(payload);
console.log("Buffer:", buf);