2014-03-18 12:08 PM
Hi,
I use LWIP and FreeRTOS like WEB server. It's OK. But now, I want send data to otger page for example by GET. Like this: http://www.page.com/p.php?json=1234 Can you help me please? Here is my code:
portCHAR PAGE_BODY[512];
struct
netconn *conn1 = NULL;
struct
ip_addr local_ip;
struct
ip_addr remote_ip;
int
rc1, rc2;
strcat
((
char
*) PAGE_BODY,
''HTTP/1.0 ''
);
strcat
((
char
*) PAGE_BODY,
''Method: POST\r\n''
);
strcat
((
char
*) PAGE_BODY,
''Server: Ethernet termostat\r\n''
);
strcat
((
char
*) PAGE_BODY,
''Content-Length: 9\r\n''
);
strcat
((
char
*) PAGE_BODY,
''json=1234\r\n\r\n''
);
strcat
((
char
*) PAGE_BODY,
''Content-type: application/x-www-form-urlencoded\n\n''
);
/* Create a new TCP connection handle */
conn1 = netconn_new(NETCONN_TCP);
if
(conn1!= NULL)
{
local_ip.addr = NULL;
rc1 = netconn_bind ( conn1, &local_ip, 0 );
IP4_ADDR(&remote_ip, 46, 28, 105, 62);
//remote_ip.addr = remote_ip; // static or by netconn_gethostbyname ()
rc2 = netconn_connect ( conn1, &remote_ip, 80 );
if
( rc1 != ERR_OK || rc2 != ERR_OK )
{
netconn_write(conn1, PAGE_BODY,
strlen
(PAGE_BODY), NETCONN_COPY);
netconn_delete ( conn1 );
}
}
else
{
printf
(
''can not create netconn''
);
}
#lmgtfy:-stm32-resources #send-data-frm-stm32-to-webserver
2014-03-19 12:40 AM
Do you need to specify a port somewhere?
Where?Should you expect a response from the Server? How?Should you be careful closing the connection?How?2014-03-20 08:24 AM
Hi, I want to implement LwIP stack to my discovery, but I couldn't find appropriate resources. Could you please upload your project or some resources that you have? Any guidance about this subject will be appreciated.
Best regards2014-03-20 08:43 AM
\STM32F4x7_ETH_LwIP_V1.1.0\Project\FreeRTOS\httpserver_netconn
http://www.st.com/web/en/catalog/tools/PF257906
If you have an STM32F4-DIS-BB break-out board with Ethernet, there is source specifically available from EmBest/Element14 for that.2014-03-31 03:53 AM
Hi, I've next problem. I need getting data from web server. I have one web page with JSON. When I put address of this page to web browser, I get data in JSON format.
Now I write script in PHP. I want get data from web page. When I show web page in web browser and then I read web page in my script, it's OK. But when I read data from web page in PHP script first, then page is not exist. But in web browser is OK still.Can you help me please?2014-03-31 08:11 AM
Now is OK. I change name of file from teploty.json to teploty.php and it's OK.
2014-11-09 01:38 PM
Hello I would like to make almost the same project as you. I would like to connect to my webserver with ''netconn_connect(conn, &remote_ip, 80 ); '' but nothing happened. I can not catch any packets with wireshark. If anybody can help or can send a web client example code I will be happy. Have stm32f4 discovery board with ethernet extension.
2014-11-09 04:11 PM
Not sure I've seen an HTTP GET example, how much socket experience do you come at this with?
STM32F4x7_ETH_LwIP_V1.0.0\Project\Standalone\tcp_echo_client\src\tcp_echoclient.c STM32F4DIS-BB Discover More Software Examples\STM32F4xx_Ethernet_Example\Project\Standalone\tcp_echo_client\src\tcp_echoclient.c2014-11-10 01:43 PM
I start the work with tcp echo client. It is working! Many thanks.
2016-07-24 11:28 PM
Hi,
I have also the same type requirement . I want to send the Data from microcontroller to a web page like :
http://www.xyzabc.com/getdata.php
and post_data on this URL at a regular interval.Thanks for Information.
Best Regards,
Sanjeev