Tom's Main Menu

Physical Computing Home

Intro to Physical Computing Syllabus

Networked Objects

Sustainable Practices

blog

Resources

code, circuits, & construction

my del.icio.us links

 

CoBox Micro: Customizing the Web interface

 

The Web interface of a Cobox Micro can be customized using HTML, Java applets, and a tool called web2cob.exe. Jürgen Littwin and Garry Morris have written an excellent guide to Web Enabling Your Device server that tells you everything you need to know to make a custom site on a Cobox, Xport, or WiPort device server, and how to write java applets to connect to the device's serial port. What follows is a summary of their notes, with a few additions, and java code based on theirs.

The first thing you need to know is that the whole web site on a Cobox device can't be more than 64KB in size. That's not much room, but you can fit a few web pages and an applet or two, if you're careful.

The HTML files for the Cobox devices is plain HTML, no frills. It's all interpreted by the client browser, there's no way to access any of the device's properties using HTML alone. So you can put whatever HTML, images, and other static files that you want to on the Cobox, as long as it fits in the 64KB memory.

To access the serial port, you have to establish a socket connection with the device on the right port, just as shown in my Cobox java examples. There's nothing special to it. You simply open a TCP socket to the appropriate port number, and start talking. The code example above is a java applet that can live on the Cobox. It makes a socket connection to the serial port, then opens a panel with a keyboard input text box and a serial output text box and shows you what's going between the serial port and the applet. This example is based in Garry and Jürgen's code.

To load your HTML and applets onto your device, you need a PC application called web2cob.exe, available from Lantronix. It's available on Windows only, unfortunately. Put all of your HTML, applet classes, and whatever else you want into a directory (we'll call it "source"). The web2cob application is tiny, so just copy the application into the directory that "source" lives in for the next part. You'll also need another file, mimetype.ini. There's a copy of it at this link. This file should also live in the same directory as the source directory and the web2cob application.

Web2cob is a command line application, so you'll have to open a command window, Go to the Run menu and type cmd. In the command window, change directories until you're in the directory that web2cob and source are in. For example, in Windows XP, you might put them both in a directory called "cobweb" on the Desktop, and change directories like this:

cd Desktop\cobweb

Next, you'll make a binary file to load onto the Cobox (called a .cob file) from the source directory. To do this, type

web2cob /d source /o web1.cob

This will make a new file, web1.cob, in your directory. You need to transfer this to the Cobox using the TFTP protocol (trivial file transfer). Windows has a TFTP tool built in, so you can use it, by typing

tftp -i xxx.xxx.xxx.xxx PUT web1.cob WEB1

Replace the xxx.xxx.xxx.xxx with your device's IP address. This will transfer your web pages and applets to the Cobox.

That's it! Now open a browser, and open URLs for your pages on your device. For example, if you made a page called "mypage.html" and your device is 192.168.0.12, then open http://192.126.0.12/mypage.html and you'll see your page.

One final note: you may not be able to replace the device's configuration page, index.html, with your own, so just use different names.

Most of these notes apply to the Xport as well as the Cobox Micro.