freshworkstudio / gps-tracking-nodejs

Let you work with some GPS trackers that connects through tcp.
MIT License
260 stars 159 forks source link

To Send Command to Device using Https #27

Closed jAddict7 closed 5 years ago

jAddict7 commented 5 years ago

I am new to NodeJS, In the documentation an available option to send command is available, 'cmd':'other_command'

this.send_comand = function(cmd,data){ var msg = [this.device.uid,cmd,data]; this.device.send(this.format_data(msg)); }

But how to trigger this from http request to a specific connected device? Please do help. Thanks in advance.

jAddict7 commented 5 years ago
var http = require('http');
http.createServer(function(req, res){
    server.send_to('device_id', 'command');
    res.end();
}).listen(3000);
jona556 commented 5 years ago

how you set var server? for "server".send_to('device_id', 'command')

jAddict7 commented 4 years ago

var server is already created when we use the library