Using a wr703n for wifi connectivity

Inside the Roomba and Scooba and more, Cool mods, Repair and Upgrades - including the all new iRobot Create Kit. Let's void that warranty baby!

Using a wr703n for wifi connectivity

Postby Loshki » January 4th, 2015, 7:40 pm

For around $20 shipped, the wr703n is a 4M flash/32M RAM linux-capable
router, with a built-in wifi, usb port, and ethernet. It struck me
that this might be the perfect cheap wifi dongle for a Neato, and
other kit. The CPU may not be a giant, but it's plenty for shuffling
bytes there and back over wifi and its other interfaces. I also like the idea
of no soldering, or breaking of any seals etc. (less of an issue on a Botvac).

I am a big fan of the wr703n, Most of the gory details (far too many, in
fact) are here: http://wiki.openwrt.org/toh/tp-link/tl-wr703n

Here is my attempt to try and save someone else some time and pain by steering you around
the curves I encountered while trying to deploy this little beauty. Sadly, at this point, this is still
little more than a set of notes. Hopefully over time it will evolve.

1) The hardware and firmware versions

The wr703n generally arrives with either CHINESE firmware, or DD-WRT
firmware preinstalled. You want to change this to OPENWRT
firmware. There are several possible gotchas to this upgrade
process

1a) There are apparently at least 7 different hardware versions of
the wr703n. In addition, some are mislabeled, some are labelled with different
version numbers on the outside than on the inside, etc. and so
forth. Ah, the joy of the very low end...

$20 isn't much to risk, but some dealers haven't the faintest idea
about the hardware they're shipping, much less what version, and
some buyers brick perfectly good routers then return them, which I
disapprove of, to say the least. Many sellers find the margins so slim on
these items that they don't pay much attention.
That said, Ebay is pretty pro-buyer-protection these days.

1b) There are a lot of choices for firmware, and the naming is such
that you can't always tell which image runs on which version, so
save yourself some headache and check the
http://wiki.openwrt.org/toh/tp-link/tl-wr703n page for anything special
about your hardware version before you begin.

1c) Openwrt (and other firmwares) distinguish between "factory
install" images and "sysupgrade" images. When you change firmware
from CHINESE or DD-WRT you need a "factory install" image.

1d) moving from Chinese firmware requires a particular technique
and corresponding openwrt image:
http://wiki.villagetelco.org/index.php? ... first_time

1e) moving from dd-wrt requires a different technique and different, special openwrt image
http://www.madox.net/blog/2013/03/10/ho ... ith-dd-wrt
I spent a lot of time vainly trying to boot different firmwares until I discovered this page.

1f) Firmware releases for Openwrt have the usual obligatory alpahbetically noxious names.
The first release is "Attitude Adjustment", the second is "Barrier Breaker". The top-of-tree is currently
Chaos Calmer. If you see mentions of AA, BB and CC, this is what they are talking about.

2) The wrong firmware, or some other disaster (e.g. power outage during upgrade)
may brick your router (i.e. it will no longer respond via any interface). If you
are unfortunate enough to have this happen to you, see
http://forums.openpilot.org/blog/52/ent ... ifi-router
and later portions of http://wiki.openwrt.org/toh/tp-link/tl-wr703n.

In the worst case, the wr703n will only be recoverable by soldering in
a serial port connection. This is extremely small and fiddly
work. Don't call me. See instead
http://forums.openpilot.org/blog/52/ent ... ifi-router
and later portions of http://wiki.openwrt.org/toh/tp-link/tl-wr703n.

NOTE: One workaround to the potentially awkward soldering problem
of a bricked router might be the GL.inet 6416 mini smart router. This is a tarted up
(binary compatible?) wr703n with extra flash, an extra ethernet port, and
get this, three pins already wired for rs232 console tx/rx/gnd, so
even if you brick it, you don't need to do any soldering to bring it
back from the dead. Mine cost $26 off ebay, shipped.

