Standard SDK: [RTL8195AM] SSL – Send simple HTTPS request by Ameba
- Ameba x 1
In this example, we use AT COMMAND to connect Ameba to WiFi, and send a simple HTTPS request to retrieve information from www.github.com.
- Modify the flag in SDK to enable SSL
In platform_opts.h ($ sdk \project\realtek_ameba1_va0_example\inc) modify the flag:
#define CONFIG_SSL_CLIENT 1to set CONFIG_SSL_CLIENT to 1。
- Move the SSL related files in project (for Ameba 8710/8711AF users) For users of 8710/8711, the SSL related files must be moved from SDRAM to SRAM. Open $ sdk \project\realtek_ameba1_va0_example\EWARM-RELEASE 下的 project.eww in IAR. In the workspace window, move the “polarssl” and “ssl_ram_map” folders from “SDRAM” to “Project-Debug”.
- Compile the project and download to Ameba Click “make” in the project directory, or click the “make” button at the top right of IAR IDE, to compile and download to Ameba.
- Send AT Command in UART console to establish SSL connection
First, use AT Command to connect Ameba to WiFi
- ATW0=SSID (SSID of the WiFi AP to connect)
- ATW1=PASSWARD (Password of the WiFi network. Skip this step if it’s an open network.)
- ATWC (Start WiFi connection)
#define CONFIG_EXAMPLE_WLAN_FAST_CONNECT 1Ameba preserves the WiFi connection information in flash memory, and will resume the preserved connection automatically after Ameba is reset. Next, use AT Command to connect to SSL server: ATWL=HOST_NAME Take www.github.com for example:
- net_connect returned -86 Please check if the WiFi network can connect to the Internet.
- net_connect returned -68 Please confirm if the server supports SSL connection.
- ssl_handshake returned -0x7200 This may be caused by the file size set by the server exceeds the default SSL_MAX_CONTENT_LEN 4096. You can try to modify this value in config_rsa.h ($ sdk\component\common\network\ssl\polarssl-1.3.8\include\polarssl), set the SSL_MAX_CONTENT_LEN to sufficient size (maximum value is 16384). For example, to connect to “www.baidu.com”, SSL_MAX_CONTENT_LEN needs to be larger than 4419.
- ssl_handshake returned -0x2880 This is due to SSL MALLOC failure, please try to modify the configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h ($ sdk\project\realtek_ameba1_va0_example\inc) to a larger value.