Team XSockets.NET

Photon

Photon is an Arduino based board from Particle. You can use it with XSockets and a custom protocol. The protocol template is available in the item templates in Visual Studio.

Source

The client source is available on github

Sample

#pragma SPARK_NO_PREPROCESSOR
#include <PhotonSocketClient.h>
#define SERVER_IP "ip or dns"
#define SERVER_PORT 8080

PhotonSocketClient client;

//When a message arrives we take action depending on the topic
void onMessage(PhotonSocketClient client, String data) {
    String topic = client.getValueAtIx(data,1);
    //Do something based on topic...
}

//Connect to the XSockets server
void setup()
{
    Serial.begin(9600);
    if(client.connect(SERVER_IP,SERVER_PORT)){
      client.setOnMessageDelegate(onMessage);
    }
    else{
      Serial.println("Could not open connection :(");
    }
}

//Receive data in each loop to fire the onMessage method when data arrives
void loop()
{
  client.receiveData();

  //Sending sample to the generic controller
  //client.send("generic","topic","data");

  delay(250);
}

results matching ""

    No results matching ""