2015-05-12 47 views
0

我想知道是否有任何像GCM Arduino的东西。如何发送推送通知到arduino

我正在开发一个项目,我需要将推送通知发送到与WiFi盾连接的arduino。然后Arduino会根据它获取的通知或与服务器数据同步来执行一些操作。 任何关于如何继续进行的建议都会有所帮助。

谢谢。

回答

1

是的,你可以推送通知发送到Arduino的用于与WiFi屏蔽一个简单的HTTP服务器的教程。您可以通过多种方式将推送通知发送给Arduino。

我正在使用来自Parse.com.的推送通知。要从Parse发送推送通知,只需向Parse.com注册并在那里创建账户。 创建帐户后,您可以从Parse仪表板发送推送通知。

要接收Arduino上的通知,您需要在Arduino上写下草图,以下是草图的帮助。

包括解析库,以确保以下代码将工作。

/*************************************************************************************************************************** 
    setup function 
****************************************************************************************************************************/ 

void setup() { 

    Bridge.begin(); 
    Serial.begin(9600); 

    while (!Serial); 

    Parse.begin("***E0uUjQkMa7nj5D5BALvzegzfyVNSG22BD2FJ", "umPSsggp5JgMFmSHfloewW5oixlM5ibt9LBS***"); 
    // In this example, we associate this device with a pre-generated installation 

    Parse.getInstallationId(); 
    Parse.startPushService(); 

}//setup function block 


void loop() { 

if (Parse.pushAvailable()) { 

    Serial.println("Start push"); 

    ParsePush push = Parse.nextPush(); 
    // Print whole JSON body 

    String message = push.getJSONBody(); 
    // Serial.print("New push message size: "); 
    // Serial.println(message.length()); 
    // Serial.print("New push message content: "); 
    Serial.println(message); 
    // Do something with the push 
    // IMPORTANT, close your push message 
    push.close(); 
    checkStatus(message); 
    Serial.println("End Push"); 


    }//if push notification block 

} //loop 

您可以在这里阅读文档https://parse.com/docs/arduino/guide#push-notifications

我希望这会有所帮助。

-1

你将不得不运行在其上接受请求的WiFi盾HTTP服务器,然后从我假设外系统(在桌面上的命令行,IFTTT配方等)

发出这样的请求这是旧的8位Arduinos之一(因为你提到了wifishield而不是像Linux那样的Yun),所以你需要在Arduino上写一个http服务器草图。

这里是arduino.cc

https://www.arduino.cc/en/Tutorial/WiFiWebServer