Skip to content

Instantly share code, notes, and snippets.

@ReidCarlberg
Created November 28, 2011 19:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ReidCarlberg/1401747 to your computer and use it in GitHub Desktop.
Save ReidCarlberg/1401747 to your computer and use it in GitHub Desktop.
Simples Possible Tester with WiFly
#include <Wire.h>
// (Based on Ethernet's WebClient Example)
#include "WiFly.h"
#include "Credentials.h"
byte server[] = { 66, 249, 89, 104 }; // Google
//Client client(server, 80);
Client client("10.0.1.4", 3000);
void setup() {
delay(2000);
Serial.begin(9600);
WiFly.begin();
if (!WiFly.join(ssid, passphrase)) {
Serial.println("Association failed.");
while (1) {
// Hang on failure.
}
}
Serial.println("connecting...");
if (client.connect()) {
Serial.println("connected");
client.println("GET /sample/index HTTP/1.0");
client.println();
} else {
Serial.println("connection failed");
}
Wire.begin(4);
Wire.onReceive(handleReceive);
}
void handleReceive(int howMany) {
//reciving something
}
void loop() {
handleTransmission("Starting....");
while (client.available()) {
char c = client.read();
Serial.print(c);
}
if (!client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
for(;;)
;
}
delay(4000);
handleTransmission("forward/150/1000");
}
void handleTransmission(String toTx) {
char txChars[toTx.length()];
toTx.toCharArray(txChars,toTx.length());
Wire.beginTransmission(2); // transmit to device #4
Wire.send(txChars); // sends one byte
Wire.send("aaa");
Wire.endTransmission();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment