client-nmea-socket-to-event

1.1.6 • Public • Published

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();


Package Sidebar

Install

npm i client-nmea-socket-to-event

Weekly Downloads

11

Version

1.1.6

License

ISC

Unpacked Size

7.31 kB

Total Files

6

Last publish

Collaborators

  • reytuty