cancel
Showing results for 
Search instead for 
Did you mean: 

I'm trying to implement custom callbacks on the STM32WB Zigbee library. Any examples of custom callbacks on a report or certain attributes?

MCope.1
Associate II

My goal is to have a coordinator connected to sleepy end devices. The coordinator will periodically request measurements from the end devices. It seems like all the examples have requests going from the nodes to the coordinator, so I'm having trouble reversing it for my implementation.

Right now I'm using the Zigbee_PressMeas application example from STM32Cube_FW_WB_V1.6.0 as a base. I want a custom callback on the client when the server issues a request, which will cause the client to take a measurement and respond.

This is my client code in app_zigbee.c from APP_ZIGBEE_ConfigEndpoints(void:(

// Cluster Setup
  zigbee_app_info.press_meas_client = ZbZclPressMeasServerAlloc(zigbee_app_info.zb, SW1_ENDPOINT, ZCL_PRESSURE_MIN, ZCL_PRESSURE_MAX);
  assert(zigbee_app_info.press_meas_client != NULL);
  zigbee_app_info.press_meas_client->report = &zcl_press_meas_press_client_report;
 
  // Find the Attribute Object
  struct ZbZclAttrListEntryT pressure_attribute_entry;
  struct ZbZclAttrT pressure_attribute;
  pressure_attribute_entry = *(ZbZclAttrFind(zigbee_app_info.press_meas_client, ZCL_PRESS_MEAS_ATTR_MEAS_VAL));
  pressure_attribute = *(pressure_attribute_entry.info);
  // Print to verify the Attribute
  printf("\r\nPressure_Attr ID Number: %d\r\n", pressure_attribute.attributeId);
 
  // Assign a callback function
  pressure_attribute.callback = &APP_ZIGBEE_custom_pressure_read_cb;
 
  // Register the Cluster
  ZbZclClusterEndpointRegister(zigbee_app_info.press_meas_client);

I think it's ignoring my custom callback and simply using the default request handler.

Thanks!

4 REPLIES 4
MCope.1
Associate II

It looks like I didn't have my attribute flags set to enable read requests. I got my code to work after adding custom attributes on the client side. Set the client attribute read flag and callback address. Then call a ReadReq() from the server.

MTorr.3
Associate II

Since I can't seem to post new topics to create my own question I will hijack your thread, sorry about that = )

I have acquired a P-NUCLEO-STM32WB55 board and am trying to develop a sensor+actuator network with it.

The sensor+actuator part is done and I would now like to connect the end-node to a coordinator to send and receive messages.

From what I gathered I can use Zigbee or OpenThread, for range reasons (>50m). However the examples are specific to EWARM or KEIL platforms. Can you point me to some examples for the provided STM32CubeIDE, some way to import those projects or another approach altogether?

Examples on how to create basic network interaction using STM32CubeIDE will also be greatly appreciated =)

Cheers!

MCope.1
Associate II

I'm assuming you've downloaded the STM32WBCube software? (https://www.st.com/en/embedded-software/stm32cubewb.html). There is only one Zigbee application with a STM32CubeIDE example (OnOff_Server_Coord). However we found it's easy to use this project as a base and swap the other example main and app_zigbee files to get the other examples working.

To get the OnOff_Server_Coord working:

  1. Import an existing project from this directory -> STM32Cube_FW_WB_V1.6.0/Projects/P-NUCLEO-WB55.Nucleo/Applications/Zigbee/Zigbee_OnOff_Server_Coord/SW4STM32
  2. It'll ask if you want to convert to a new format. Click yes.
  3. Build and flash

To get the Zigbee_OnOff_Client_Distrib working:

  1. Set up a new project as a OnOff_Server_Coord
  2. Replace the project specific files. I don't remember exactly but I think it's just app_zigbee.c, app_zigbee.h, main.c, main.h. Follow the errors from there and it's pretty easy to find what needs to be swapped
  3. Build and flash

pdelrot
Associate III

Hello. I can't post new topics too...

This one was quite encouraging for me, but I still not working.

My goal :

  • I try to make a Zigbee router, with a device temperature server.
  • The network coordinator will ask router's temperature from time to time (push button).
  • I use STM32Cube_FW_WB_V1.10.0.

I'd like to read the device temperature (cluster server) (for exemple) only when a attribute read request is received (from client cluster). For this scenario, I don't want my device reading periodically the temperature to update the server cluster attribute.

Quite close from MCope.1 use case.

In AN5498 §3.2.3, this is perfectly what I want to do : install a callback when the attribute is accessed.

But I was not able to find how to configure the cluster to call the callback once's I wrote it.

Are there any examples from the API (I did not found any) ? or from anyone ?

I read this current topic, seems clear, but I was not able to adapt the solution inside my code (older API ?)

/* Temperature */
 
zigbee_app_info.temperature_server_1 = ZbZclDevTempServerAlloc(zigbee_app_info.zb, SW1_ENDPOINT);
 
assert(zigbee_app_info.temperature_server_1 != NULL);
 
 
// Find the Attribute Object
 
struct ZbZclAttrListEntryT temperature_attribute_entry; // COMPILE ERROR ZbZclAttrListEntryT not existing (even after text search inside API repository)
 
struct ZbZclAttrT temperature_attribute;
 
temperature_attribute_entry = *(ZbZclAttrFind(zigbee_app_info.temperature_server_1, ZCL_DEV_TEMP_CURRENT)); // COMPILE ERROR ZbZclAttrFind not existing (even after text search inside API repository)
 
temperature_attribute = *(temperature_attribute_entry.info);
 
 
// Assign a callback function
 
temperature_attribute.callback = &APP_ZIGBEE_ReadTemperatureRequest_cb;
 
temperature_attribute.flags = ZCL_ATTR_FLAG_CB_READ;   // to activate callback when the attribute is read by the client cluster
 
 
ZbZclClusterEndpointRegister(zigbee_app_info.temperature_server_1);

Thanks !

Pascal