XBEE WIFI – DIGI – TCP Receive Problem
So I just bought two new XBEE WIFIs. If you’re not familure with XBEE’s they are little embedded RF Modules that provide a simple serial connection. In the past they have always been over the 802.15.4 protocol, but the new ones communicate over 802.11g/n! up to 65MBps. The new WIFI ones just came out a couple months ago, and there is little documentation online. Digi does provide a manual online.
So with XBEE’s you have Transparent AT Command Mode and API Mode. In Transparent mode you send serial ascii to both send data and must put the xbee in command mode to change any configuration items. You enter command mode by sending three consecutive +’s (“+++”). Now you can send Ascii Command’s with parameters such as “ATFR” to restart the module The more robust communication style is API Mode. In this mode you must generate XBEE API Packets at the byte level.
After configuring the XBEE in the X-CTU application to my Access Point (which it supports WPA2). It automatically DHCP’s an address.
And the problems begin…
I set the Registers for DEST_IP, DEST_PORT, SRC_PORT, PROTOCOL=TCP. After setting those registers, if I then send the module this data serial over UART it automatically creates a TCP/IP socket to the DEST_IP on SRC_PORT from DEST_PORT and sends data. It has no problem creating the Three Way Handshake, sending data over the tcp stream, or even closing the tcp stream. The problem that I have had is receiving data from the TCP Stream. In Transparent Mode it’s supposed to just come back over the UART. it’s not… It’s API Mode it’s supposed to generate a 0xB0 … it doesn’t…
Example Data Sent to XBEE serially [these are the same thing]
Transparent Mode: GET /energy/CommitEnergy.php HTTP/1.0 Host: s157582434.onlinehome.us API Mode: 7E 00 57 20 01 4A D0 3B 1A 00 50 BE EF 01 00 47 45 54 20 2F 65 6E 65 72 67 79 2F 43 6F 6D 6D 69 74 45 6E 65 72 67 79 2E 70 68 70 20 48 54 54 50 2F 31 2E 30 0D 0A 48 6F 73 74 3A 20 73 31 35 37 35 38 32 34 33 34 2E 6F 6E 6C 69 6E 65 68 6F 6D 65 2E 75 73 0D 0A 0D 0A 0D 0A 12
I don’t understand why I’m not getting an HTTP response, I know that the web server was receiving the GET Request in both modes because it saves a msg to a log file. I unsecured my wireless network.. started up BackTrack and ran WireShark in promiscuous mode. After seeing a real TCP Socket Creation and all the correct data, yet still seing no response from the XBEE I decided to email tech support. I will admit they do respond very quickly. Although it’s like they didn’t read my question or look at my pictures.
Dialog with XDIGI Support
Created 10/10/2011 23:37
I’m Connecting to the XBEE via an FTDI cable connected to an Adafruit XBee Adapter Kit. I’m sending API packets from X-CTU. The same problems occur in Transparent Mode. The XBEE is connected to my wireless access point and I’ve set the router to OPEN security so I could debug the traffic. It DHCP’s the IP Address of 192.168.1.100. In Wireshark I see successful connection to the DEST IP with data coming back.
I’m establishing a connection to a remote web server <4AD03B1F>(22.214.171.124) to port <0050>(80) from port <BEEF>(48879).
Problem #1) I never receive any data back in either Transparent or API Mode. I’m expecting an API packet of B0 (Rx IPV4 Packet). In wireshark I have seen TCP data being returned to the XBEE. [Attached]
Problem #2) If I try the connection again even though the webserver should have already closed the TCP Connection it crashes the XBEE. I’ve even seen the FIN, ACK in wireshark. I receive
 01 04 – Physical error occurred on the interface with the WIFI Transeiver.
[8A] 03 72 – No longer joined to access point.
From that point if I try to transmit I get a:
 01 03 – Transmission was purged because it was attempted before stack was up.
