UM0094 Realtek Ameba 1 Alink User Guide
User Manual:
Open the PDF directly: View PDF .
Page Count: 17
Download | |
Open PDF In Browser | View PDF |
Realtek Ameba-1 Alink user guide The document describes how to porting Alink into Ameba SDK and demonstrates how to use Alibaba ONEAPK to make Ameba connect to Ali Cloud and how to update new firmware over the air. _______________________________________________________________ Table of Contents 1 2 3 Introduction .................................................................................................................................. 3 Porting Alink patch ....................................................................................................................... 4 2.1 Add files to SDK folder ........................................................................................................... 4 2.2 Add files to IAR project .......................................................................................................... 5 2.3 Other Configuration ............................................................................................................... 5 2.3.1 platform_opts.h .............................................................................................................. 5 2.3.2 alink.c ............................................................................................................................... 6 2.3.3 example_entry.c ............................................................................................................. 6 2.3.4 lwipopts.h ........................................................................................................................ 6 2.3.5 config_rsa.h ..................................................................................................................... 6 2.3.6 FreeRTOSConfig.h ........................................................................................................... 6 2.3.7 image2.icf ........................................................................................................................ 7 Access Ali Cloud Example(Android) ............................................................................................. 7 3.1 One key configuration ........................................................................................................... 7 3.2 4 Soft AP configuration ...........................................................................................................11 OTA ..............................................................................................................................................15 June 14, 2016 2 _______________________________________________________________ 1 Introduction Ali Cloud provides an open security-rich and reliable cloud services for traditional hardware businesses and aspiring provide development platform for those interested in the development of the IOT enthusiasts. Internet based services include, but are not limited to: one-stop access to services, data analysis services, after-sales service support, firmware upgrade service (OTA) and equipment sharing services. Alink is used to help the smart device to connect to the target AP and register to Ali cloud. It provides two ways to configure Wi-Fi for the smart device: One-key configuration and Soft AP configuration. One-key configuration: A smart device will enter One-key configuration as default. It adjusts channels from 1 to 13 circularly to receive and analysis configuration packets sent from the mobile ONEAPK in promiscuous mode. By doing this for a short moment, the smart device can lock to the exact channel and get enough information of the target AP. After getting the target AP profile, it will try to link with the AP automatically. Soft AP configuration: If the smart device does not get the target AP profile after one minute using One-key configuration, it will switch to Soft AP configuration. Firstly, the smart device will enter Soft AP mode, broadcast itself with the SSID “alink_*” and create a TCP server waiting client in. Secondly, ONEAPK in smart phone will make its Wi-Fi link with the Soft AP and connect to the TCP server as a client. Thirdly, the smart phone transfers the profile of the target AP which has internet access to the smart device through the TCP connection. Fourthly, the smart device switches to STA mode and try to link with the target AP. At last, the smart device will send broadcast UDP to declare successful connection and the smart phone will acknowledge a unicast UDP to declare the configuration is successful. Alibaba provides a test APK named ONEAPK to help the developers to verify Alink configuration and Ali cloud service for smart devices. The ONEAPK logo is like and you can get it by scanning the two-dimensional code shown as follows. The download URL is https://open.alink.aliyun.com/download/ . June 14, 2016 3 _______________________________________________________________ The table below shows some keywords and their descriptions in this document. Keyword Description UUID A UUID identifies a unique type of products. Each device will obtain a unique UUID from Ali cloud during registration process. Key/Secret Used for identity authentication. It is produced by Alibaba when one type of device registers to Ali IOT platform. The combination of “UUID and Key/Secret can identify a unique smart device. Different devices of the same type must have different UUID. To know more details about Ali Cloud service and to configure more function options, you can login Alibaba Smart living official website: https://open.alink.aliyun.com/. 2 Porting Alink patch 2.1 Add files to SDK folder Step 1:Extract Ameba released SDK, eg. sdk-ameba1-v3.4b3. Step 2:Create “alink” folder in $sdk\component\common\application\. Step 3:Copy “alink.c”、 “alink_export.h”、 “alink_export_rawdata.h”、 “aws_lib.h”、 “aws_platform.h”、 “platform_porting.h”、 and “lib_alink.a” from 3.4b_patch_alink_v1.1_(v01).zip to $sdk\component\common\application\alink June 14, 2016 4 _______________________________________________________________ Step 4:Copy “device_lock.h” from 3.4b_patch_alink_v1.1_(v01).zip to $sdk\component\os\os_dep\include\.(remarks:only fo sdk_v3.4) Step 5:Copy “device_lock.c” from 3.4b_patch_alink_v1.1_(v01).zip to $sdk\component\os\os_dep. (remarks:only fo sdk_v3.4) Step6:Replace "dhcp" folder which located at $sdk\component\common\network\. (remarks: only fo sdk_v3.4) 2.2 Add files to IAR project Step 1: Open IAR project and add a new group “alink”. Step 2: Add alink.c and lib_alink.a into alink group. Step 3: Add device_lock.c into osdep group. 2.3 Other Configuration 2.3.1 platform_opts.h The file location is $sdk\ project\realtek_ameba1_va0_example\inc\platform_opts.h. Please add CONFIG_ALINK define as follows. #define CONFIG_ALINK 1 June 14, 2016 5 _______________________________________________________________ 2.3.2 alink.c The file location is $sdk\component\common\application\alink.c. You can add PASS_THROUGH define as follows. #define PASS_THROUGH PASS_THROUGH is defined only when using a iPhone, if defined, pass through mode will be enabled or JSON message mode will be enabled. Please mark it as default. 2.3.3 example_entry.c The file location is $sdk\component\common\example\example_entry.c. You can add alink entry here if needed. void example_entry(void) { …… #if CONFIG_ALINK example_alink(); #endif …… } 2.3.4 lwipopts.h The file location is $sdk\ component\common\api\network\include\lwipopts.h. If the following define does not exist, please add it, otherwise just change to 1. #define LWIP_IGMP 1 #define LWIP_TCP_KEEPALIVE 1 2.3.5 config_rsa.h The file location is $sdk\component\common\network\ssl\polarssl1.3.8\include\polarssl\config_rsa.h. Please mark the following defines in order to ensure the establishment of SSL connection with Ali cloud. //#define POLARSSL_SSL_PROTO_SSL3 //#define POLARSSL_SSL_PROTO_TLS1 //#define POLARSSL_SSL_PROTO_TLS1_1 2.3.6 FreeRTOSConfig.h The file location is $sdk\project\realtek_ameba1_va0_example\inc\FreeRTOSConfig.h. Change configTOTAL_HEAP_SIZE from 60K to 70K because Alink need more heap. #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 70 * 1024 ) ). June 14, 2016 6 _______________________________________________________________ 2.3.7 image2.icf The file location is $sdk\ project\realtek_ameba1_va0_example\EWARM-RELEASE\image2.icf. Please notice that alink 、acloud and alinkporting code should only be placed at SDRAM now since SRAM is not enough to run acloud. Please add section “.alink.text”、“.acloud.text” and “.alinkporting.text” to SDRAM block as follows. 3 Access Ali Cloud Example(Android) Please download ONEAPP and install to your smart phone at first. The download link is http://open.alink.aliyun.com/download/. Then click APP to find setting entry: Setting =>About=> Environment configure After configuring environment, close APP and kill the process. 3.1 One key configuration Now we will step by step demonstration One-key configuration. Step 1: Power on your smart device (ameba development board). It will enter one key configuration as default if no saved AP profile in the flash. June 14, 2016 7 _______________________________________________________________ Step 2:Make sure that WiFi device on your phone has connected to a target AP with internet access. Step 3:Open ONEAPK, Add Device=> Search by category => Device classes, find the entry of One key configure network. Then click “next step” button to enter configure AP interface: June 14, 2016 8 _______________________________________________________________ Input the right passphrase of the target AP: Click “search for devices” button to start configuration: June 14, 2016 9 _______________________________________________________________ Step 4:After a few seconds, ameba will get the target AP’s profile and connect to the target AP. After link built and IP address gotten, ameba and smart phone will exchange UDPs to discover each other and complete binding process. Then ameba will register to Ali cloud. June 14, 2016 10 _______________________________________________________________ Step 5:If the smart device registers to smart cloud successfully, the smart phone ONEAPK will automatically jump to the following page, then you can control your smart device now. 3.2 Soft AP configuration Step 1:Power on your smart device (ameba development board).After about one minute, it will leave One-key configuration mode and enter Soft AP configuration mode which means the smart device will enter Soft AP mode, broadcast itself with the SSID “alink_*” and create a TCP server waiting TCP client in. Step 2:Make sure that WiFi device on your phone has connected to a target AP with internet access. June 14, 2016 11 _______________________________________________________________ Step 3:Open ONEAPK, Add Device=> Search by category => Device classes, find the entry of Soft AP configure network. Click “confirm the device into the SoftAP configure network state” button to enter configure AP interface. Input the right passphrase for the target AP. June 14, 2016 12 _______________________________________________________________ Click “search for devices” button to start configuration. After doing this, ONEAPK will make its Wi-Fi link with the Soft AP and connect to the TCP server as a TCP client. Then the smart phone will transfer the target AP’s profile to the smart device through the TCP connection. June 14, 2016 13 _______________________________________________________________ Step 4: The smart device switches to STA mode and try to link with the target AP. After link built and IP address got, the smart device will send broadcast UDP to declare successful connection and the smart phone will acknowledge a unicast UDP to declare the configuration is successful. Then the smart device will register to Ali cloud. Step 5:If the smart device registers to smart cloud successfully, the smart phone ONEAPK will automatically jump to the following page, then you can control your smart device now. June 14, 2016 14 _______________________________________________________________ 4 OTA Over The Air function is achieved to upgrade the new firmware. Here goes an example of OTA test. Assume that the current assigned version number running in the smart device is "1.0.3" which can be modified in alink.c file. And a new firmware “ota.bin” with a higher assigned version number "1.1" is placed in Ali cloud which you can view from ONEAPK->Setting-> Device management -> Current device. Step 1: Click " firmware upgrade " to jump to the following upgrade page. June 14, 2016 15 _______________________________________________________________ Step 2:Click " upgrade now" to start to download the new firmware. As device’s serial log shows, it begins to download firmware. In ONEAPK, it will show the download percentage like this: June 14, 2016 16 _______________________________________________________________ Step 3:After download completed, the device will automatically reboot. The device’s serial log shows as follows. In ONEAPP, when the progress bar reaches 100%, click "confirm" to finish upgrading firmware. Then it will jump to the following page, it shows “Your smart device’s firmware is the newest”. June 14, 2016 17
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.5 Linearized : No Page Count : 17 Language : zh-TW Tagged PDF : Yes Producer : Microsoft® Word 2010 Creator : Microsoft® Word 2010 Create Date : 2016:06:14 09:39:17+08:00 Modify Date : 2016:06:14 09:39:17+08:00EXIF Metadata provided by EXIF.tools