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

Unable to use zigbee cli and additional USB classes

The way that zb_cli_init is currently coded, it isn't possible to add any additional USB classes.

zb_cli_init calls app_usb_init, adds the classes it wants and then either calls app_usbd_power_events_enable or app_usbd_enable depending on the configuration.

The documentation for app_usbd_power_events_enable says that all classes should be added prior to calling it. This means that it isn't possible to add additional USB classes (for say a second CDC ACM port or the DFU trigger library) if the zigbee cli is enabled.

Similarly, app_usbd_class_append says that it needs to be called after usbd is initialized and before its enabled.

Currently, I think that the only way to work around this is to make a copy of zigbee_cli.c and use a modified copy rather than the original.

Parents
  • Hello,

    I believe that the power events for the USB is enabled by default in the Zigbee cli_agent_router example from SDK2.0.0 for Thread and Zigbee.

    Check out:

    zb_zli_init() -> usbd_init() -> app_usbd_power_events_enable() -> which set the app_usbd_power_event_handler as the usb event handler. Is that what you are looking for?

    This is probably what you mean, but it is correct as you say. Since the nRF52840 only has one physical USB, you must configure it before starting it. So everything you want to use the USB for you need to configure before you start the usb.

    Alternatively, if you do not want to use the USB for CLI, you can remove this part, and only use the UART, but I don't know whether this suits your application.

    Best regards,

    Edvin

  • The issue is that I want to use the USB for CLI, and I also want to instantiate a second CDC ACM channel as well as enabling the USB DFU trigger, but it seems that I can't do these things with the existing code.

  • I believe it is possible to have several USB classes on the same USB peripheral, so if you want this, then you should init all of these classes prior to enabling the USB. Have you tried implementing it? Does it throw any errors?

  • I tried it and it just hung. As I mentioned earlier, the documentation says that app_usbd_class_append needs to be called after app_usbd_init and before USB is enabled. Since zb_cli_init does both of those things, I'm not sure where the correct place to call app_usbd_class_append is?

Reply Children
Related