3) Once your wr703n is flashed, and successfully comes back up, you
have a number of choices, but the easiest thing to do initially is to
simply configure it as a regular old AP. Ultimately, you may want to
configure the wr703n as a bridged wireless client to your main wifi,
but that's well beyond the scope of this note.

The router will come up with ip address 192.168.1.1 and you can access
it via the web page at that address. Set a root password, setup a
dhcp-server (which does not conflict with any existing one), and then
login to it over the ethernet port via ssh, or access it via
the web page, or both at the same time.

Actually, the first thing I do is change the wr703n address to 192.168.1.2 (which I keep reserved) and
plug it into my main, wired network, for ease of access.

4) Talking to the USB port via ser2net

Once your router is up, you plug your Neato via USB into your wr703n running Openwrt, it
should be detected automatically. The "dmesg" command should show that
it was detected.

[ 33.680000] cdc_acm 1-1:1.0: This device cannot do calls on its own. It is not a modem.
[ 33.690000] cdc_acm 1-1:1.0: ttyACM0: USB ACM device

To talk to the USB port, we will use a program called ser2net.

4a) Edit the configuration file for ser2net at /etc/ser2net.conf.

It only need contain the one line, as follows:

3000:telnet:0:/dev/ttyACM0:115200

This line says to listen for incoming telnet connections on port 3000, and connect them
to /dev/ttyACM0 at 115200 baud. Other possible options (none of which
I needed) are listed in the comments in /etc/ser2net.conf.

One last thing, ser2net doesn't start automatically, so add
the following line to /etc/rc.local *before* the exit 0,
so the file looks like this:

# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.

ser2net &
exit 0

At this point, you need to reboot (or simply start ser2net by hand from the
console by typing ser2net &), which saves having to wait 30 seconds for a reboot.

5) A USB power on/power off workaround.

My XV is one of those that won't clean with the USB cable still
connected. No problem. On Openwrt says the docs, you can switch the
USB power on and off using the cli GPIO command:

USB Power off
-------------
echo 0 > /sys/class/gpio/gpio8/value

USB Power on
------------
echo 1 > /sys/class/gpio/gpio8/value

I tried this of course, and IT DOESN'T WORK, at least, not for
me. Maybe you'll have better luck and I'll be able to update this
document later. Investigation is, as they say, ongoing.

I was about to throw in the towel at this point, when I noticed that
if I issued two "Clean" commands, the unit would complain about the
USB cable being connected. If I pulled the USB plug out, then plugged
it back in straight away, the XV would start cleaning and continue
issuing and responding to telemetry!

So on a hunch, I reconnected everything, issued two "Clean" commands,
and hit "reboot" on the router. When the wr703n reboots, it drops the
USB connection, and the XV starts its cleaning cycle.

Thirty seconds later, the wr703n is rebooted and is once again ready
to send/receive telemetry. At this point, you have to reconnect to the
AP and restart telnet (or ssh) of course, and you've missed 30 seconds of telemetry,
but this should be scriptable. Under linux, this is left as an exercise for the reader,
and will have to do until I can do some debugging work on gpio.

I'm struggling to get this written before I go on vacation. As
feedback comes in, I will update this doc, assuming there is enough
interest. Bear in mind that when the first questions come in, I will be
on a beach tapping out replies using a tiny pink umbrella as a stylus,
so please be patient.

Loshki
User avatar
Loshki
 
Posts: 33
Joined: July 12th, 2014, 11:31 pm

Re: Using a wr703n for wifi connectivity

Postby vic7767 » January 5th, 2015, 12:12 am

I've noticed that the prices are going up a little on ebay for the WR703n. Some Chinese hackers are adding more memory and UART/USB as well as openwrt pre installed.
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 14371
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Using a wr703n for wifi connectivity

Postby ThisGuyDave » January 11th, 2015, 7:40 pm

Excellent write up. Thank you .. really appreciate it.

And hope you update.


