Go Down

Topic: Transfering UDP packets, WiFly can't recieve any!! (Read 3023 times) previous topic - next topic


Hello everyone, this is a problem ive been working on for about a week everyday now.
I am starting to go stir crazy, so please help me!
Ive been through just about every UDP example, and none seem to work, nor help me in constructing something that works!!
Code: [Select]
#include "WiFly.h"
#include "Credentials.h"
#include "SPI.h"

const int pwmA = 3;
const int pwmB = 5;
const int brakeA = 9;
const int brakeB = 8;
const int dirA = 4;
const int dirB = 2;
const int speed = 255;

WiFlyServer server(7778);

void setup() {

  pinMode(dirA, OUTPUT); //Initiates Motor Channel A pin
pinMode(brakeA, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel B
pinMode(dirB, OUTPUT); //Initiates Motor Channel A pin
pinMode(brakeB, OUTPUT); //Initiates Brake Channel A pin

  if (!WiFly.join(ssid, passphrase)) {
    while (1) {
      // Hang on failure.

  Serial.print("IP: ");


void loop() {

  WiFlyClient client = server.available();
  if (client) {
    while (client.connected()) {
      //if (client.available()) {
        char c = client.read();
         while(c == 'F'){ // forward
            digitalWrite(dirA, HIGH); //Establishes forward direction of Channel A
          digitalWrite(dirB, LOW); //Establishes backward direction of Channel B
          digitalWrite(brakeB, LOW); //Disengage the Brake for Channel B
          digitalWrite(brakeA, LOW); //Disengage the Brake for Channel A
          analogWrite(pwmA, speed); //Spins the motor on channel A at full speed
          analogWrite(pwmB, speed); //Spins the motor on channel A at full speed

Is my code. I send commands to the IP and correct port and NOTHING happens. i have opened up the port range on both machines on my router, unblocked all firewalls and tried DMZ as well. Nothing works. I can send UDP packets to myself on my own machine fine.

If i submit 'F' nothing happens!

I have tried all coding libraries on the internet including the more complex WiFi HQ, which wont work, when when i route the Tx/Rx through to 6/7. Still wont start.
Ive tried a new library WiFlyserial and its poorly written and doesnt work.

Apparently its set up to recieve UDP commands anyway, so i shouldnt need the advanced libraries.
Ive tried parsing commands through using $$$, but it says 'BAD CONFIG' every single time. And i cant seem to automate these configs using code, everytime i write it using serial.print, it just prints it and doesnt enter cmd mode. I thought setting 'set ip proto 1' would help since thats setting it to UDP. Do i need to do something similar in the code below? I cant enter commands without having the following code;
Code: [Select]
while(SpiSerial.available() > 0) {
  if(Serial.available()) { // Outgoing data

Can you only transmit commands when this SPI UART code is present?

Previously i had a WiFly server loading a webpage and command were recieve through localIp/?forwards etc, but this taken about 10-15 seconds to send a command, which is absolutely useless.
Please, help me out here!

thank you


I suspect that the WiFly library only handles TCP servers.

You can set the WiFly to UDP mode and set up a bi-directional UDP pipe.  You can also turn on "UDP Auto-pairing"  and it will establish a UDP pipe with the first IP address to send a UDP packet to the specified port.

Since you have to do a reset to switch to UDP mode it appears that you can't use UDP and TCP at the same time.

Download and read the Roving Networks "WiFly Command Reference, Advanced Features & Applications User's Guide".
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp

Go Up