Notification handler

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
aleconakad
Posts: 68
Joined: 18 Jan 2016 15:25

Notification handler

Post by aleconakad »

Hi,

I am trying to port a Zuno sketch to Zuno2 using the 3.0.7 toolchain. The following piece of code seems to break:

Code: Select all

ZUNO_REPORTS_HANDLER(Notification, notificationReportHandler);
...
...
void notificationReportHandler() {
#if defined SERIAL_DEBUG && defined DEBUG_REPORT_HANDLER
  Serial.print(REPORT_NOTIFICATION_STATUS(), HEX);
  Serial.print(" TYPE:");
  Serial.print(REPORT_NOTIFICATION_TYPE(), HEX);
  Serial.print(" EVENT:");
  Serial.print(REPORT_NOTIFICATION_EVENT(), HEX);
  Serial.print(" PARAM:");
  Serial.println(REPORT_NOTIFICATION_EVENT_PARAM(0), HEX);
#endif 
  byte type = REPORT_NOTIFICATION_TYPE();
  byte event = REPORT_NOTIFICATION_EVENT();
  byte param0 = REPORT_NOTIFICATION_EVENT_PARAM(0);
....
....
}
It seems that some signatures have been changed in reportHandler.h, and now they require some parameter(s) to work:

Code: Select all

#define REPORT_NOTIFICATION_STATUS(report_data)				(((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.notificationStatus)
#define REPORT_NOTIFICATION_TYPE(report_data)				(((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.notificationType)
#define REPORT_NOTIFICATION_EVENT(report_data)				(((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.mevent)
#define REPORT_NOTIFICATION_PARAM_LENGTH(report_data)		(((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.properties1 & NOTIFICATION_PROPERTIES_PARAMLENGTH_MASK)
#define REPORT_NOTIFICATION_EVENT_PARAM(report_data, N)		(((uint8_t *)&(((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.eventParameter1))[N])

Error messages shown:

Code: Select all

[size=85]var/folders/_b/cl88zkv55sx9w89rk4tb6zhw0000gn/T/arduino_build_737389/zuno-rgbw-controller.ino: In function 'void notificationReportHandler()':
ReportHandler.h:75:101: error: expected primary-expression before '*' token
 #define REPORT_NOTIFICATION_TYPE(report_data)    (((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.notificationType)
                                                                                                     ^
/var/folders/_b/cl88zkv55sx9w89rk4tb6zhw0000gn/T/arduino_build_737389/zuno-rgbw-controller.ino:1238:15: note: in expansion of macro 'REPORT_NOTIFICATION_TYPE'
 #endif
               ^                       
ReportHandler.h:75:102: error: expected primary-expression before ')' token
 #define REPORT_NOTIFICATION_TYPE(report_data)    (((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.notificationType)
                                                                                                      ^
/var/folders/_b/cl88zkv55sx9w89rk4tb6zhw0000gn/T/arduino_build_737389/zuno-rgbw-controller.ino:1238:15: note: in expansion of macro 'REPORT_NOTIFICATION_TYPE'
 #endif
               ^                       
ReportHandler.h:76:102: error: expected primary-expression before '*' token
 #define REPORT_NOTIFICATION_EVENT(report_data)    (((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.mevent)
                                                                                                      ^
/var/folders/_b/cl88zkv55sx9w89rk4tb6zhw0000gn/T/arduino_build_737389/zuno-rgbw-controller.ino:1239:16: note: in expansion of macro 'REPORT_NOTIFICATION_EVENT'
   //byte type, event, param0;
                ^~~~~~~~~~~~~~           
ReportHandler.h:76:103: error: expected primary-expression before ')' token
 #define REPORT_NOTIFICATION_EVENT(report_data)    (((ZwNotificationReportFrame_t *)((ReportAuxData_t *)report_data)->rawReportData)->byte4.mevent)
                                                                                                       ^
/var/folders/_b/cl88zkv55sx9w89rk4tb6zhw0000gn/T/arduino_build_737389/zuno-rgbw-controller.ino:1239:16: note: in expansion of macro 'REPORT_NOTIFICATION_EVENT'
   //byte type, event, param0;
                ^~~~~~~~~~~~~~           
zuno-rgbw-controller:1240:17: error: 'REPORT_NOTIFICATION_EVENT_PARAM' was not declared in this scope
   byte type = REPORT_NOTIFICATION_TYPE();
                 ^~~~~~~~~~~~~~~~~~~~~~~~~      


exit status 10
macro "REPORT_NOTIFICATION_EVENT_PARAM" requires 2 arguments, but only 1 given[/size]
amatilda
Posts: 61
Joined: 26 Sep 2021 22:09

Re: Notification handler

Post by amatilda »

Hello. Indeed, compared to Zuno, there are changes in Zuno2, here's an example changed:
https://z-uno.z-wave.me/Reference/ZUNO_REPORTS_HANDLER/

Code: Select all

#include "Arduino.h"
#define MY_SERIAL					Serial0

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 BatteryReport(ReportAuxData_t *report_data) {
	logReportTitle("BATTERY", report_data);
	MY_SERIAL.println(REPORT_BATTERY_VALUE(report_data), HEX);
}

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);
}

