Alink API¶
-
void
alink_set_loglevel
(enum ALINK_LOG_LEVEL loglevel)¶ Log level control
- Parameters
loglevel
: ALINK_LOG_LEVEL
-
int
alink_enable_sandbox_mode
(void)¶ Enable sandbox mode, for debug
- Return
- 0 on success, otherwise -1 will return
-
int
alink_enable_daily_mode
(const char * server_ip, int port)¶ Enable daily mode, for debug
- Return
- 0 on success, otherwise -1 will return
- Parameters
server_ip
: IP Addrport
: server port
-
int
alink_start
(void)¶ Entry function. start alink gateway service.
- Return
- 0 on success, otherwise -1 will return
-
int
alink_wait_connect
(int timeout_ms)¶ Waiting alink connect to aliyun server
- Return
- 0 when connect to server successfully, otherwise -1 will return
- Parameters
timeout_ms
: time in milliseconds, use ALINK_WAIT_FOREVER to wait until server is connected
-
int
alink_end
(void)¶ Destroy alink service and free resources
- Note
- this func will block at most 15 seconds to stop all alink related process(thread)
- Return
- 0 on success, otherwise -1 will return
-
int
alink_factory_reset
(void)¶ Reset user account binding.
- Return
- 0 on success, -1 when params invalid
-
int
alink_report
(const char * method, char * json_buffer)¶ Report alink message, it is a fundamental func.
- Note
- when connection with server is unstable, this func will block until got response from server or timeout.
- Return
- 0 when successfully got response from cloud, otherwise this func will block until timeout and -1 will return
- Parameters
method
: alink protocol method, i.e. “postDeviceRawData”, “retrieveDeviceData”.json_buffer
: json format buffer, like {“OnOff”:”1”, “Light”:”80”}.
-
int
alink_register_callback
(unsigned char cb_type, void * cb_func)¶ Register misc callback
- Return
- 0 on success, otherwise -1 will return
- Parameters
cb_type
: callback type.cb_func
: callback func pointer, func declaration see related comments.
-
int
awss_start
(void)¶ Start awss service, block method, block until awss succeed, or timeout(see Note).
- Note
- platform_awss_get_timeout_interval_ms() return monitor timeout interval, AP connection timeout is 30s.
- Return
- 0 on success, otherwise non-zero value will return = 0: connect AP & DHCP success = -1: get ssid & passwd fail = -2: connect AP / DHCP fail
-
int
awss_stop
(void)¶ Calling this func force awss_start exit.
- Return
- 0 on success, otherwise -1 will return