Skip to content

Instantly share code, notes, and snippets.

@jonmarkgo
Created August 7, 2012 20:23
Show Gist options
  • Save jonmarkgo/3289002 to your computer and use it in GitHub Desktop.
Save jonmarkgo/3289002 to your computer and use it in GitHub Desktop.
poweroutlet2
//paste next block of code here
if (!wifly.isAssociated()) { //check to see if we are already associated with the network before connecting
wifiSerial.println(F("Joining network"));
if (wifly.join(mySSID, myPassword, true)) { //using the true flag at the end of wifly.join indicates that we are using WPA
wifly.save();
wifiSerial.println(F("Joined wifi network"));
}
else {
wifiSerial.println(F("Failed to join wifi network"));
wifly.terminal();
}
}
else { //if we are already associated with the network
wifiSerial.println(F("Already joined network"));
}
client.setClient(wifly); //initialize the pusher client with our
if(client.connect(pusherKey)) { //connect to our pusher account
client.bind("powersms", powerSwitch); //bind the powersms event to the powerSwitch callback function
client.subscribe("robot_channel"); //subscribe to our pusher channel
}
else { //if we fail to connect, just loop
while(1) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment