[solved] ZUNO_REPORTS_HANDLER() for Z-Uno2

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
element
Posts: 14
Joined: 22 Oct 2021 02:10

[solved] ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by element »

Compiling sample code, catching unsolicited reports from other Z-Wave devices:

Code: Select all

ZUNO_REPORTS_HANDLER(SensorMultilevel, SensorMultilevelReport);

#define SERIAL Serial0
ZUNO_ENABLE(LOGGING_DBG LOGGING_EVENTS);

void logReportTitle(char * text) {
    SERIAL.print(millis());
    SERIAL.print("    ");
    SERIAL.print(text);
    SERIAL.print(" NODE:");
    SERIAL.print(REPORT_NODE_ID());
    SERIAL.print(" VALUE:");
}


void SensorMultilevelReport() {
    logReportTitle("SENSOR MULTILEVEL");
    switch(REPORT_SENSOR_MULTILEVEL_SIZE()) {
        case 1:
            SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_1B()), REPORT_SENSOR_MULTILEVEL_PRECISION());
            break;
        case 2:
            SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_2B()), REPORT_SENSOR_MULTILEVEL_PRECISION());
            break;
        case 4:
            SERIAL.fixPrint(long(REPORT_SENSOR_MULTILEVEL_VALUE_4B()), REPORT_SENSOR_MULTILEVEL_PRECISION());
            break;
    }
    SERIAL.print(" TYPE:");
    SERIAL.print(REPORT_SENSOR_MULTILEVEL_TYPE(), HEX);
    SERIAL.print(" SCALE:");
    SERIAL.println(REPORT_SENSOR_MULTILEVEL_SCALE(), HEX);
}

void setup() {
    SERIAL.begin(115200);
    SERIAL.print("START");
}

void loop() {
    delay(1000);
}
from the site: https://z-uno.z-wave.me/Reference/ZUNO_REPORTS_HANDLER/ throws a lot of errors, but when the Z-Uno2 board is selected. However, for the first version of the Z-Uno it shows no errors. So I guess this page has not been updated for the second version of the Z-Uno. I am asking for a working code example for the Z-Uno2 board.
Pretty please.
Last edited by element on 04 Jun 2022 01:44, edited 1 time in total.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by p0lyg0n1 »

Hello. Thank you very much for reminding us about receiving reports. At some point we forgot about them and the code was out of sync, like the example on the site. Fixed the code (reinstall the latest version 3.09.B10 from the beta repository, see the instructions: https://drive.google.com/file/d/13l9e6D ... sp=sharing ) and updated the example on the website: https://z-uno.z-wave.me/Reference/ZUNO ... S_HANDLER/
Try. Good luck

Best regards,
Alex.
element
Posts: 14
Joined: 22 Oct 2021 02:10

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by element »

Thank you, but ... it's not working.

For the first board, I have compiled the following code:

Code: Select all

// add library ds18b20
#include <ZUNO_DS18B20.h>

// pin connection ds18b20
#define PIN_DS18B20 11

OneWire ow(PIN_DS18B20);

// onewire connection temperature sensors
DS18B20Sensor ds1820(&ow); 

int temp; // here we will store the temperature
int tempSent=-10;
int reportThreshold=10;

// set up channel
ZUNO_SETUP_CHANNELS(
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, 
                          SENSOR_MULTILEVEL_SCALE_CELSIUS, 
                          SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                          SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                          getterTemp)
);

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);

void setup() {
}

void loop() {
  temp=ds1820.getTempC100(NULL);
  digitalWrite(PIN_DS18B20, LOW);
  if(abs(temp-tempSent)>reportThreshold){
    zunoSendReport(1);
    tempSent=temp;
  }
  zunoSetCustomWUPTimer(30);
  zunoSendDeviceToSleep();
}

word getterTemp() {
  return temp;
}
For the second board, I have the following code compiled:

Code: Select all

#include "Arduino.h"
#define MY_SERIAL Serial

ZUNO_REPORTS_HANDLER(SensorMultilevel, SensorMultilevelReport);

void logReportTitle(const char * text, ReportAuxData_t *report_data) {
  MY_SERIAL.print(millis());
  MY_SERIAL.print("    ");
  MY_SERIAL.print(text);
  MY_SERIAL.print(" NODE:");
  MY_SERIAL.print(REPORT_NODE_ID(report_data));
  MY_SERIAL.print(" VALUE:");
}

