a single connection pbp3 version than can turn a led on/off ,report the led state ,and allow a byte var to updated over the web , its fairly robust but not perfect

had a bit of trouble getting the line extender _ to work with arraywrite so watch out for the looooong lines and its still just proof of concept nothing fancy

Code:
'*  Name    : UNTITLED.BAS                                      *
'*  Author  : [select VIEW...EDITOR OPTIONS]                    *
'*  Notice  : Copyright (c) 2014 [select VIEW...EDITOR OPTIONS] *
'*          : All Rights Reserved                               *
'*  Date    : 29/11/2014                                        *
'*  Version : 1.0                                               *
'*  Notes   :   [pic18f45k20                                                *
'*          :                                                 *
'****************************************************************
#CONFIG
  CONFIG  FOSC = INTIO67
  CONFIG  FCMEN = OFF
  CONFIG  IESO = OFF
  CONFIG  PWRT = OFF
  CONFIG  BOREN = SBORDIS
  CONFIG  BORV = 18
  CONFIG  WDTEN = ON
  CONFIG  WDTPS = 512
  CONFIG  CCP2MX = PORTC
  CONFIG  PBADEN = OFF
  CONFIG  LPT1OSC = OFF
  CONFIG  HFOFST = ON
  CONFIG  MCLRE = ON
  CONFIG  STVREN = ON
  CONFIG  LVP = OFF
  CONFIG  XINST = OFF
  CONFIG  DEBUG = OFF
  CONFIG  CP0 = OFF
  CONFIG  CP1 = OFF
  CONFIG  CP2 = OFF
  CONFIG  CP3 = OFF
  CONFIG  CPB = OFF
  CONFIG  CPD = OFF
  CONFIG  WRT0 = OFF
  CONFIG  WRT1 = OFF
  CONFIG  WRT2 = OFF
  CONFIG  WRT3 = OFF
  CONFIG  WRTC = OFF
  CONFIG  WRTB = OFF
  CONFIG  WRTD = OFF
  CONFIG  EBTR0 = OFF
  CONFIG  EBTR1 = OFF
  CONFIG  EBTR2 = OFF
  CONFIG  EBTR3 = OFF
  CONFIG  EBTRB = OFF
#ENDCONFIG


  define OSC 64
  
   osccon=$70   '64 mhz
   
   trisb.7=0
   trisc.6=0
   trisc.1=0    'rst
   trisd.1=0
DEFINE HSER_RCSTA 90h ' Enable serial port & continuous receive
DEFINE HSER_TXSTA 24h ' Enable transmit, BRGH = 1
DEFINE HSER_CLROERR 1 ' Clear overflow automatically
DEFINE HSER_SPBRG 130 ' 9600 Baud @ 64MHz, -0.02%
SPBRGH = 6
BAUDCON.3 = 1         ' Enable 16 bit baudrate generator





  led var latd.1

    
  page var byte[294]      
  head var byte[85]    
  buff var byte[22]
  dummy VAR BYTE[15]
  Hits VAR BYTE 
  tmp var word
  myvar var byte
  ch var byte
 
 ASM       
content_z          = _head+77    
ch_z               = _page+76
hits_z             = _page+100 
my_z               = _page+151                                                                                                 
chk_z              = _page+226
ENDASM   
page[293]=0
head[84]=0
content_z   var byte EXT 
my_z        var byte EXT 
hits_z      var byte EXT 
ch_z        var byte EXT 
chk_z       var byte EXT 
PORTb.7=1       'debug out
OSCTUNE.6=1 
 PORTc.1=1      'rst
 pause 4000 
 Serout2 PORTb.7,84,["ready",13,10]
  
 ARRAYWRITE head,["HTTP/1.1 200 OK",13,10,"Content-Type: text/html",13,10,"Connection: close",13,10,"Content-Length: AAA",13,10,13,10]
 arraywrite page ,["<TITLE>PBP ESP8266 demo</TITLE><H1>Testing the ESP8266</H1><H3>You are ch :-B of 5 </H3>Page visits:CCC<form method=",$22,"post",$22,"><input  maxlength=",$22,"5",$22,"value=",$22,"DDD",$22,"name=",$22,"MyInput",$22," size=",$22,"5",$22,"><br><input type=",$22,"checkbox",$22," name=",$22,"led",$22,"value=",$22,"on",$22,"checked> led<br><input value=",$22,"Change MyInput",$22," type=",$22,"submit",$22,"></form>" ]
 

  

  tmp=293
  ARRAYWRITE content_z,3,,[dec3 tmp]
  tmp=tmp+84
  hits=0
  myvar=0
  led=0
  
Main:
    ' Issue a module reset
    HSEROUT["AT+RST", 13, 10]
    ' Module should respond with a bunch of data and finally 'ready'
    HSERIN[WAIT ("ready"), dummy[0]]

    HSEROUT["AT+CWMODE=3", 13, 10]
    PAUSE 100

    HSEROUT["AT+CWJAP=", 34, "ssid", 34, "," ,34, "password", 34, 13, 10]
    HSERIN[WAIT ("OK"), Dummy[0]]
      PORTc.1=1

    
     PORTc.1=0
    ' Allow multiple connections, module should respond with 'OK'
    HSEROUT["AT+CIPMUX=1", 13, 10]
    HSERIN[WAIT ("OK"), Dummy]
    
     pause 50
     PORTc.1=1
    ' Open port 80 (normal port for HTTP), module should respond with 'OK'
    HSEROUT["AT+CIPSERVER=1,80", 13, 10]
     HSERIN  [WAIT ("OK"), Dummy[0]]
    Serout2 PORTb.7,84,["run",13,10] 
 doop:     
   
     PORTc.1=0
    ' Here we need to wait for a client to connect and request data.
    ' When that happens the module will outout the HTTP header on the
    ' UART, we'll trig on the GET keyword.
    HSERIN[WAIT("+IPD"),str Dummy\6]    ;get ch number
    ch_z=dummy[1]
   
    HSERIN 100 , novar,[WAIT("MyInput="),str Dummy\5\10]   'parse input data if any
    Serout2 PORTb.7,84,[#dummy[0],",",#dummy[1],",",#dummy[2],13,10]
    myvar= (dummy[0]-$30)*100 + (dummy[1]-$30)*10 +(dummy[2]-$30)     ' the myvar input  field needs 3 chars  and leading 0's for padding  this could be better done
    if dummy[4]= "l"  then 
    led  =1
    else
    led=0
    endif
 novar:   
    Hits = Hits + 1                ' update web array
    ARRAYWRITE my_z,3,,[dec3 myvar]
    ARRAYWRITE hits_z,3,,[dec3 hits] 
    if led then 
      ARRAYWRITE chk_z,7,,["checked"]
    else
       ARRAYWRITE chk_z,7,,["       "]
     endif
     
     
    ' Prepare to send  bytes
    HSEROUT["AT+CIPSEND=0,",#(tmp+2), 13, 10]          
    HSERIN[WAIT (">"), Dummy[0]]
    ' Send the actual data
    HSEROUT[str head,str page ,13, 10]
  
      HSERIN[WAIT (" OK"), Dummy[0]]
    '
 
Goto doop