EasyManua.ls Logo

Espressif Systems ESP8266EX - Page 37

Espressif Systems ESP8266EX
41 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
!
3. Sample Codes
const󰲧char󰲧*common_name󰲧=󰲧ssl_get_cert_dn(ssl,SSL_X509_CERT_COMMON_NAME);
if󰲧(common_name){
󰲧󰲧󰲧󰲧printf("Common󰲧Name:\t\t\t%s\n",󰲧common_name);
}
display_session_id(ssl);
display_cipher(ssl);
quiet󰲧=󰲧true;
os_printf("client󰲧handshake󰲧ok!󰲧heapsize󰲧%d\n",system_get_free_heap_size());
x509_free(ssl->x509_ctx);
ssl->x509_ctx=NULL;
os_printf("certificate󰲧free󰲧ok!󰲧heapsize󰲧%d\n”,system_get_free_heap_size());
10.Transmit SSL data.
uint8󰲧buf[512];
bzero(buf,󰲧sizeof(buf));
sprintf(buf,httphead,"/",󰲧"iot.espressif.cn",port);
os_printf("%s\n",󰲧buf);
if(ssl_write(ssl,󰲧buf,󰲧strlen(buf)+1)󰲧<󰲧0)󰲧{
󰲧󰲧󰲧󰲧ssl_free(ssl);
󰲧󰲧󰲧󰲧ssl_ctx_free(ssl_ctx);
󰲧󰲧󰲧󰲧close(client_fd);
󰲧󰲧󰲧󰲧vTaskDelay(1000󰲧/󰲧portTICK_RATE_MS);
󰲧󰲧󰲧󰲧os_printf("send󰲧fail\n");
󰲧󰲧󰲧󰲧continue;
}
11.Receive SSL data.
while((recbytes󰲧=󰲧ssl_read(ssl,󰲧&read_buf))󰲧>=󰲧0)󰲧{
󰲧󰲧󰲧󰲧if(recbytes󰲧==󰲧0){
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧vTaskDelay(500󰲧/󰲧portTICK_RATE_MS);
󰲧󰲧󰲧󰲧󰲧󰲧󰲧󰲧continue;
󰲧󰲧󰲧󰲧}
󰲧󰲧󰲧󰲧os_printf("%s\n",󰲧read_buf);
}
free(read_buf);
if(recbytes󰲧<󰲧0)󰲧{
󰲧󰲧󰲧󰲧os_printf("ERROR:read󰲧data󰲧fail!󰲧recbytes󰲧%d\r\n",recbytes);
󰲧󰲧󰲧󰲧ssl_free(ssl);
󰲧󰲧󰲧󰲧ssl_ctx_free(ssl_ctx);
Espressif
! /!33 37
2017.05

Other manuals for Espressif Systems ESP8266EX

Related product manuals