CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

HTTP client problem

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
phanvankhan



Joined: 01 Jun 2017
Posts: 1

View user's profile Send private message

HTTP client problem
PostPosted: Thu Jun 01, 2017 9:10 am     Reply with quote

I'm using PIC18F97J60 with internal ethernet. I use my device as a client, it has the function of updating the sensor data and sending it to a server. I have been successful in sending data to the server. The server got the data and displayed it on the screen. The problem I encountered was that I could not change the data submitted. I can only send the initial default value when creating the project.
This is my entire main program.
Looking forward to receiving the help of all of you.
Thank you very much!
Code:
#include <main.h>

int1 g_MyHttpSending = FALSE;

/* The CCS HTTP Client library is very flexible in the manners of which
data can be sent to the remote HTTP server an how to read response
data from the remote HTTP server. See the ccs_http_client.h file for
a full documentation of this API. */
void MyHttpSend(void)
{
   // there are also non-ROM versions of these functions if you want to
   // dynamically control the parameters.
   HttpClientSetHostNameROM((rom char*)"192.168.100.2");
   HttpClientSetUrlROM((rom char*)"dulieumau/db.php");
   HttpClientSetHostPort(80);
   static char cgi[64];
   cgi[0] = 0;
   HttpClientAppendCgiROM(cgi, (rom char*)"temperature", (char*)"5",sizeof(cgi));
   HttpClientSetCgiGet(cgi);

   HttpClientStart();
}

void IPAddressInit(void)
{
   //MAC address of this unit
   MY_MAC_BYTE1=MY_DEFAULT_MAC_BYTE1;
   MY_MAC_BYTE2=MY_DEFAULT_MAC_BYTE2;
   MY_MAC_BYTE3=MY_DEFAULT_MAC_BYTE3;
   MY_MAC_BYTE4=MY_DEFAULT_MAC_BYTE4;
   MY_MAC_BYTE5=MY_DEFAULT_MAC_BYTE5;
   MY_MAC_BYTE6=MY_DEFAULT_MAC_BYTE6;

   //IP address of this unit
   MY_IP_BYTE1=MY_DEFAULT_IP_ADDR_BYTE1;
   MY_IP_BYTE2=MY_DEFAULT_IP_ADDR_BYTE2;
   MY_IP_BYTE3=MY_DEFAULT_IP_ADDR_BYTE3;
   MY_IP_BYTE4=MY_DEFAULT_IP_ADDR_BYTE4;

   //network gateway
   MY_GATE_BYTE1=MY_DEFAULT_GATE_BYTE1;
   MY_GATE_BYTE2=MY_DEFAULT_GATE_BYTE2;
   MY_GATE_BYTE3=MY_DEFAULT_GATE_BYTE3;
   MY_GATE_BYTE4=MY_DEFAULT_GATE_BYTE4;

   //subnet mask
   MY_MASK_BYTE1=MY_DEFAULT_MASK_BYTE1;
   MY_MASK_BYTE2=MY_DEFAULT_MASK_BYTE2;
   MY_MASK_BYTE3=MY_DEFAULT_MASK_BYTE3;
   MY_MASK_BYTE4=MY_DEFAULT_MASK_BYTE4;
}

void main()
{

   IPAddressInit();
   TickInit();
   enable_interrupts(GLOBAL);
   StackInit();


   while(TRUE)
   {

      // TCP/IP code
      StackTask();
      StackApplications();
     
      g_MyHttpSending = TRUE;
      HttpClientSetHostNameROM((rom char*)"192.168.100.2");
      HttpClientSetUrlROM((rom char*)"dulieumau/db.php");
      HttpClientSetHostPort(80);
      static char cgi[64];
      cgi[0] = 0;
      HttpClientAppendCgiROM(cgi, (rom char*)"temprature", (char*)"11",sizeof(cgi));
      HttpClientSetCgiGet(cgi);

      HttpClientStart();
      g_MyHttpSending = FALSE;

      //Example blinking LED program
      output_low(LED);
      delay_ms(DELAY);
      output_high(LED);
      delay_ms(DELAY);
      //TODO: User Code
   }

}
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group