This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to use Power Config Cluster

Hello Nordic!

I want to control the battery level, and set alarms... I know that there is a cluster callled PowerConfig cluster and I have been reading it, but I acan't figure out how declare it.

I have the following code (it is written in Spanish, sorry):

typedef  struct contexto_alimentacion_s
{
    zb_uint8_t battery_voltage; // Atributo 3.3.2.2.3.1
    zb_uint8_t battery_size; // Atributo 3.3.2.2.4.2
    zb_uint8_t battery_quantity; // Atributo 3.3.2.2.4.4
    zb_uint8_t battery_rated_voltage; // Atributo 3.3.2.2.4.5
    zb_uint8_t battery_alarm_mask; // Atributo 3.3.2.2.4.6
    zb_uint8_t battery_voltage_min_threshold; // Atributo 3.3.2.2.4.7
} contexto_alimentacion_t;

static contexto_alimentacion_t contexto_alimentacion;

ZB_ZCL_DECLARE_POWER_CONFIG_ATTRIB_LIST(lista_atributos_alimentacion,
                                        &contexto_alimentacion.battery_voltage,
                                        &contexto_alimentacion.battery_size,
                                        &contexto_alimentacion.battery_quantity,
                                        &contexto_alimentacion.battery_rated_voltage,
                                        &contexto_alimentacion.battery_alarm_mask,
                                        &contexto_alimentacion.battery_voltage_min_threshold);

This is part of a bigger code which is using doorlock cluster too. Ithink that I have to use what is asked in this older post, am I right?

Anyway, can someone point me in the right direcction? Where can I find some examples of the Power Config cluster?

Thank you very much!

Parents
  • Hello all!

    I made some updates to the code, now it looks like this:

    typedef  struct contexto_alimentacion_s
    {
        zb_uint8_t battery_voltage; // Atributo 3.3.2.2.3.1
        zb_uint8_t battery_size; // Atributo 3.3.2.2.4.2
        zb_uint8_t battery_quantity; // Atributo 3.3.2.2.4.4
        zb_uint8_t battery_rated_voltage; // Atributo 3.3.2.2.4.5
        zb_uint8_t battery_alarm_mask; // Atributo 3.3.2.2.4.6
        zb_uint8_t battery_voltage_min_threshold; // Atributo 3.3.2.2.4.7
        zb_uint8_t battery_percentage_remaining; // Atributo 3.3.2.2.3.1
        zb_uint8_t battery_voltage_threshold_1; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_voltage_threshold_2; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_voltage_threshold_3; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_percentage_min_threshold; // Atributo 3.3.2.2.4.9
        zb_uint8_t battery_percentage_threshold_1; // Atributo 3.3.2.2.4.10
        zb_uint8_t battery_percentage_threshold_2; // Atributo 3.3.2.2.4.10
        zb_uint8_t battery_percentage_threshold_3; // Atributo 3.3.2.2.4.10
        zb_uint32_t battery_alarm_state; // Atributo 3.3.2.2.4.11
    } contexto_alimentacion_t;
    
    static contexto_alimentacion_t contexto_alimentacion;
    
    ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(lista_atributos_alimentacion,
                                                        &contexto_alimentacion.battery_voltage,
                                                        &contexto_alimentacion.battery_size,
                                                        &contexto_alimentacion.battery_quantity,
                                                        &contexto_alimentacion.battery_rated_voltage,
                                                        &contexto_alimentacion.battery_alarm_mask,
                                                        &contexto_alimentacion.battery_voltage_min_threshold,
                                                        &contexto_alimentacion.battery_percentage_remaining,
                                                        &contexto_alimentacion.battery_voltage_threshold_1,
                                                        &contexto_alimentacion.battery_voltage_threshold_2,
                                                        &contexto_alimentacion.battery_voltage_threshold_3,
                                                        &contexto_alimentacion.battery_percentage_min_threshold,
                                                        &contexto_alimentacion.battery_percentage_threshold_1,
                                                        &contexto_alimentacion.battery_percentage_threshold_2,
                                                        &contexto_alimentacion.battery_percentage_threshold_3,
                                                        &contexto_alimentacion.battery_alarm_state);

    The next step might be to declare and endpoint for this cluster, or should I use the doorlock cluster and set the power config cluster as a part of the required clusters? There is an older post where it is discussed.

