This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

LP-EM-CC2340R53: The beacon of the door lock cannot be viewed in the door lock log.

Part Number: LP-EM-CC2340R53
Other Parts Discussed in Thread: UNIFLASH, SYSCONFIG

Tool/software:

hi Ryan

According to the standard instance of the custom door lock, steps 1 to 3 were all carried out. However, I did not see the effect of step 4. I would like to see the request log, which includes the beacon of the lock. Please help me check which step went wrong. 

The coordinator used is an instance of onoff_light.

The instance code of the door lock is as follows: 

/****** Application variables declarations ******/
zb_uint16_t g_dst_addr;
zb_uint8_t g_addr_mode;
zb_uint8_t g_endpoint;
zb_bool_t perform_factory_reset = ZB_FALSE;

zb_bool_t cmd_in_progress = ZB_FALSE;

/****** Application function declarations ******/
/* Handler for specific ZCL commands */
zb_uint8_t zcl_specific_cluster_cmd_handler(zb_uint8_t param);
void test_device_interface_cb(zb_uint8_t param);
void send_toggle_req(zb_uint8_t param);
void button_press_handler(zb_uint8_t param);
void send_lock_req(zb_uint8_t param, zb_uint8_t lock_or_unlock);

/****** Cluster declarations ******/

// THIS CODE REPLACES IT
  /* Door Lock cluster attributes data */
zb_uint8_t g_attr_door_lock_lock_state = 0;
zb_uint8_t g_attr_door_lock_lock_type = 0;
zb_bool_t g_attr_door_lock_actuator_enabled = ZB_FALSE;
ZB_ZCL_DECLARE_DOOR_LOCK_ATTRIB_LIST(door_lock_attr_list, &g_attr_door_lock_lock_state,
                                      &g_attr_door_lock_lock_type, &g_attr_door_lock_actuator_enabled);

/* Basic cluster attributes */
zb_uint8_t g_attr_zcl_version  = ZB_ZCL_BASIC_ZCL_VERSION_DEFAULT_VALUE;
zb_uint8_t g_attr_power_source = ZB_ZCL_BASIC_POWER_SOURCE_DEFAULT_VALUE;

ZB_ZCL_DECLARE_BASIC_ATTRIB_LIST(basic_attr_list, &g_attr_zcl_version, &g_attr_power_source);

/* Identify cluster attributes */
zb_uint16_t g_attr_identify_time = ZB_ZCL_IDENTIFY_IDENTIFY_TIME_DEFAULT_VALUE;

ZB_ZCL_DECLARE_IDENTIFY_ATTRIB_LIST(identify_attr_list, &g_attr_identify_time);

/* Groups cluster attributes */
zb_uint8_t g_attr_name_support = 0;

ZB_ZCL_DECLARE_GROUPS_ATTRIB_LIST(groups_attr_list, &g_attr_name_support);

#ifdef ZB_ZCL_SUPPORT_CLUSTER_SCENES
/* Scenes cluster attributes */
zb_uint8_t g_attr_scenes_scene_count = ZB_ZCL_SCENES_SCENE_COUNT_DEFAULT_VALUE;
zb_uint8_t g_attr_scenes_current_scene = ZB_ZCL_SCENES_CURRENT_SCENE_DEFAULT_VALUE;
zb_uint16_t g_attr_scenes_current_group = ZB_ZCL_SCENES_CURRENT_GROUP_DEFAULT_VALUE;
zb_uint8_t g_attr_scenes_scene_valid = ZB_ZCL_SCENES_SCENE_VALID_DEFAULT_VALUE;
zb_uint16_t g_attr_scenes_name_support = ZB_ZCL_SCENES_NAME_SUPPORT_DEFAULT_VALUE;

ZB_ZCL_DECLARE_SCENES_ATTRIB_LIST(scenes_attr_list, &g_attr_scenes_scene_count,
    &g_attr_scenes_current_scene, &g_attr_scenes_current_group,
    &g_attr_scenes_scene_valid, &g_attr_scenes_name_support);
#else
zb_zcl_attr_t scenes_attr_list[] = { ZB_ZCL_NULL_ID, 0, 0, NULL };
#endif

/* Declare cluster list for the device */

ZB_HA_DECLARE_DOOR_LOCK_CLUSTER_LIST(door_lock_clusters, 
                                door_lock_attr_list, 
                                basic_attr_list, identify_attr_list, 
                                groups_attr_list, scenes_attr_list);