I have my 703N running and can telnet into my Neato XV-21 and still trying to figure these things out.
I'm curious to know what is the advantage of Ser2net ?
at the moment I'm just echo'ing to ttyACM0
Trying to figure out Ser2net, but not exactly sure if it's really working !
ThisGuyDave
 
Posts: 5
Joined: January 2nd, 2015, 11:55 pm

Re: Using a wr703n for wifi connectivity

Postby amund7 » February 25th, 2015, 6:23 pm

Sounds so promising I just ordered that WR703N.

I have a Botvac 85, and rumour say I will get away the whole 'can't clean with USB cable connected'-problems.

Keep up the good work! And please post pictures of your final packaging, where did you get power for the WR, did you hook it to the USB plug or solder your wires somewhere else?

And then my stupid question - do I really have to reflash the unit to make it work? Or is the flash just to get rid of the Chinese? Because I think I can live with the Chinese, guessing it's just the web interface that's chinese, surely the linux commands and messages are still English...
amund7
 
Posts: 5
Joined: February 24th, 2015, 4:50 pm

Re: Using a wr703n for wifi connectivity

Postby vic7767 » February 25th, 2015, 7:03 pm

Attachments
A703.jpg
Roomba and Neato Mods, come visit: http://www.vic7767.com/

http://www.Robot-Doc.com/
User avatar
vic7767
Robot Master
 
Posts: 14371
Joined: January 14th, 2006, 8:31 pm
Location: Haughton Louisiana - USA

Re: Using a wr703n for wifi connectivity

Postby glnc222 » February 25th, 2015, 9:13 pm

The issue is whether it has a Host usb interface in the openwrt flashing. How does that work?
glnc222
Robot Master
 
Posts: 4541
Joined: January 23rd, 2012, 9:19 pm
Location: North Carolina, U.S.

Re: Using a wr703n for wifi connectivity

Postby Loshki » February 26th, 2015, 1:11 am

amund7 wrote
..please post pictures of your final packaging, where did you get power for the WR, did you hook it to the USB plug or solder your wires somewhere else?


I totally cheated on the power, and used a standalone battery pack: "PowerGen 5200mAh External Battery Pack High Capacity Power Bank Charger 1A output for Apple and Android Devices" off Amazon. My rationale was that I wanted a mod that wouldn't invalidate any warranty, and that I hate to solder. There are postings by others who have opened their XVs to add wireless (though generally not wi-fi), detailing what they had to do to tap power for it.

I would expect that the USB port on the Neato supplies zero power (I have not verified this). It shouldn't, since it is a USB client. As far as I know, only USB hosts are allowed to supply power.

amund7 then said
do I really have to reflash the unit to make it work? Or is the flash just to get rid of the Chinese? Because I think I can live with the Chinese, guessing it's just the web interface that's chinese, surely the linux commands and messages are still English


I don't actually know the answer to this either (yet). I would normally test this for you, but two of my routers are currently bricked, awaiting soldering. But that won't stop me pontificating. There is a good chance that the web interface is indeed just a Chinese layer with the same old dd-wrt/openwrt underneath. I can't imagine the thrifty Chinese deciding it was worth their time to rewrite anything but the web interface. If that's true, then provided you can get access to the router, with its Chinese config, via telnet or ssh, you should be able to do everything you need. I hope to update my post soon with additional material about communicating with the Neato.

Update March 5 2015: I have tried telnetting and ssh-ing into the wr703n while the Chinese firmware is running, and neither service is enabled by default, at least in the firmware mine came with. I tried locating an SSH server or telnet server configuration page in the Chinese web interface in order to enable them, but couldn't find anything that looked appropriate. I will add a note to this effect in the main document. Perhaps some reader of Mandarin will come along and be able to help.

Loshki @ Loshki's house. Where old Neatos go to die...
Last edited by Loshki on March 5th, 2015, 4:27 am, edited 1 time in total.
User avatar
Loshki
 
Posts: 33
Joined: July 12th, 2014, 11:31 pm

Re: Using a wr703n for wifi connectivity

