     else if (state==5 && !strcmp (wlinebuf,"OK"))        { state_5_6 (); }
     else if (state==6 && !strcmp (wlinebuf,"0,CONNECT")) { state_6_7 (); }
     else if (state==7 && !strcmp (wlinebuf,"0,CLOSED"))  { state_7_6 (); }
-    else if (state==8 && !strcmp (wlinebuf,"OK"))        { state_8_7 (); }
+    else if (state==8 && !strcmp (wlinebuf,"SEND OK"))   { state_8_7 (); }
     
     if (!strncmp (wlinebuf,"+IPD,",5)) {  // incoming command (or CR/LF)
         char * mark = wlinebuf + 6;

}

void state_0_1 () {
    wsend("AT+CWMODE=3");
    state = 1;
}

#include <Wire.h>
#include <ArduCAM.h>
#include <SPI.h>
#include "ov2640_regs.h"

//#define HOSTCONN
//#if defined HOSTCONN
//#include <AltSoftSerial.h>
//AltSoftSerial SWserial;
//#endif

void handle_host ();
void xlog (char * origin, char * text);
void xlognum (char * origin, char * text, int number);
void w_handle_line ();
void rsend (char * msg);

void state_0_1 ();
void state_1_2 ();
void state_2_3 ();
void state_3_4 ();
void state_4_5 ();
void state_5_6 ();
void state_6_7 ();
void state_7_6 ();
void state_8_7 ();

void handle_command (char * command);
void handle_command_ok (char * command);
void handle_command_pic (char * command);

const int CS = 6;
ArduCAM cam(OV2640, CS);
