tlaukkan / zigbee4java

Zigbee API for Java provides simple Java interface to ZigBee network.
Apache License 2.0
144 stars 68 forks source link

Issue regarding Dongle Reset #125

Open Aimen-Hammou opened 2 years ago

Aimen-Hammou commented 2 years ago

Hi,

I've downloaded the repository and run the mvn clean install. It gives me zero errors, so far so good.

I've created a main class, with this source code.

` public static void main(String[] args) {

    final byte[] networkKey = null; // Default network key
    final SerialPort port = new SerialPortImpl("COM3");
    final ZigBeeDongle dongle = new ZigBeeDongleTiCc2531Impl(port, 4951, 11, networkKey, false);
    final ZigBeeApiDongleImpl api = new ZigBeeApiDongleImpl(dongle, false);

    api.startup();

    //final ZigBeeDevice device = api.getDevices().get(3);

    api.shutdown();
    port.close();

}

`

When api.startup() is called it fails at the dongle reset.

15:36:02 339  INFO   Loading network state...
15:36:02 558  INFO   Loading network state done.
15:36:07 581  WARN   Dongle reset failed. Assuming bootloader is running and sending magic byte 0xef.
15:36:12 583  WARN   Attempt to get out from bootloader failed.
15:36:12 583  WARN   Discarded stream: expected start byte but received this 0x00
15:36:12 583  INFO   Serial portName 'COM3' closed.
15:36:12 583  INFO   ZigBeeApi saving network state...
15:36:12 583  INFO   ZigBeeApi saving network state done.

To see what was going on in the background I decided to sniff the serial port, and it shows that the SYS-RESET command is sent, but dongle gives no response.

I also decided to test ZSmartSystem repository and it seems like the dongle answer to the reset command and does what is needed to do.

Hardware: SonOff CC2562