void SensorBinaryReport(ReportAuxData_t *report_data) {
	logReportTitle("SENSOR BINARY", report_data);
	MY_SERIAL.print(REPORT_SENSOR_BINARY_VALUE(report_data), HEX);
	MY_SERIAL.print(" TYPE:");
	MY_SERIAL.println(REPORT_SENSOR_BINARY_TYPE(report_data));
}

void SwitchBinaryReport(ReportAuxData_t *report_data) {
	logReportTitle("SWITCH BINARY", report_data);
	MY_SERIAL.println(REPORT_SWITCH_BINARY_VALUE(report_data), HEX);
}

void SwitchMultilevelReport(ReportAuxData_t *report_data) {
	logReportTitle("SWITCH MULTILEVEL2", report_data);
	MY_SERIAL.println(REPORT_SWITCH_MULTILEVEL_VALUE(report_data), HEX);
}

void NotificationReport(ReportAuxData_t *report_data) {
	logReportTitle("NOTIFICATION ", report_data);
	MY_SERIAL.print(REPORT_NOTIFICATION_STATUS(report_data), HEX);
	MY_SERIAL.print(" TYPE:");
	MY_SERIAL.print(REPORT_NOTIFICATION_TYPE(report_data), HEX);
	MY_SERIAL.print(" EVENT:");
	MY_SERIAL.print(REPORT_NOTIFICATION_EVENT(report_data), HEX);
	MY_SERIAL.print(" PARAM:");
	MY_SERIAL.println(REPORT_NOTIFICATION_EVENT_PARAM(report_data, 0), HEX);
}

void MeterReport(ReportAuxData_t *report_data) {
		logReportTitle("METER", report_data);
		switch(REPORT_METER_SIZE(report_data)){
		case 1:
			MY_SERIAL.fixPrint(int(REPORT_METER_VALUE_1B(report_data)), REPORT_METER_PRECISION(report_data));
			break;
		case 2:
			MY_SERIAL.fixPrint(int(REPORT_METER_VALUE_2B(report_data)), REPORT_METER_PRECISION(report_data));
			break;
		case 4:
			MY_SERIAL.fixPrint(long(REPORT_METER_VALUE_4B(report_data)), REPORT_METER_PRECISION(report_data));
			break;
	}
	MY_SERIAL.print(" TYPE:");
	MY_SERIAL.print(REPORT_METER_TYPE(report_data), HEX);
	MY_SERIAL.print(" SCALE:");
	MY_SERIAL.println(REPORT_METER_SCALE(report_data), HEX);
}

void BasicReport(ReportAuxData_t *report_data) {
	logReportTitle("BASIC", report_data);
	MY_SERIAL.println(REPORT_BASIC_VALUE(report_data), HEX);
}

/* the setup function runs once, when you press reset or power the board */
void setup() {
	ZUNO_REPORTS_HANDLER(Battery, BatteryReport);
	ZUNO_REPORTS_HANDLER(SensorMultilevel, SensorMultilevelReport);
	ZUNO_REPORTS_HANDLER(SensorBinary, SensorBinaryReport);
	ZUNO_REPORTS_HANDLER(Notification, NotificationReport);
	ZUNO_REPORTS_HANDLER(SwitchMultilevel, SwitchMultilevelReport);
	ZUNO_REPORTS_HANDLER(SwitchBinary, SwitchBinaryReport);
	ZUNO_REPORTS_HANDLER(Meter, MeterReport);
	ZUNO_REPORTS_HANDLER(Basic, BasicReport);
	MY_SERIAL.begin(115200);
	MY_SERIAL.print("START");
}

/* the loop function runs over and over again forever */
void loop() {
	MY_SERIAL.print("Loop");
	delay(1000);
}
amatilda
Posts: 61
Joined: 26 Sep 2021 22:09

Re: Notification handler

Post by amatilda »

That is, in your case, it is so necessary:

Code: Select all

void NotificationReport(ReportAuxData_t *report_data) {
#if defined SERIAL_DEBUG && defined DEBUG_REPORT_HANDLER
  Serial.print(REPORT_NOTIFICATION_STATUS(report_data), HEX);
  Serial.print(" TYPE:");
  Serial.print(REPORT_NOTIFICATION_TYPE(report_data), HEX);
  Serial.print(" EVENT:");
  Serial.print(REPORT_NOTIFICATION_EVENT(report_data), HEX);
  Serial.print(" PARAM:");
  Serial.println(REPORT_NOTIFICATION_EVENT_PARAM(report_data, 0), HEX);
#endif 
  byte type = REPORT_NOTIFICATION_TYPE(report_data);
  byte event = REPORT_NOTIFICATION_EVENT(report_data);
  byte param0 = REPORT_NOTIFICATION_EVENT_PARAM(report_data, 0);
....
....
}
aleconakad
Posts: 68
Joined: 18 Jan 2016 15:25

Re: Notification handler

Post by aleconakad »

thanks.

that worked :-)
Post Reply