How can I use "espconn_sent"
Posted: Fri Jan 23, 2015 12:34 pm
How can I use "espconn_sent" function in function directly? (094 or 095 sdk) or can i send data to server directly?
i am using this code in freertos and working good. but freertos sdk dont have ota upgrade. thats why i am asking
i am using this code in freertos and working good. but freertos sdk dont have ota upgrade. thats why i am asking
Code: Select all
void sendData(void *pvParameters)
{
printf("starting");
int recbytes;
int sin_size;
int str_len;
int sta_socket;
struct sockaddr_in local_ip;
struct sockaddr_in remote_ip;
sta_socket = socket(PF_INET, SOCK_STREAM, 0);
if (-1 == sta_socket) {
close(sta_socket);
printf("C > socket fail!\n");
}
printf("C > socket ok!\n");
bzero(&remote_ip, sizeof(struct sockaddr_in));
remote_ip.sin_family = AF_INET;
remote_ip.sin_addr.s_addr = inet_addr(server_ip);
remote_ip.sin_port = htons(server_port);
if (0 != connect(sta_socket, (struct sockaddr *)(&remote_ip), sizeof(struct sockaddr))) {
close(sta_socket);
printf("C > connect fail!\n");
}
printf("C > connect ok!\n");
char *pbuf = (char *)zalloc(1024);
sprintf(pbuf, "%s\n", "client_send info");
if (write(sta_socket, pbuf, strlen(pbuf) + 1) < 0) {
printf("C > send fail\n");
}
printf("C > send success\n");
close(sta_socket);
free(pbuf);
vTaskDelete(NULL);
}