Data Sending [Transparent & API Mode]
GET /energy/CommitEnergy.php HTTP/1.0
//SEND Get REQUEST to Web Server
7E 00 57 20 01 4A D0 3B 1A 00 50 BE EF 01 00 47 45 54 20 2F 65
6E 65 72 67 79 2F 43 6F 6D 6D 69 74 45 6E 65 72 67 79 2E 70 68
70 20 48 54 54 50 2F 31 2E 30 0D 0A 48 6F 73 74 3A 20 73 31 35
37 35 38 32 34 33 34 2E 6F 6E 6C 69 6E 65 68 6F 6D 65 2E 75 73
0D 0A 0D 0A 0D 0A 12
10/11/2011 – 08:15 (Case Set to Presumably Fixed & Closed)
Thank you for contacting Digi. Try entering the port numbers in the X-CTU for the WIFI module in the Hex values. I think you will have better luck.
If there is anything else I can do for you, please let me know.
Digi RF Technical Support
10/11/2011 – 09:55 (My Response to this statement)
I did use hex… I used 0x0050 for port 80, and 0xBEEF for port for 48879. I see that the XBEE is making clear connections and the webserver is sending TCP data back via Wireshark AIRMON capturing. However, no data is returned in either Tranparent Mode or API Packet B0 from the XBEE.
10/11/2011 – 10:11
Are you able to get it to work with the X-CTU and Hyper-terminal? Are you able to enter command mode and make changes to the radios settings?
10/11/2011 – 11:10
Yes, I can use Command Mode or API Mode to change radio settings.
In Transparent Mode I cat set the DEST in HEX, and PORT in HEX.
I am making a successful TCPIP Connection!!
The Device is doing the TCP Handshake, and TCPIPv4 Sending and in API Mode I receive a Success Message. The webserver did receive the Request because it acted on the the XBEE’s Request.
However, the XBEE is not showing me that it received the webserver’s communication back! In Transparent Mode I get nothing else in X-CTU Terminal and in API Mode I get no TCPIP Receive (B0) Packet.
10/11/2011 – 13:37 (wow.. and he got a leet time…)
To help narrow down the possible cause, are you able to use Hyper-terminal and X-CTU to create a connection to the radio via the PC’s COM port and the WIFI connection and then send and receive data back and forth? Keep in mind that your web server can’t do this so we are trying to take it out of the picture to see if it is an issue with it or not.
10/11/2011 – 14:59 (My Response)
Yes, I can make a connection to the XBEE over COM6.
Yes, I can connect and send TCP packets in either Transparent or API over WIFI.
However, if server sends data back, example:
TCP Packets returned from the webserver! through my router. (directed to my XBEE) they don’t appear
I know they are returned to the XBEE because I can see them from a third party wireshark sniffer in premiscuous mode..
The problem is XBEE does not aknowledge receiving TCP Packets!
Please view images from my original email, it shows a clear TCP/IP Connection to Close from XBEE to WebServer!
While Hyper Terminal or X-CTU shows ZERO data returned.
Attached is another image.
10/11/2011 – 15:08
The radio does not accept direct TCP/IP packets. You need to create a socket to it for it to send and receive data via its WIFI ports.
10/11/2011 – 18:40
Ok… If I am sending data to a remote server over TCP/IP I am creating a socket correct? You use API “FrameType 0x20 Transmit (TX) request IPv4” to create a socket correct?
AFAIK it creates the socket automatically when you send data via the 0x20 command, am I mistaken? because that is what it is doing… and it creates a TCP Socket with 3-way hand shake and all, and sends the data….
The only problem is.. it’s not returning the received data from the TCPIP Socket to the ReadSerial with a 0xB0 API Packet.
And we wait for a response…
10/12/2011 – I was able to get the wifi expert on the phone and talked to him about the problem. He’ll be looking in to it.
10/18/2011 – Video I just created tonight to show problem.
*You’ll probably want to watch this in HD.
I finally did get a response back from the DigiKey rep.
Welcome back from you deployment. The new version of the firmware fixes the TCP handling issues you were seeing.
When you are ready, just give me a call and we can continue to work on the XBee WF.
I did specifically test this. Works Fine — I was able to connect to a TCP server (e.g. webserver) and data received before timeout (connection closes) it returns the received data back to me as the end user.
Now on to the DNS Issues…. X_X