* Start of parsing on FTN packets

This commit is contained in:
Bryan Ashby 2015-07-13 17:04:03 -06:00
parent 368f0d6467
commit f51b6c7098
1 changed files with 59 additions and 2 deletions

View File

@ -3,10 +3,24 @@
var Config = require('./config.js').config;
var _ = require('lodash');
var assert = require('assert');
var binary = require('binary');
function getFTNAddress = function() {
return 'TODO';
}
function getFTNMessageSerialNumber(messageId) {
return ((Math.floor((Date.now() - Date.UTC(2015, 01, 01)) / 1000) + messageId)).toString(16);
}
function getFTNMessageID(messageId, areaId) {
return messageId + '.' + areaId + '@' + getFTNAddress() + ' ' + getFTNMessageSerialNumber(messageId)
}
function getFTNOriginLine = function() {
//
// Specs:
@ -17,11 +31,54 @@ function getFTNOriginLine = function() {
//
// References
// https://gist.github.com/M-griffin/65a23b7ea3d7529fd725
// https://github.com/M-griffin/PyPacketMail/blob/master/PyPacketMail.py
//
function extractMessagesFromFTNPacket(options) {
function extractMessageFromFTNPacketBuffer(options, cb) {
// options.networkAddress
// options.packetBuffer
assert(_.isBuffer(options.packetBuffer));
// :TODO: check size
// :TODO: big/little endian?
binary.parse(options.packetBuffer)
.word16('origNode')
.word16('destNode')
.word16('year')
.word16('month')
.word16('day')
.word16('hour')
.word16('minute')
.word16('second')
.word16('baud')
.word16('packetType')
.word16('originNet')
.word16('destNet')
.word8('prodCodeLo')
.word8('revisionMajor') // aka serialNo
.buffer('password', 8)
.word16('origZone')
.word16('destZone')
// where is the rest of the spec?
.word16('auxNet')
.word16('capWordA')
.word8('prodCodeHi')
.word8('revisionMinor')
.word16('capWordB')
.word16('originZone2')
.word16('destZone2')
.word16('originPoint')
.word16('destPoint')
.word32u('prodData')
.tap(function tapped(vars) {
}
);
}
function extractMessagesFromFTNPacketFile(options) {
//
// options.path
// options.networkAddress
//
}