A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By alonewolfx2
#3032 its my code. i tried sockettest3 on windows and wamp server on windows.

Code: Select allvoid hardcoded_connect()
{//os_timer_arm(&connection_timer_elapsed, 10000, 1);
   os_timer_disarm(&auto_setup);

   //Setup timer
   os_timer_setfn(&auto_setup, (os_timer_func_t *)auto_setup_elapsed, NULL);

   //Set up the timer, (timer, milliseconds, 1=cycle 0=once)
   os_timer_arm(&auto_setup, 2000, 0);
   
   
   

}

void auto_setup_elapsed()
{

   char temp[128];
 
   os_sprintf(temp,"=\"TCP\",\"192.168.2.69/new_value.php?\",80");
   at_setupCmdCipStartLog(19,temp);
}
void polling_timer_elapsed(void *arg)
{
      char temp[128];
   
   //check if input is active (0), increment time
   /*if(!GPIO_INPUT_GET(2))   
      GPIO_time_active++;
   //the input is inactive, do we have a measurement to send?
   else
      //yep there is something to send
      if(GPIO_time_active!=0)
      {*/
         //Connect
         strcpy(temp, logger_CISTART_args);
         at_setupCmdCipstart(12,temp);   
         
         //set time to life (max connect tries)
         connection_TTL=TTL_INIT;
         
         //check if connection was successful with the help of a timer
         //Disarm timer
         os_timer_disarm(&connection_timer);

         //Setup timer
         os_timer_setfn(&connection_timer, (os_timer_func_t *)connection_timer_elapsed, NULL);

         //Set up the timer, (timer, milliseconds, 1=cycle 0=once)
         os_timer_arm(&connection_timer, CONNECTION_DELAY_MS, 1);   
         
         //safe data
         //captured_time=GPIO_time_active;
         //GPIO_time_active=0;
      //}
}
void ICACHE_FLASH_ATTR
at_setupCmdCipStartLog(uint8_t id, char *pPara)
{
   char temp[128];
   int8_t len,i;
   char *pParatemp=pPara;
   char temp_protocol[3];
   

   //get station mode
   if(wifi_get_opmode()!=2)
   {
      pParatemp++;
   
      //check if MUX is 1 to set up the connection ID
      if(isIPMUX())
      {
         //check if conID seem to be ok
         if(isdigit(pParatemp[0]))
         {
            //char to int         
            logger_con_id=pParatemp[0]- '0';
            pParatemp+=2;
         }
         else
         {
            uart0_sendStr("Connection ID missing, add one or set CIPMUX to 0");
            return;
         }
      }
      else
      {
         //check if there is no conID is ok
         if(pParatemp[0]=='"')
            logger_con_id=0;
         else
         {
            uart0_sendStr("there seems to be something wrong with the parameters");

            return;
         }
      }      

      //parse protocol
      len = at_dataStrCpy(temp_protocol, pParatemp, 4);      
      if(len == -1)
      {
         uart0_sendStr("Protocol ERROR\r\n");
         return;
      }
      pParatemp+=len+3;
      
      //parse URL
      len = at_dataStrCpy(logger_script_path, pParatemp, 127);
      if(len == -1)
      {
         uart0_sendStr("URL ERROR\r\n");
         return;
      }
      pParatemp+=len+3;
      
      //separate Host and Path
      for(i=0;i<MAX_PATH_LENGTH-1;i++)
      {
         if(logger_script_path[i]!='/')
            logger_target_host[i]=logger_script_path[i];
         else
         {

            //end of host, now we go for the path, needs do be made better
            logger_target_host[i] = '\0';
            for(len=i;i<MAX_PATH_LENGTH-1;i++)
               if(logger_script_path[i]!='"')
                  logger_script_path[i-len]=logger_script_path[i];
               else            
                  logger_script_path[i-len]= '\0';                           

            break;
         }

      }
         
      //ok now we need to get the other parameters for at_setupCmdCipstart aka AT+CIPSTART
      if(isIPMUX())
         os_sprintf(logger_CISTART_args,"=%d,\"%s\",\"%s\",%s",logger_con_id,temp_protocol,logger_target_host,pParatemp);
      else
         os_sprintf(logger_CISTART_args,"=\"%s\",\"%s\",%s",temp_protocol,logger_target_host,pParatemp);

      //TODO: get the GPIO pin number as parameter   
      
      //set gpio2 as gpio pin
      //PIN_FUNC_SELECT(PERIPHS_IO_MUX_GPIO2_U, FUNC_GPIO2);
    
      //disable pulldown
      //PIN_PULLDWN_DIS(PERIPHS_IO_MUX_GPIO2_U);
    
      //enable pull up R
      //PIN_PULLUP_EN(PERIPHS_IO_MUX_GPIO2_U); 
    
      //TODO: make this interrupt based

      //Disarm timer
      os_timer_disarm(&polling_timer);

      //Setup timer
      os_timer_setfn(&polling_timer, (os_timer_func_t *)polling_timer_elapsed, NULL);

      //Set up the timer, (timer, milliseconds, 1=cycle 0=once)
      os_timer_arm(&polling_timer, 10000, 1);

      uart0_sendStr("Done setting up the Logger at GPIO2\r\n");
      
#ifdef DEBUG
      uart0_sendStr("CIPStart args: \r\n");
      uart0_sendStr(logger_CISTART_args);
      
      uart0_sendStr("Path to the script \r\n");
      uart0_sendStr(logger_script_path);
      
      os_sprintf(temp,"\r\nConnection ID %d \r\n",logger_con_id);
      uart0_sendStr(temp);
#endif
      at_backOk;
   }
   else
   {
      uart0_sendStr("Cant set up logger in AP mode\r\n");
      at_backError;
   }
}

User avatar
By picpic020960
#3083 Bonjour ,

i have compiled this project with this link/topic (virtualbox for win 7 with ubuntu as guest )

http://www.esp8266.com/viewtopic.php?f=9&t=430

but two '.bin' have not the same size that on the '.zip'

as I have not found how to do a backup of the actual firmware , I fear.

can you confirm that the source with my compilation link is OK ?

thanks

chip : esp-01