phanvankhan
Joined: 01 Jun 2017 Posts: 1
|
HTTP client problem |
Posted: Thu Jun 01, 2017 9:10 am |
|
|
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
}
} |
|
|