I am trying to send some very simple data from an arduino with an ethernet shield to my meteor app and enter it into a mongodb collection. With what I came up with so far, I can add info into a collection with this iron-router route in the server when I enter the path into the browser:
this.route('enter', {
path: '/enter/:_id',
data: function (){
_id = this.params._id;
return Meteor.call('addMessage', _id);
}
});
I figured if I sent a simple GET request from the arduino with the data put into the path like "http://my-app-name.meteor.com/enter/some-message", that this would work even if there wasn't any GET info in the message but I'm probably wrong about that. Here is my request code for the arduino:
void connectToServer() {
// attempt to connect, and wait a millisecond:
Serial.println("connecting to server...");
if (client.connect(serverName, 80)) { // serverName is "ijsnow.meteor.com"
Serial.println("making HTTP request...");
// make HTTP GET request to the server:
client.println("GET /enter/message-from-arduino HTTP/1.1");
client.println("HOST: ijsnow.meteor.com");
client.println();
}
// note the time of this connect attempt:
lastAttemptTime = millis();
}
I get the message in the serial monitor that it is making the request but nothing changes in my mongodb collection on that server.
Is there something I need to do differently in my meteor app? I know it would be better if I sent it as an actual GET or POST request but I can't figure out how to process the data in meteor.
Does anyone know if there is better way that I should be sending the data to my meteor app with?
Sorry if this was confusing or if this is a dumb way to do this but I'd like to use meteor for this app if possible!
Thanks in advance for any answers or feedback!
答案 0 :(得分:0)
For connectables, I run a net server inside Meteor that can accept raw TCP packets from just about anything.
For arduino specific stuff, check out johnny-five and this repo for some good stuff: https://github.com/Goyapa/mongoduinometeor