void SensorMultilevelReport(ReportAuxData_t *report_data) {
  logReportTitle("SENSOR MULTILEVEL", report_data);
  switch(REPORT_SENSOR_MULTILEVEL_SIZE(report_data)) {
    case 1:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_1B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 2:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_2B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 4:
      MY_SERIAL.fixPrint(long(REPORT_SENSOR_MULTILEVEL_VALUE_4B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
  }
  MY_SERIAL.print(" TYPE:");
  MY_SERIAL.print(REPORT_SENSOR_MULTILEVEL_TYPE(report_data), HEX);
  MY_SERIAL.print(" SCALE:");
  MY_SERIAL.println(REPORT_SENSOR_MULTILEVEL_SCALE(report_data), HEX);
}

/* the setup function runs once, when you press reset or power the board */
void setup() {
  MY_SERIAL.begin(115200);
  MY_SERIAL.print("START");
}

/* the loop function runs over and over again forever */
void loop() {
  delay(1000);
}
According to the instructions, I updated the board software in the manager to 3.09.B10. I checked by comparing the files in the "Z-Uno2 (Beta)" directory with the unpacked z-uno2_core_03_00_09_beta10.zip. I have excluded both boards from the Z-Way. I've updated bootloaders and recompiled the codes. Then include to Z-Way. In the association lifeline configuration of the first board, I added a second board (previously, for the whole winter, it was added Eurotronic Spirit thermostat working on the radiator, so the first board works). Z-Way receives unsolicited reports and displays the updated temperature. By contrast, the serial port monitor connected to the second board only displayed START.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by p0lyg0n1 »

Hello. We will check your configuration today. At first glance, according to the description, everything looks working. I will write as soon as there are results.
Sincerely,
Alex.
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by p0lyg0n1 »

Hello. As a result, there really are problems with getting reports. They are blocked by the latest version of the SDK. Everything that is not part of the channels of the device is blocked. We'll find a workaround and update the main firmware, but it's not clear how long it will take, because it's in the binary library code. So far, there is one way to make reports work for you - add a dummy SensorMultilevel channel to the receiving sketch. I will keep you updated on how to solve this problem in the main firmware.

Sincerely,
Alex.
element
Posts: 14
Joined: 22 Oct 2021 02:10

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by element »

Okay, I'll wait for the firmware update. Anyway, I've tried this workaround
p0lyg0n1 wrote:
01 Jun 2022 14:58
So far, there is one way to make reports work for you - add a dummy SensorMultilevel channel to the receiving sketch.
and still don't have reports. Please correct my code:

Code: Select all

#include "Arduino.h"
#define MY_SERIAL Serial

// set up channel
ZUNO_SETUP_CHANNELS(
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, 
                          SENSOR_MULTILEVEL_SCALE_CELSIUS, 
                          SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                          SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                          getterTemp)
);
ZUNO_REPORTS_HANDLER(SensorMultilevel, SensorMultilevelReport);

void logReportTitle(const char * text, ReportAuxData_t *report_data) {
  MY_SERIAL.print(millis());
  MY_SERIAL.print("    ");
  MY_SERIAL.print(text);
  MY_SERIAL.print(" NODE:");
  MY_SERIAL.print(REPORT_NODE_ID(report_data));
  MY_SERIAL.print(" VALUE:");
}

void SensorMultilevelReport(ReportAuxData_t *report_data) {
  logReportTitle("SENSOR MULTILEVEL", report_data);
  switch(REPORT_SENSOR_MULTILEVEL_SIZE(report_data)) {
    case 1:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_1B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 2:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_2B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 4:
      MY_SERIAL.fixPrint(long(REPORT_SENSOR_MULTILEVEL_VALUE_4B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
  }
  MY_SERIAL.print(" TYPE:");
  MY_SERIAL.print(REPORT_SENSOR_MULTILEVEL_TYPE(report_data), HEX);
  MY_SERIAL.print(" SCALE:");
  MY_SERIAL.println(REPORT_SENSOR_MULTILEVEL_SCALE(report_data), HEX);
}

/* the setup function runs once, when you press reset or power the board */
void setup() {
  MY_SERIAL.begin(115200);
  MY_SERIAL.print("START");
}

/* the loop function runs over and over again forever */
void loop() {
  delay(1000);
}

word getterTemp() {
  return 0;
}
p0lyg0n1
Posts: 242
Joined: 04 Aug 2016 07:14

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by p0lyg0n1 »

Hello. Everything was finally fixed. It's working now. Update the packages. The current beta version is 3.09 beta 12. This time I checked it myself and didn't trust other testers. As I have already said, there was the following global problem - reports were filtered at the SDK level. Among other things, the preprocessor did not generate a handler specifically for Sensor Multi level. Colleagues check on SensorBinary so as not to wait 30 seconds between reports and he was just working with the edits that I wrote. In addition, there was also a security level filter - reports could only be received from devices with the same S2 level. Well, small edits of your sketch are still needed - to receive reports from multi-channel devices. See my test code below. Thank you again so much for your perseverance and patience!

Code: Select all

#define MY_SERIAL Serial
// You need the WITH_CC_MULTICHANNEL channel to view multi-channel reports (for devices with multiple endpoints, such as ZUno)
ZUNO_ENABLE(LOGGING_DBG WITH_CC_MULTICHANNEL);
ZUNO_REPORTS_HANDLER(SensorMultilevel, SensorMultilevelReport);

void logReportTitle(const char * text, ReportAuxData_t *report_data) {
  MY_SERIAL.print(millis());
  MY_SERIAL.print("    ");
  MY_SERIAL.print(text);
  MY_SERIAL.print(" NODE:");
  MY_SERIAL.print(REPORT_NODE_ID(report_data));
  MY_SERIAL.print(" VALUE:");
}

void SensorMultilevelReport(ReportAuxData_t *report_data) {
  logReportTitle("SENSOR MULTILEVEL", report_data);
  switch(REPORT_SENSOR_MULTILEVEL_SIZE(report_data)) {
    case 1:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_1B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 2:
      MY_SERIAL.fixPrint(int(REPORT_SENSOR_MULTILEVEL_VALUE_2B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
    case 4:
      MY_SERIAL.fixPrint(long(REPORT_SENSOR_MULTILEVEL_VALUE_4B(report_data)), REPORT_SENSOR_MULTILEVEL_PRECISION(report_data));
      break;
  }
  MY_SERIAL.print(" TYPE:");
  MY_SERIAL.print(REPORT_SENSOR_MULTILEVEL_TYPE(report_data), HEX);
  MY_SERIAL.print(" SCALE:");
  MY_SERIAL.println(REPORT_SENSOR_MULTILEVEL_SCALE(report_data), HEX);
}

/* the setup function runs once, when you press reset or power the board */
void setup() {
  MY_SERIAL.begin(115200);
  MY_SERIAL.print("START");
  // DBG for those who have a special license
  // dumps all received and transmitted messages
  // zunoPTIConfigUART(TX2, 230400);
}

/* the loop function runs over and over again forever */
void loop() {
  delay(1000);
}
Code of the sensor sketch:

Code: Select all


ZUNO_ENABLE(LOGGING_DBG);
int temp1; 
int temp2;


// set up channel
ZUNO_SETUP_CHANNELS(
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, 
                          SENSOR_MULTILEVEL_SCALE_CELSIUS, 
                          SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                          SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                          temp1),
   ZUNO_SENSOR_MULTILEVEL(ZUNO_SENSOR_MULTILEVEL_TYPE_TEMPERATURE, 
                          SENSOR_MULTILEVEL_SCALE_CELSIUS, 
                          SENSOR_MULTILEVEL_SIZE_TWO_BYTES, 
                          SENSOR_MULTILEVEL_PRECISION_TWO_DECIMALS,
                          temp2)
);

ZUNO_SETUP_SLEEPING_MODE(ZUNO_SLEEPING_MODE_FREQUENTLY_AWAKE);

void setup() {
}

void loop() {
  temp1=1500 + rand() % 1000;
  temp2=1500 + rand() % 1000;
  zunoSendReport(1);
  zunoSendReport(2);
  zunoSetCustomWUPTimer(30);
  delay(10000);
  zunoSendDeviceToSleep();

}
Sincerely,
Alex.
element
Posts: 14
Joined: 22 Oct 2021 02:10

Re: ZUNO_REPORTS_HANDLER() for Z-Uno2

Post by element »

Works great. :-) Thank you, but ;P ... macro:

Code: Select all

// You need the WITH_CC_MULTICHANNEL channel to view multi-channel reports (for devices with multiple endpoints, such as ZUno)
ZUNO_ENABLE(WITH_CC_MULTICHANNEL);
Not yet in the reference. Include them. ;-)
Regards
Post Reply