Reply
  • Hello all!

    I made some updates to the code, now it looks like this:

    typedef  struct contexto_alimentacion_s
    {
        zb_uint8_t battery_voltage; // Atributo 3.3.2.2.3.1
        zb_uint8_t battery_size; // Atributo 3.3.2.2.4.2
        zb_uint8_t battery_quantity; // Atributo 3.3.2.2.4.4
        zb_uint8_t battery_rated_voltage; // Atributo 3.3.2.2.4.5
        zb_uint8_t battery_alarm_mask; // Atributo 3.3.2.2.4.6
        zb_uint8_t battery_voltage_min_threshold; // Atributo 3.3.2.2.4.7
        zb_uint8_t battery_percentage_remaining; // Atributo 3.3.2.2.3.1
        zb_uint8_t battery_voltage_threshold_1; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_voltage_threshold_2; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_voltage_threshold_3; // Atributo 3.3.2.2.4.8
        zb_uint8_t battery_percentage_min_threshold; // Atributo 3.3.2.2.4.9
        zb_uint8_t battery_percentage_threshold_1; // Atributo 3.3.2.2.4.10
        zb_uint8_t battery_percentage_threshold_2; // Atributo 3.3.2.2.4.10
        zb_uint8_t battery_percentage_threshold_3; // Atributo 3.3.2.2.4.10
        zb_uint32_t battery_alarm_state; // Atributo 3.3.2.2.4.11
    } contexto_alimentacion_t;
    
    static contexto_alimentacion_t contexto_alimentacion;
    
    ZB_ZCL_DECLARE_POWER_CONFIG_BATTERY_ATTRIB_LIST_EXT(lista_atributos_alimentacion,
                                                        &contexto_alimentacion.battery_voltage,
                                                        &contexto_alimentacion.battery_size,
                                                        &contexto_alimentacion.battery_quantity,
                                                        &contexto_alimentacion.battery_rated_voltage,
                                                        &contexto_alimentacion.battery_alarm_mask,
                                                        &contexto_alimentacion.battery_voltage_min_threshold,
                                                        &contexto_alimentacion.battery_percentage_remaining,
                                                        &contexto_alimentacion.battery_voltage_threshold_1,
                                                        &contexto_alimentacion.battery_voltage_threshold_2,
                                                        &contexto_alimentacion.battery_voltage_threshold_3,
                                                        &contexto_alimentacion.battery_percentage_min_threshold,
                                                        &contexto_alimentacion.battery_percentage_threshold_1,
                                                        &contexto_alimentacion.battery_percentage_threshold_2,
                                                        &contexto_alimentacion.battery_percentage_threshold_3,
                                                        &contexto_alimentacion.battery_alarm_state);

    The next step might be to declare and endpoint for this cluster, or should I use the doorlock cluster and set the power config cluster as a part of the required clusters? There is an older post where it is discussed.

Children
  • Hi,

    You can declare a set of endpoints on a node, so you should be able to declare an endpoint for the power configuration cluster.

    I'm afraid we don't have any examples of how this particular cluster can be implemented, but if you haven't already you should check out the Zigbee stack API overview page. There you can find information about how to implement a Zigbee end product with ZCL, such as declaring attributes, clusters, cluster lists, and endpoints, as well as registering device context.

    Best regards,

    Marte

  • Hello Marte! Thanks for your fast response!

    My main question regards the declaration of a new endpoint. Should I create a new endpoint for each cluster or can I use the same endpoint for the doorlock cluster and the power config one? What is the better way to do it? I would have to modify some lines from de zb_zcl_door_lock.h to integrate the power config into the doorlock cluster, right?.

    If I wanted to declare another endpoint for the power config cluster, do I need to modify the zb_zcl_power_config.h? Adding declarations for endpoint and context as it is done with the doorlock cluster.

  • Hi,

    No, you don't have to create a new endpoint for each cluster, you can add the clusters to your existing endpoint. Whether you want to have multiple endpoints or not depends on what you want, and how you want your application to work. In this case I believe having one endpoint would be best. And yes, you should add the power config cluster to the door lock cluster list if you want to add the power config cluster to the existing endpoint.

    Best regards,

    Marte

Related