Monday, August 25, 2008

ant hello

Each free range SPOT can run a small number of commands using the libraries installed on them by default. The OTA command server is charged with intepreting and performing these commands. One of these commands is "ant hello", and it acts as a good indication that your SPOTs and base station are all communicating correctly, read to accept commands, etc.

After messing with some demos, however, I ran into trouble when trying to invoke the simple command. I pleaded with the SunSPOT World forums:


What is the appropriate response for this command? My basestation is connected, OTA server disabled, and running as a basestation. Client one is configured to run the built-in dummy application, and the OTA server is disabled. Client two is configured to run the current application, and the OTA server is enabled. The response to "ant hello":

-run-spotclient-one:
[java] SPOT Client starting...
[java] There are 0 Sun SPOTs in range

[java] Exiting

How do I get both SPOTs in range?

---

First off, the OTA server must be enabled in order for a SPOT to respond to a hello request. The OTA server is the process that (among other things) responds to the hello). If you turn the OTA server on (ant enableota) on the SPOT with the dummy application, it should begin to respond.

Second, you need to be sure you are not running an application that deep sleeps. If the SPOT is sleeping, it will only respond if it happens to be awake when the hello is sent. You don't say what the "current application" on your second SPOT is. What I'd suggest is that you make sure that OTA is enabled, then connect the SPOT via USB and deploy something like the BounceDemo-OnSPOT, which does not attempt to sleep. If you still encounter problems, posting the output of 'ant sdk-info' and 'ant info' for one of the failing SPOTs will provide a place for people on the forum to help debug the situation.

---

I upgraded my SPOTs to blue-sdk, enabled OTA on both the free range SPOTS (disabled by default), started the base station ("ant startbasestation"), and ran "ant hello" with the base station plugged into my PC. However, the command did not work until the base station and the two free range SPOTs were restarted using their respective reset buttons.


To recap:
1. Ensure both fre range SPOTs have loaded on them an application that does not deep sleep.
2. Enable the OTA command server on free range SPOTs usng "ant enableota".
3. Ensure your base station is configured as a base station. Remember, anytime you do an "ant info" on the base sation, you must do an "ant startbasestation".
4. Reset all SPOTs with the reset button on each device.
5. With the base station plugged into the USB port, run "ant hello".

No comments: