client-nmea-socket-to-event
v1.1.6
Published
To connect a socket NMEA pattern, with byte 10 to separate messages in tcp/ip connection. Permit connect to recive messages once at time in callback methods.
Downloads
5
Maintainers
Readme
ClientNmeaSocket2Event
To connect a socket NMEA pattern, with byte 10 to separate messages in tcp/ip connection. Permit connect to recive messages once at time in callback methods.
Instantiate
const ClientNmeaSocket2Listener = require('./client-nmea-socket-to-event') ;
//to connect an server running at port 8000
const nmeaSocketClient = new ClientNmeaSocket2Listener(
{
ip:'localhost',
port:8000,
log:true,
autoReconnect:true
}
) ;
Listen and Sending messages
const ClientNmeaSocket2Listener = require('client-nmea-socket-to-event') ;
const nmeaSocketClient = new ClientNmeaSocket2Listener(
{
ip:'localhost',
port:8000,
log:false,
autoReconnect:true
}
) ;
//Add event listener when recive messages type HLHUD recive here
nmeaSocketClient.addListener("HLPVA", (data)=>{
//recive object { header, message }
console.log("recived ", data.header, data.message )
})
nmeaSocketClient.onConnect( ()=>{
//sending message like HLHUD
nmeaSocketClient.sendMessage("HDADA", "HLPVA")
} )
nmeaSocketClient.onDisconnect( ()=>{
//sending message like HLHUD
console.log("disconnected")
} )
nmeaSocketClient.connect();