Mesh controlling using Model classes

The application can send control requests using Model classes. The CSRMesh library provides various Model classes, and they can be acquired by calling the appropriate method on the MeshService class. Here is the list of Model classes available in the CSRMesh library:

  • ActuatorModelApi: Send requests to the device that are not awake 100% of the time
  • AttentionModelApi: Tell a device to get user attention
  • BearerModelApi: Enable or disable the relay functionality
  • ConfigModelApi: Acquire device configuration and remove associations
  • DataModelApi: Exchange manufacturer's data using ACK and UNACK packets
  • LightModelApi: Control and modify lighting information
  • GroupModelApi: Manage a mesh group
  • PowerModelApi: Manipulate or acquire a mesh device's power state
  • FirmwareModelApi: Perform firmware-related operations
  • PingModelApi: Ping the mesh network just like a network ping
  • SensorModelApi: Control and modify sensor information

You can use these classes in order to perform tasks on mesh devices. For example, if you want to get information about a device, you can use this:

ConfigModelApi.getInfo(mDeviceId, ConfigModelApi.DeviceInfo.VID_PID_VERSION);

Here, mDeviceId is the ID of the device you need to acquire information from. Similarly, if you want to obtain the firmware version of a particular device, you can write this:

FirmwareModelApi.getVersionInfo(mDeviceId);

An example of controlling a mesh device is to set the color of the light. You can call LightModelApi to set RGB colors of the light:

LightModelApi.setRgb(mDeviceId, red, green, blue, (byte)0xFF, 1, false);

The (byte)0xFF variable identifies the light level, 1 identifies the duration, and false describes whether the command is to be acknowledged or not.

By going through each Model class, you will be able to perform a range of functionalities over mesh devices. The goal of this chapter is to provide enough understanding of the API so that you can implement your own projects. I encourage you to explore the Model classes and implement a range of controls.   

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.64.128