ZB_HA_DECLARE_DOOR_LOCK_EP(door_lock_ep, ZB_OUTPUT_ENDPOINT, door_lock_clusters);
ZB_HA_DECLARE_DOOR_LOCK_CTX(device_ctx, door_lock_ep);


static zb_bool_t error_ind_handler(zb_uint8_t severity,
                                   zb_ret_t error_code,
                                   void *additional_info);
                                   

/* test_device_interface_cb */

case ZB_ZCL_DOOR_LOCK_LOCK_DOOR_CB_ID:
    {
      zb_uint8_t lock_state = ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_LOCKED;
      uart2_printf("Lock the door");
      ZVUNUSED(zb_zcl_set_attr_val(ZB_OUTPUT_ENDPOINT,
                                  ZB_ZCL_CLUSTER_ID_DOOR_LOCK,
                                  ZB_ZCL_CLUSTER_SERVER_ROLE,
                                  ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID,
                                  &lock_state,
                                  ZB_FALSE));
      zb_osif_led_on(0);
    }
    break;
    case ZB_ZCL_DOOR_LOCK_UNLOCK_DOOR_CB_ID:
    {
      zb_uint8_t lock_state = ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_UNLOCKED;
      uart2_printf("Unlock the door");
      ZVUNUSED(zb_zcl_set_attr_val(ZB_OUTPUT_ENDPOINT,
                                  ZB_ZCL_CLUSTER_ID_DOOR_LOCK,
                                  ZB_ZCL_CLUSTER_SERVER_ROLE,
                                  ZB_ZCL_ATTR_DOOR_LOCK_LOCK_STATE_ID,
                                  &lock_state,
                                  ZB_FALSE));
      zb_osif_led_off(0);
    }
    break;
    
/* in button_press_handler add */

void button_press_handler(zb_uint8_t param)
{
  ZVUNUSED(param);
  uart2_printf("button is pressed, do nothing\r\n");
  if (!param)
  {
    /* Button is pressed, gets buffer for outgoing command */
    zb_buf_get_out_delayed(button_press_handler);
  }
  else
  {
    user_print("button_press_handler %d\r\n", param);
    // send_toggle_req(param);
    send_lock_req(param, ZB_ZCL_CMD_DOOR_LOCK_LOCK_ID);
#ifndef ZB_USE_BUTTONS
    /* Do not have buttons in simulator - just start periodic on/off sending */
    ZB_SCHEDULE_APP_ALARM(button_press_handler, 0, 7 * ZB_TIME_ONE_SECOND);
#endif
  }
}
    
/*send lock message*/
void send_lock_req(zb_uint8_t param, zb_uint8_t lock_or_unlock)
{
  zb_uint16_t addr = 0;

  ZB_ASSERT(param);

  if (ZB_JOINED() ) // && !cmd_in_progress
  {
    cmd_in_progress = ZB_TRUE;

    user_print("send_lock_req %d - sending %s command\r\n", param,
                "LOCK" );

    /* Send Door Lock command via binding (destination unknown) */ // ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_REQ
    ZB_ZCL_DOOR_LOCK_SEND_LOCK_DOOR_REQ(
      param,
      addr,
      ZB_APS_ADDR_MODE_DST_ADDR_ENDP_NOT_PRESENT,
      0,                       // no addr/endpoint needed because using binding
      ZB_SWITCH_ENDPOINT,      // source endpoint
      ZB_FALSE,                // no default response
      NULL);         // command: 0x00 = LOCK, 0x01 = UNLOCK
  }
  else
  {
    user_print("send_lock_req %d - not joined or busy\r\n", param);
    zb_buf_free(param);
  }
}
The following is the log of the request.
Best Regards, 
yongjian
  • Hi Yongjian,

    First, please make sure you are not using the UART2 code shared in your other E2E post, as the issues with this implementation must be addressed separately.

    It may help to erase all chip memory in Uniflash or CCS before re-programming the new firmware.

    Next, confirm that you are sniffing the same channel configured in your SysConfig file.  You should see a Beacon Request each time you run the firmware within the CCS debugger or otherwise reset the device (assuming a Zigbee network has not yet been joined).  Your Zigbee network ZC/ZC devices need to have permit join enabled before the device will be capable of joining.

    You should test with the default on_off light and switch projects to confirm you have a strong grasp on the joining process (end application should not affect this) before migrating your project to a new application.

    Regards,
    Ryan