-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
147 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
const HBDMRGateway = require('../src/Services/HBDMRGateway'); | ||
const DMRIPGateway = require("../src/Services/DMRIPGateway"); | ||
const DMRServices = require("../src/Services/DMRServices"); | ||
const LRRP = require("../src/Protocols/LRRP"); | ||
const TMS = require("../src/Protocols/TMS"); | ||
const IP = require("../src/IP"); | ||
|
||
let serviceID = 10099; | ||
let host = '127.0.0.1'; | ||
let port = 50000; | ||
|
||
let gateway = new HBDMRGateway({ | ||
host: host, | ||
port: port, | ||
repeaterId: 1000 | ||
}); | ||
|
||
let ipGateway = new DMRIPGateway(gateway, [serviceID]); | ||
|
||
let lrrpRequest = new LRRP(); | ||
lrrpRequest.type = LRRP.TYPE_TriggeredLocationStartRequest; | ||
lrrpRequest.locationRequestParams.timeInterval = 30; | ||
|
||
let lrrpRequest2 = new LRRP(); | ||
lrrpRequest2.type = LRRP.TYPE_TriggeredLocationStartRequest; | ||
lrrpRequest2.locationRequestParams.distanceInterval = 30; | ||
lrrpRequest2.locationRequestParams.distanceMinTime = 30; | ||
|
||
let dmrServices = new DMRServices(ipGateway, serviceID, { | ||
ignoreUnregistered: false, | ||
LRRPEnabled: true, | ||
LRRPRequests: [lrrpRequest, lrrpRequest2], | ||
LRRPRetryCount: 5, | ||
BMSEnabled: true, | ||
BMSRetryCount: 5, | ||
BMSQueryInterval: 55, | ||
CSBKCount: 0 | ||
}); | ||
|
||
|
||
gateway.on(HBDMRGateway.EVENT_DATA, (data) => { | ||
// console.log('event data '+JSON.stringify(data)); | ||
}) | ||
|
||
gateway.on(HBDMRGateway.EVENT_DMRDATA, (data) => { | ||
console.log('event dmrdata' + JSON.stringify(data)); | ||
|
||
}) | ||
|
||
gateway.on(HBDMRGateway.EVENT_CONNECTED, (data) => { | ||
console.log('event connected' + JSON.stringify(data)); | ||
|
||
}) | ||
|
||
ipGateway.on(DMRIPGateway.EVENT_DATA, (ipPacket) => { | ||
console.log(ipPacket); | ||
}); | ||
|
||
setTimeout(() => { | ||
sendSms(); | ||
}, 12000); | ||
|
||
async function sendSms() { | ||
let src = 10070; | ||
let dst = 10058; | ||
let slot = 1; | ||
let dstIsGroup = false; | ||
let src_addr = (12 << 24) | src; | ||
let dst_addr = ((dstIsGroup ? 225 : 12) << 24) | dst; | ||
|
||
let tms = new TMS(); | ||
|
||
tms.msgId = 145; | ||
tms.text = 'Hello'; | ||
|
||
let ip = new IP.IP4Packet(); | ||
|
||
ip.protocol = IP.IP4Packet.PROTOCOL_UDP; | ||
ip.identification = 124; | ||
ip.src_addr = src_addr; | ||
ip.dst_addr = dst_addr; | ||
ip.src_port = 4007; | ||
ip.dst_port = 4007; | ||
ip.payload = tms.getBuffer(); | ||
|
||
ipGateway.sendIPPacket(ip, slot); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const DMRLib = require('../src'); | ||
|
||
//DMR ID | ||
let src = 11111; | ||
let dst = 22222; | ||
|
||
let tms = new DMRLib.Protocols.TMS(); | ||
|
||
tms.text = 'Hi all'; | ||
|
||
let tmsBuffer = tms.getBuffer(); | ||
|
||
let ipPacket = new DMRLib.IP.IP4Packet(); | ||
|
||
ipPacket.src_addr = (DMRLib.Motorola.Network.NETWORK_SERVER<<24) | src; | ||
ipPacket.dst_addr = (DMRLib.Motorola.Network.NETWORK_RADIO<<24) | dst; | ||
ipPacket.src_port = DMRLib.Motorola.Network.PORT_TMS; | ||
ipPacket.dst_port = DMRLib.Motorola.Network.PORT_TMS; | ||
ipPacket.protocol = DMRLib.IP.IP4Packet.PROTOCOL_UDP; | ||
ipPacket.payload = tmsBuffer; | ||
|
||
let ipBuffer = ipPacket.getBuffer(); | ||
|
||
let dataPackets = DMRLib.DMR.Util.DataBlock.createDataBlock(ipBuffer, src, dst, false); | ||
|
||
let rawPackets = dataPackets.map(i => i.getBuffer()); | ||
|
||
console.log(dataPackets); | ||
console.log(rawPackets); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
const DMRLib = require('../src'); | ||
|
||
console.log('ARS: register from 10058:'); | ||
console.log(DMRLib.Protocols.ARS.from(Buffer.from('000af0200531303035380000', 'hex'))); | ||
|
||
console.log('LRRP: start periodic tracking:'); | ||
console.log(DMRLib.Protocols.LRRP.from(Buffer.from('0b082204000000013716', 'hex'))); | ||
|
||
console.log('LRRP: location data (no satellites):'); | ||
console.log(DMRLib.Protocols.LRRP.from(Buffer.from('0d082204000000013710', 'hex'))); | ||
|
||
console.log('LRRP: location data (location + altitude + time):'); | ||
console.log(DMRLib.Protocols.LRRP.from(Buffer.from('0d18220400000001341f9c46d758691ab13ef423a44b2c815e4f', 'hex'))); | ||
|
||
console.log('TMS: text=Hi:'); | ||
console.log(DMRLib.Protocols.TMS.from(Buffer.from('000ca0008e040d000a0048006900', 'hex'))); | ||
|
||
console.log('BMS: registration:'); | ||
console.log(DMRLib.Protocols.BMS.from(Buffer.from('02f9d1e119db858795c2d602a45371737a84020050', 'hex'))); | ||
|
||
console.log('BMS: battery data:'); | ||
console.log(DMRLib.Protocols.BMS.from(Buffer.from('05826200737a8402005003504d4e4e34353434410000005c348a06481053c7ea0757a90501f82a0c166464646464646464646460932100400704802303701575014a0022001d0012000600050016000d001600200028000e0009001800190024002f004b002c00582a1f7ef905870462', 'hex'))); | ||
|
||
console.log('HomeBrew: data from 10058 to 10099'); | ||
console.log(DMRLib.Protocols.HomeBrew.Packet.from(Buffer.from('444d52440500274a00277311e1a365e7cf64a9a16cbf40af13e5d68b6893026585ed5d7f77fd7570944b6779062d1ea037105232c10047', 'hex'))); | ||
|
||
console.log('NMEA: legacy'); | ||
console.log(DMRLib.Protocols.NMEA.Legacy.from(Buffer.from('700a362f141a42d3a2dfb4db', 'hex'))); | ||
|
||
console.log('IPSC: private data from 10056 to 10099'); | ||
console.log(DMRLib.Protocols.IPSC.Packet.from(Buffer.from('840000000a1a002748002773010000666a20805db31d0589b6db0000000007c0000a800a0060b90f015f5f0d18220400000000170007', 'hex'))); |