Trying to send UDP packets through a Le-wei 5G wifi modules onboard RX pin using arduino serial

Viewed 133

I have a 5G wifi module hooked up to a arduino nano 33 ble via RX/TX pins, I can send UDP packets from a UDP monitor app on android using port 50000 over UDP and receive them on the wifi modules tx pin that is connected to arduino's rx pin and print it on the serial monitor using baud speed of 115200 but I can't send any packets or anything for that matter on the modules rx pin. At this point im just trying to send anything that can be received by another device that is connected on the same wifi network, the wifi module im using I cant seem to find any information on as the wifi module was taken out of a cheap chinese drone.

this is the exact same model first link below....

notice the 4 wires.. 2 are for the power, other 2 wires are tx and rx, I believe they are used as serial as I can receive from the modules tx thats connected directly to arduinos rx serial when I send a udp message on port 5000 to ip 192.168.0.1 from a (UDP app on android). So must be a way to send data back to the android app by using the modules rx wire just like the flight controller did that was previously connected.

https://www.aliexpress.com/item/4000228028568.html?gatewayAdapt=glo2nld

appears to be made by this company

http://www.le-wei.com/eacp_view.asp?id=59

Im sure I have to send a UDP packet (header plus data) to the device I want to send the udp message to IE...the UDP monitor app im using on android. I know there are UDP libraries available but they all seem to use wifi modules that aren't connected via serial rx/tx.

Do I need to construct a udp packet containing port and ip of the device I want to receive the message to if so how would I do this using arduino but only sending the info on the arduino serial tx line, also not sure if the constructed packet should be in binary or hex

something like...

    //example only - udp in binary
            String COMPLETE_UDP_DATAGRAM_PACKET="110000110101000011000011010100000000000000000100101101001101000001001000011011110110110001100001";
            
            //example only - udp in hex
            String COMPLETE_UDP_DATAGRAM_PACKET="C350C3500004B4D0486F6C61";
            
                serial.write(COMPLETE_UDP_DATAGRAM_PACKET);
            
    
    //hhhm or something like this maybe,could this possibly work?
//no maybe not as I think the UDP var needs to be binded first.
           serial.write(udp.beginPacket(IP,port));
           serial.write(udp.send(packet)); 
           serial.write(udp.endPacket());

UPDATE: The wifi module im using was connected to a toy drone the tx/rx pins was being used for telemetry back and fourth from the drone app to the wifi module then the drones flight controller, the flight controller was originally sending information on the same wifi rx pin in the form of UDP that im trying to accomplish now but because I don't have the flight controller anymore I cant hook it back up to sniff the packets that the (fc) was sending to the wifis rx pins if so I could maybe sniff the packets using wireshark and figure out what to send on the .write() or .print() function to the module rx pin that will then be sent to the receiving device IE..IP 192.168.0.20 PORT 50000

Any help or suggestions would be much appreciated thanks.

Arduino code below

 
UART WIfISerial(digitalPinToPinName(A3), digitalPinToPinName(A2), NC, NC);


// If anything comes in from the wifi module
// TX pin that is connected to arduino rx pin


if (WIfISerial.available()) { 
////THIS WORKS PERFECT , ANY UPD APP CAN SEND UDP MESSAGES HERE

    Serial.println(WIfISerial.read());   // read it and send it out to Serial
  }


  if (Serial.available()) {     // If anything comes in on Serial then send to wifi module
   //udp packet
  //WIfISerial.print("0100010100000000000000000011001110000011001111100000000000000000100000000001000100110110000101011100000010101000000000000000000111000000101010000000000000010100100111000100000011000011010100000000000000011111011000010011101100110001001100000011101000110010001101000011101000110001001110000010000001110000011011010010000000110010001100000011001000110011001110010011010100110001001101100011000000111000001110010000"); 

//send some data back to the UDP monitor android app
WIfISerial.write(Serial.read());  

  }

UPDATE: after getting my hands back on the flight controller I connected the wifi unit back up to the fc and read the packets coming in to the wifi module and have successfully sent a packet of data using the following code

//YES THIS WORKS BUT WHY?? I DONT THINK THIS IS UDP
WIfISerial.write(0xFF);//BEGINNING OF PACKET
WIfISerial.write(0xFE);//BEGINNING OF PACKET
WIfISerial.write(0x06);//PACKET SIZE IN BYTES
WIfISerial.write(0x09);
WIfISerial.write(0x06);
WIfISerial.write(0x04);
WIfISerial.write(0xFF);
WIfISerial.write(0xFF);
WIfISerial.write(0xFF);
1 Answers

Ok I have it working. Quite simple really :(

The module is not sending UDP packets as I initially thought, only UDP packets are sent to the module when connected on the same network the wifi module itsel actually sends data as fffe=header 0x04=size of following data in bytes 0x06,0x05,0x00,0x04=data in bytes

byte message[] = {0xFF, 0xFE, dataBytes+2 ,s[0],s[1],s[2],s[3], 0x06, 0x05};

WIfISerial.write(message, sizeof(message));

Related