Hi everyone,
I have found workaround
s to be able to include Z-uno2 in HC2. It works but it is very heavy:
- The code must be both static and dynamic ???
- The inclusion is a 15(!!) steps 'procedure' that, in fact, implies 3 consecutives configurations. It looks as if there were somes timeouts fights between Z-uno & HC2 during inclusion.
I hope anyway that it will help someone that does not want to wait for next release.
CODE: It is largely inspired from ZunoTest.ino (the certified ZWave device).
The astounding fact is that it includes both a static declaration of devices to include and a dynamic one. I can’t really figure out why, to me it reduces a lot 'dynamic code' interest ?
The static declaration part seems to be required to declare some memory space to be saved ‘before’ the real compilation:
Somewhere at the beginning of compilation, the following message appears:
Core version: 03.09 Channels:x, where x is the number of channel declared by the ‘static code’.
Check that it is what you require.
Other strange thing : the ‘dynamic code’
must include at least one zunoAddAssociation(). So most of the time there will be 2 groups in HC2
but that is not always the case, even when it works.
This is probably the next bug, but so far, I am not using groups….
Here it is :
Code: Select all
#include "Arduino.h"
#include "ArduinoTypes.h"
#define ZUNO_STATICGATHERING_PHASE
#include "ZUNO_StaticData.h"
#if (ZUNO_CORE_VERSION_MAJOR < 3)
#error "------- This code should be complied for ZUNO 2 target"
#endif
#define SPDBGSTART(X) Serial.begin(X)
#define SPDBG(...) Serial.print(__VA_ARGS__)
#define SPDBGLN(...) Serial.println(__VA_ARGS__)
#define BUILTIN_LED_PIN 13
ZUNO_DISABLE(NO_MULTIBINARY_SWITCH0);
ZUNO_ENABLE(WITH_CC_SENSOR_MULTILEVEL WITH_CC_SENSOR_BINARY WITH_CC_BASIC WITH_CC_SWITCH_MULTILEVEL WITH_CC_SWITCH_BINARY);
uint32_t au32myZwaveValues[10];
ZUNO_SETUP_CHANNELS(
ZUNO_SWITCH_BINARY(au32myZwaveValues[0], NULL),
ZUNO_SWITCH_BINARY(au32myZwaveValues[1], NULL),
ZUNO_SWITCH_MULTILEVEL(au32myZwaveValues[2], NULL),
ZUNO_SWITCH_MULTILEVEL(au32myZwaveValues[3], NULL),
ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[4]),
ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[5]),
ZUNO_SENSOR_MULTILEVEL_VOLTAGE(au32myZwaveValues[6])
);
// SETUP SETUP SETUP SETUP SETUP SETUP SETUP
//_________________________________________________________________________________
void setup() {
SPDBGSTART(57600); SPDBGLN("SetupStart");
pinMode(BUILTIN_LED_PIN, OUTPUT);
if(zunoStartDeviceConfiguration()) {
SPDBGLN("NewConf");
zunoAddChannel(1,0,0);
zunoSetZWChannel( 0, 0x01 | ZWAVE_CHANNEL_MAPPED_BIT);
zunoAddChannel(1,0,0);
zunoSetZWChannel( 1, 0x02);
zunoAddChannel(2,0,0);
zunoSetZWChannel( 2, 0x03);
zunoAddChannel(2,0,0);
zunoSetZWChannel( 3, 0x04);
zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
zunoSetZWChannel( 4, 0x05);
zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
zunoSetZWChannel( 5, 0x06);
zunoAddChannel(4,ZUNO_SENSOR_MULTILEVEL_TYPE_VOLTAGE,34);
zunoSetZWChannel( 6, 0x07);
zunoAddAssociation(1, 0);
zunoCommitCfg();
}
zunoAppendChannelHandler( 0, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[0]);
zunoAppendChannelHandler( 1, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[1]);
zunoAppendChannelHandler( 2, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[2]);
zunoAppendChannelHandler( 3, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[3]);
zunoAppendChannelHandler( 4, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[4]);
zunoAppendChannelHandler( 5, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[5]);
zunoAppendChannelHandler( 6, 1, CHANNEL_HANDLER_SINGLE_VALUEMAPPER, (void*)&au32myZwaveValues[6]);
SPDBGLN("INIT Done");
}
// LOOP LOOP LOOP LOOP LOOP
//_________________________________________________________________________________
void loop() {
static uint32_t u32Count=0;
uint8_t u8i;
uint8_t bChgt=false;
digitalWrite(BUILTIN_LED_PIN, HIGH);delay(2000);
digitalWrite(BUILTIN_LED_PIN, LOW);delay(500);
for(u8i=0;u8i<7;u8i++){ SPDBG(u8i);SPDBG(":");SPDBGLN(au32myZwaveValues[u8i]);}
if (((u32Count /3) % 2) == 0) {bChgt =(au32myZwaveValues[3]!=80); au32myZwaveValues[3]=80;au32myZwaveValues[0] = 255;zunoSendReport(1);zunoSendReport(3);}
else {bChgt =(au32myZwaveValues[3]!=30);au32myZwaveValues[3]=30;au32myZwaveValues[0] = 0;}
if (bChgt) {zunoSendReport(1);zunoSendReport(4);}
if ((u32Count % 20)== 0)
{
au32myZwaveValues[4] = u32Count*10;
zunoSendReport(5);
}
u32Count++;
}
INCLUSION PROCEDURE:
1) get Z-uno2 board in rescue mode even with a ligh 'loop code' (you must have a light loop code anyways after step 11, you will replace it later)
2) start 'Add device' on HC2 and triple click on Z-uno2
3) wait & wait & wait...
4) device is added but not configured and only lifeline appears:
- 1.jpg (42.7 KiB) Viewed 2531 times
5) go to the page of the new master & to the 'advanced' tab
- 2.jpg (179.23 KiB) Viewed 2531 times
6) click on 'Setting Association' and check,
for every groups, that S & M are 'ON'
- 3.jpg (138.69 KiB) Viewed 2531 times
7) click on 'Reconfigure Device' (red circle above). At this stage you should still be in Rescue mode
8) In the next popup don't be shy and 'YES!!' pretend that you know what you are doing
.
- 4.jpg (77.36 KiB) Viewed 2531 times
8) wait & wait & wait...
9) But most of the time it is not finished yet, as you should still be close to 4)
!!!
10) Repeat step 6 (some other group may have appeared)
11) press reset on the Z-uno2
12) click in the notification icon
- 5.jpg (204.96 KiB) Viewed 2531 times
13) click on
retry
14) wait & wait & wait...
15) this time it should be OK!!!,
- 6.jpg (49.33 KiB) Viewed 2531 times
If not: try again once from 10), if still KO, then suspect your code, most of the time the bug lies somewhere between keyboard and chair but, in that particular case, understanding of documentation may be also involved
Have a nice day,
Yves