Postby Loshki » February 26th, 2015, 2:50 am

glnc222 wrote:The issue is whether it has a Host usb interface in the openwrt flashing. How does that work?


There is a standard size USB-A female socket on the wr703n, making it a usb host, which is what allows it to talk to a Neato (or any other serial device, depending on the usb-to-serial cable and the chip it uses). Host interfaces like this are common on such mini-routers, since they allow you to plug in USB drives, hubs, cameras and assorted what-not. Unless you use a powered hub, the host is on the hook for meeting the power requirements of whatever you plug in to it, up to certain limits.

This USB interface is not normally involved in the flashing process as such. In general, when you flash, you use either the built-in ethernet interface, or the built-in wifi interface, preferably the former, as it's generally the most stable.

As you might expect, some software is involved in USB support for so many different devices. This takes the form of openwrt packages containing the requisite software modules, which need to be installed, either at image creation time (which makes the image larger, but is obligatory if something is crucial for booting), or later at run-time, as an installable package. This allows a cafeteria style of selectable features, which is a boon when you only have a tiny amount of space to work in, as on the wr703n.

There is also a micro-usb port that supplies power to the wr703n. It usually carries no data (but see slboat's crafty hardware mod on ebay where he routes the serial console out via the data pins in the micro-usb power port). With this single exception, this port is used exclusively for powering the wr703n and plays no other part in flashing, booting or running.

There's a lot more that could be said about what is, after all, a tiny but nonetheless rather well-endowed linux box, and your question seems broad. Did I cover any of what you wanted to know?

Loshki
User avatar
Loshki
 
Posts: 33
Joined: July 12th, 2014, 11:31 pm

Re: Using a wr703n for wifi connectivity

Postby glnc222 » February 26th, 2015, 5:26 pm

Very instructive, thankyou. So as I understand it, these tiny routers are made to work as host usb connections as they are supplied? This seems to contrast with the USB connection I see on microcontroller packages like Arduino, where they are made to connect to a PC for programming, being a client to the PC host. Only special add-ons, shields or what not, provide host functions. One supplier told me only the largest Arduino would work the host parts because designed for high speed disk interface connections etc. requiring fast cpu's, power hungry. I suppose these little routers are hosts because made to attach to tablets or phones, which are already clients made to attach to a PC for data sharing. Routers made for PC's are for the PC as host, so quite different.

I take it the firmware enhancements are for configuring the WiFi connection between the little router and a WiFi network on a main router attached to the internet and PC's.

Sounds like a book could be written on using these mini routers.
glnc222
Robot Master
 
Posts: 4541
Joined: January 23rd, 2012, 9:19 pm
Location: North Carolina, U.S.

Re: Using a wr703n for wifi connectivity

Postby glnc222 » February 26th, 2015, 6:15 pm

Maybe not relevant, but for the PC side of this connection, an independent Windows driver for Neato USB connection, alternative to the Neato factory one, was once published by Randomworkshop and since removed from the web.
I found one of those here Vic7767 posted in a Roomba context but noted as Neato XV-11.

http://www.robotreviews.com/chat/viewtopic.php?f=4&t=17580

The Neato driver creates a serial com port through the USB connection. I recall there being separate 32-bit and 64-bit Windows versions, and this looks like 64. When installed such alternative drivers prevent the firmware updating website functions working, presumably because they look for the factory driver itself instead of just the bot device, and the port is already occupied. These drivers use a configurable USB driver function included in windows shown as usbser. The driver is in the form of an INF file which Windows uses to install driver software.

Presumably something similar is needed for the WiFi connection in the PC instead of the USB. A COM port must be created for the serial terminal traffic with the bot.
glnc222
Robot Master
 
Posts: 4541
Joined: January 23rd, 2012, 9:19 pm
Location: North Carolina, U.S.

Re: Using a wr703n for wifi connectivity

Postby amund7 » March 1st, 2015, 5:33 am

Small update, I cancelled the WR703N as it was delayed, and in the meantime realizing I could get a Raspberry Pi for just a bit more. So I ordered that. The Pi is meant to work on, reflash, the B+ and 2 B+ has 4 usb ports, OS supports wifi dongles, plus it should be fun for lots of other things.

The Botvac powered my Xbee xplorer and also my Arduino from the USB port thru an OTG cable. But when you connect the USB host side I suppose power is not going back that way. Maybe hack a cable. Hard to know how much you can safely draw from it, I suppose a USB 'slave' plug is not supposed to feed power.

Will report back when I get the Pi and have some progress, but that's a new thread I suppose.
amund7
 
Posts: 5
Joined: February 24th, 2015, 4:50 pm

Re: Using a wr703n for wifi connectivity

Postby DaaNMaGeDDoN » June 1st, 2015, 4:30 am

Hi all, some time ago i noticed the neato driver sw installed (to update the firmware) created a serial interface, played with it, googled around, found the documentation, all exciting stuff. So i became inspired to incorporate the neato into my domotica infra. Today i decided to have a more closer look and read a lot on the subject, when i found http://www.robotreviews.com/chat/viewtopic.php?f=20&t=17844 linking here, i got really excited :)
Status quo: found out about the need to have some sort of USB host-controller and the dreaded "Please unplug me before i can clean"-issue.

Thought1: Ending up here i was wondering if the TP link clone "GL.inet 6416 mini smart router" mentioned, with its GPIO pins might be a solution? How about completely disconnecting the serial line with some transistors or maybe a relay switch that is/are controlled by these GPIO(s)?

But maybe that isn't even necessary in my case:
Thought 2: I am actually only interested in remotely sending it the "Clean" command, with it actually starting cleaning of course and maybe monitor battery charge while docked. I have a RF (domotica) controlled wallswitch before the charger station, that allows me to only charge for a couple of hours a day. (I noticed the neato likes to draw quite some power while just sitting idle)
I see an opportunity here: the moment the charger is powered on the neato comes to life. Also i could power the controller using only the charger rails. Through some neat scripting i could communicate with the controller over the network, check the battery level, charge for as long as needed and start a clean command. I read that a reboot of the controller overcomes the "please unplug me"-issue, can anybody confirm that? If that's the case i can see only one culprit: neato starts cleaning->neato returns to charge (isn't ready yet)->controller unit comes back->neato won't continue cleaning because it thinks it's connected to USB. I could of course monitor how long my domotica system hasn't been able to talk to the neato and derive from that if it made a full pass. But will it resume cleaning if i reboot the controller again? Can you share your thoughts on that? Maybe i should just test that....ideas are welcome.
And great info btw, i learned a lot today, many thanks all and especially Loshki for sharing :D
PS: I am not a native English speaker, hope you are able to digest my post ;)
DaaNMaGeDDoN
 
Posts: 1
Joined: June 1st, 2015, 3:43 am

Re: Using a wr703n for wifi connectivity

Postby glnc222 » August 9th, 2015, 11:07 pm

For simple launching operation:
Check out suggestion in "mods & repairs" list main Neato forum page: connect USB at dock, pulls out when bot moves away. Software involved. Available for PC host. Maybe something else for a remote device (possibly cut power to the interface?).
Note discovery Botvac does not have the "pull plug" demand (but has an inaccessible plug...). Also you can reconnect after the bot moves, the way the firmware works.
You can do things in the firmware of the routers (no idea how myself). One of the projects (Neato forum) had a solid state relay I think. Space for parts and power supply is the issue with wireless additions. The VR200 added wireless components, so maybe eventually in a Neato model. Apparently just takes an IC, some antenna, same as those tiny routers.
glnc222
Robot Master
 
Posts: 4541
Joined: January 23rd, 2012, 9:19 pm
Location: North Carolina, U.S.


Return to Robotic Hacking

Who is online

Users browsing this forum: Brett, CherkyB, Franzl, moradi2, susantx3, Wing Nut and 329 guests