Status Callback

Last Updated on : 2024-05-17 02:50:37download

This topic describes the status callbacks for beacon mesh devices, allowing you to implement status indication or other logic as needed.

Features

Notify the application layer of the status of the beacon mesh stack.

API description

Implement the following beacon mesh status callbacks at the application layer to monitor changes in device status.

void ty_beacon2_event_cb(ty_beacon2_event_e e, void *params){
    PR_DEBUG("EVENT:%d\n",e);
    switch(e){
        case BEACON2_EVENT_PAIR_OK:break;
        case BEACON2_EVENT_RESET:break;
        case BEACON2_EVENT_RECOVERY:;break;
        case BEACON2_EVENT_GROUP_ADD_SUCCESS:break;
        case BEACON2_EVENT_GROUP_ADD_ERR:break;
        case BEACON2_EVENT_GROUP_DEL_SUCCESS:break;
        default:break;
    }
}

Status includes:

  • Pairing succeeds.
  • The device is reset.
  • The device is restored to its previous state after an accidental reset.
  • The device is added to a group.
  • The device fails to be added to a group.
  • The group is deleted.
  • The device is bound with a remote.
  • The device is unbound from a remote.

In the callbacks for successful pairing, successful reset, or recovery from accidental reset, avoid initiating pairing to prevent a potential logic issue.

Support and help

If you have any problems with TuyaOS development, you can post your questions in the Tuya Developer Forum.