Awesome. The reason I asked is because I sneaked some time and managed to get the WiPiler (WiCli) running. To use it, requires an outside accessible IP address for the target controller.
Below is a snap shot of a session using a few token commands. The CLI executes the connect string and the last command entered, so the first command must always be the connect string. The "LAST" command gets executed when the ENTER key is pressed, but you can navigate around the command area using the arrow keys and/or mouse.
Connect: 000.000.000.000, the controllers IP address - php evaluates the address, decides if its valid, then pings it.
RAM, returns the number of bytes currently free in RAM
FREE, shows available memory using malloc/free
USED, shows memory used using malloc/free
KILL, resets the controller
ELAPSED, shows minutes elapsed since power up
LED1 ON, turns a LED on
LED1 OFF, turns a LED off
The commands and responses happen in real time, and the Response window updates automatically as soon as a reply from the controller is received. Using the "Save" button, saves the session commands and responses in an xml file.

- 1ss1.jpg (69.79 KiB) Viewed 42 times
This is the Sketch, and its for WiServer mode.
- Code: Select all
/*
* for WiPiler / WiCli
*/
#include <WiServer.h>
/******************************************
* Wireless SetUp *
******************************************/
unsigned char local_ip[] = {10,1,1,3};
unsigned char gateway_ip[] = {10,1,1,1};
unsigned char subnet_mask[] = {255,0,0,0};
const prog_char ssid[] PROGMEM = {"SSID"};
unsigned char security_type = 2;
const prog_char security_passphrase[] PROGMEM = {"password"};
prog_uchar wep_keys[] PROGMEM = {};
unsigned char wireless_mode = 1;
unsigned char ssid_len;
unsigned char security_passphrase_len;
/******************************************
* Variables *
******************************************/
unsigned long theMinutes; // Minutes elapsed since start up
extern int __bss_end; // used by freemem
extern int *__brkval; // used by freemem
char nuMbuf[10]; // holds result of itoa
int cType=2048; // RAM value for a 328 controller
#define cmds_count 7 // number of commands in list below
char *cmds[]={ "/", "/?LED1_ON", "/?LED1_OFF", "/?KILL", "/?ELAPSED", "/?FREE", "/?USED", "/?RAM" };
int cmd_selected=99; // an invalid command value
/******************************************
* Funtion Definitions *
******************************************/
// FUNCTION: Send reply
void reply (char* respond){
WiServer.print(respond); // send response
WiServer.print("\r\n");
}
// FUNCTION: Calculate Available memory using malloc
int availableMemory() {
int aM_size = 2048;
byte *aM_buf;
while ((aM_buf = (byte *) malloc(--aM_size)) == NULL);
free(aM_buf);
return aM_size;
}
// FUNCTION: return the number of bytes currently free in RAM
int freemem(){
int free_memory;
if((int)__brkval == 0)
free_memory = ((int)&free_memory) - ((int)&__bss_end);
else
free_memory = ((int)&free_memory) - ((int)__brkval);
return free_memory;
}
// Function that generates responses for recognized URL commands
boolean sendMyPage(char* URL) {
cmd_selected=99; // 99 is an invalid command
// We examine the URL command against the cmds array
for( int comp_cmds=0; comp_cmds <= cmds_count; comp_cmds++) {
if (strcmp(URL, cmds[comp_cmds]) == 0) {
cmd_selected=comp_cmds; // the value of a command match
}
}
switch (cmd_selected) {
case 0: { // Check if the requested URL matches "/" - the default home page
reply ("<html><title>Server ready</title><p>Ready ></p></html>"); // send response
break;
}
case 1: { // COMMAND: "/LED1 ON" turn led on
reply ("LED 1 is ON"); // send response
break;
}
case 2: { //LED1 OFF" turn led off
reply ("LED 1 is OFF"); // send response
break;
}
case 3: { // COMMAND: "/KILL" reset
reply ("Resetting"); // send response
WiServer.init(sendMyPage); // do a reset
break;
}
case 4: { // COMMAND: "/ELAPSED" microsceonds since power up
reply (itoa(millis()/1000/60, nuMbuf, 10)); // send response
break;
}
case 5: { // COMMAND: "/FREE" report available memory
reply (itoa(availableMemory(), nuMbuf,10)); // send response
break;
}
case 6: { // COMMAND: "/USED" report memory used
reply (itoa(cType-availableMemory(), nuMbuf,10)); // send response
break;
}
case 7: { // COMMAND: "/RAM" report available RAM
reply (itoa(freemem(), nuMbuf,10)); // send response
break;
}
default: {
// The default output is page name is unknown. This seems to fix controllers locking-up when bots visit looking for content
reply("ok"); // something was typed but we don't know what, so reply with an ok acknowledgement
return true; // URL was recognized
}
}
return true;
}
/******************************************
* SETUP *
******************************************/
void setup() {
WiServer.init(sendMyPage); // Initialize WiServer
WiServer.enableVerboseMode(false); // Turn off event printing
}
/******************************************
* LOOP *
******************************************/
void loop(){
// Run the WiServer
WiServer.server_task();
}
/******************************************
* END *
******************************************/
If you want to try the application, you can go to ( http://www.cssgurus.com/pm/ ) and register a new account, that takes 2 seconds and you can start playing immediately.
If you do and you come across any bugs, let me know. I expect there'll be a few ajax issues with different browsers so as long as you've got Firefox then it should be sweet = )
..
EDIT Sketch updated, RAM command added
EDIT Introduced a command array and switch/case command translator to save a few bytes, 53 to be exact 30/05/10