EasyLink SDK for iOS
1. The main features of the EasyLink SDK
♦ Send Wi-Fi network parameters set on the mobile terminal to the device side
* Support EasyLink mode * Support Soft AP mode * Support packet encryption
♦ Go to new networked devices and interact. Implement parameter settings, OTA and other functions
Note that EasyLink mode only supports operations on IPv4 networks.
2. API usage
EasyLink’s usage flow is: Initialize EasyLink instance → Set configuration parameters → Start sending distribution network information
→ Wait for new device discovery callback → Stop sending distribution network information → If you do not need to configure again, destroy EasyLink instance.
Initialize the EasyLink instance
@brief Initializes the EasyLink configuration instance
@param enable: Whether to output debugging information
@param delegate: Provides an instance of the function back
@return EasyLink instance.
– (id)initForDebug:(BOOL)enable WithDelegate:(id)delegate;
Set configuration parameters
/** @brief Set distribution parameters
@param wlanConfigDict: Network configuration information dictionary, where the dictionary’s Key refers to the content reference wlanConfig key
@param userInfo: The custom information that the device can receive in the EasyLink distribution network.
If not, set it to nil.
@param easyLinkMode: Set to EASYLINK_V2_PLUS or EASYLINK_AWS to match the distribution method used in the device
@param key: The transmitted EasyLink message can be encrypted using RC4. The key is the encrypted password.
The device also needs to provide this password when the EasyLink distribution network is enabled.
@return none. */ – (void)prepareEasyLink:(NSDictionary *)wlanConfigDict info:(NSData *)userInfo mode:(EasyLinkMode)easyLinkMode encrypt:(NSData *)key;
EasyLink distribution mode: easyLinkMode
⊗ 특별한 경우가 아니면 Easylink 모드로 EASYLINK_AWS 를 선택한다.
EASYLINK_V1 = 0, /**< no longer used */
EASYLINK_V2, /**< Multicast Distribution Network */
EASYLINK_PLUS, /**<broadcast distribution network */
EASYLINK_V2_PLUS, /**< Multicast + Broadcast Distribution Network */
EASYLINK_AWS, /**< The latest broadcast distribution network, providing the best compatibility in one-click distribution network */
EASYLINK_SOFT_AP, /**< Connect to the hotspot opened by the module for distribution network */
wlanConfig dictionary content
#define KEY_SSID @”SSID” //value type: NSData, the name of the wireless network, must be obtained using the + (NSData *) ssidDataForConnectedNetwork
method, otherwise the wireless network containing Chinese characters cannot be properly configured.
#define KEY_PASSWORD @”PASSWORD” //value type: NSString or NSData, wireless network password
#define KEY_DHCP @”DHCP” //value type: NSNumber(bool), whether the device automatically obtains
an IP address (DHCP is enabled), @YES or @NO, EASYLINK_AWS distribution network must use @YES
#define KEY_IP @”IP” //value type: NSString, IP address, if DHCP is enabled, you can leave it blank, EASYLINK_AWS distribution network does not support
#define KEY_NETMASK @”NETMASK” //value type: NSString, subnet mask, if DHCP is enabled, you can leave it blank, EASYLINK_AWS distribution network does not support
#define KEY_GATEWAY @”GATEWAY” //value type: NSString, gateway, if DHCP is enabled, you can leave it blank, EASYLINK_AWS distribution network does not support
#define KEY_DNS1 @”DNS1″ //value type: NSString, DNS server 1, if DHCP is enabled, you can leave it blank, EASYLINK_AWS distribution network does not support
#define KEY_DNS2 @”DNS2″ //value type: NSString, DNS server 2, if DHCP is enabled, you can leave it blank, EASYLINK_AWS distribution network does not support
Start sending distribution network information
Callback waiting for new device discovery If the device is connected to the target network, the SDK can generate a callback.
EASYLINK AWS mode uses UDP broadcast implementation, and the rest of the distribution network uses mDNS. The service name is _easylink_config._tcp.
The specific implementation method has been implemented in the SDK, the application does not need to care
/** @brief new device discovery callback
@param client: client number (can be ignored)
@param name: device name, which is the instance name provided by the device in the mDNS service.
@param mataDataDict: Metadata, even if the device provides the TXT Record in the mDNS service, or the JSON data provided in the UDP broadcast.
@return none. */ – (void)onFound:(NSNumber *)client withName:(NSString *)name mataData: (NSDictionary *)mataDataDict;
The onFoundByFTC callback is also triggered if the Config Server feature is enabled on the device.
/** @brief new device discovery callback
@param client: client number
@param name: configDict, configuration information provided by the device in the Config Server function
@return none. */ – (void)onFoundByFTC:(NSNumber *)client withConfiguration: (NSDictionary *)configDict;
If the onFoundByFTC callback is triggered, you can use the – (void)configFTCClient:(NSNumber *)client withConfiguration: (NSDictionary *)configDict;
method to set the device parameters. But this feature also works with the Config Server feature on the device.
Stop sending distribution network information If you think that the distribution network has been completed, you can stop sending distribution network information.
Destroy the EasyLink instance if you do not need to configure it again Use this method to completely remove the resources occupied by the easylink example.
3. Call Back 문제 해결
Bonjour services를 추가 한다. 아래 그림을 참조.