Updated on 2022-02-24 GMT+08:00

Command Processing Function for LiteOS SDK Device-Cloud Interconnect Components

All commands delivered by OceanConnect are executed by calling the atiny_cmd_ioctl() function.

Function

Description

int atiny_cmd_ioctl (atiny_cmd_e cmd, char* arg, int len);

Implemented by developers to declare and invoke device-cloud interconnect components. This API is a unified portal for LWM2M standard objects to deliver commands to devices. The parameters involved are as follows:

  • cmd, a specific command word, such as commands for delivering service data and resetting and upgrade.
  • arg, a specific command parameter; len, the parameter length.

    Return value: null

The atiny_cmd_ioctl API is a universal extensible API defined by device-cloud interconnect components. The command word of this API is defined by referring to the enumerated type atiny_cmd_e. Users can implement or extend this API based on respective requirements. The following table lists common APIs. Each API corresponds to an enumerated value of the atiny_cmd_e API.

Callback Function

Description

int atiny_get_manufacturer(char* manufacturer,int len)

Obtains the vendor name. The memory specified by the manufacturer parameter is allocated by device-cloud interconnect components. A user can specify the parameter. The parameter length cannot exceed the value of len.

int atiny_get_dev_type(char * dev_type,int len)

Obtains the device type. The memory specified by the dev_type parameter is allocated by device-cloud interconnect components. A user can specify the parameter. The parameter length cannot exceed the value of len.

int atiny_get_model_number((char * model_numer, int len)

Obtains the device model number. The memory specified by the model_number parameter is allocated by device-cloud interconnect components. A user can specify the parameter. The parameter length cannot exceed the value of len.

int atiny_get_serial_number(char* num,int len)

Obtains the device SN. The memory specified by the number parameter is allocated by device-cloud interconnect components. A user can specify the parameter. The parameter length cannot exceed the value of len.

int atiny_get_dev_err(int* arg,int len)

Obtains the device status, such as used-up memory, low battery, and low signal strength. The arg parameter is allocated by device-cloud interconnect components. A user can specify the parameter. The parameter length cannot exceed the value of len.

int atiny_do_dev_reboot(void)

Resets devices.

int atiny_do_factory_reset(void)

Resets vendors.

int atiny_get_baterry_level(int* voltage)

Obtains remaining battery level.

int atiny_get_memory_free(int* size)

Obtains available memory size.

int atiny_get_total_memory(int* size)

Obtains total memory size.

int atiny_get_signal_strength(int* singal_strength)

Obtains signal strength.

int atiny_get_cell_id(long* cell_id)

Obtains the cell ID.

int atiny_get_link_quality(int* quality)

Obtains the channel quality.

int atiny_write_app_write(void* user_data, int len)

Delivers service data.

int atiny_update_psk(char* psk_id, int len)

Updates PSKs.

A developer needs to make a command response by calling the atiny_write_app_write() function based on site services.

    int atiny_write_app_write(void* user_data, int len)
     {
         (void)atiny_printf("write num19 object success\r\n");
         return ATINY_OK;
     }