Danke Jérôme, ich habe jetzt erfolgreich den Sketch "HB-UNI-SenAct-4-4-SC" aufgespielt. Mit "#define CREATE_INTERNAL_PEERINGS" werden auch die internen Verknüpfungen angelegt.
Jedoch habe hier die Taster
weiter nur die Funktion eines Tasters, nicht eines Schalters.
Also der Zustand der RELAY_PIN ändert sich nur, sobald ich einen Taster drücke und loslasse.
Ich hätte erwartet, dass sich der Zustand ändert, sobald ich einen Taster drücke und halte (eben wie ein Schalter).
Liegt da ein Fehler im Quellcode vor? Die "SC" Variante soll doch eigentlich die mit "Schaltern" sein.
Code: Alles auswählen
//- -----------------------------------------------------------------------------------------------------------------------
// AskSin++
// 2016-10-31 papa Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// 2018-08-13 jp112sdl Creative Commons - http://creativecommons.org/licenses/by-nc-sa/3.0/de/
// special thanks to "klassisch" from homematic-forum.de
//- -----------------------------------------------------------------------------------------------------------------------
// ci-test=yes board=328p aes=no
// define this to read the device id, serial and device type from bootloader section
#define USE_OTA_BOOTLOADER
#define USE_WOR
#define EI_NOTEXTERNAL
#include <EnableInterrupt.h>
#include <AskSinPP.h>
#include <LowPower.h>
#include <Switch.h>
#include <ContactState.h>
//#define USE_BATTERY_MODE // bei Batteriebetrieb
#define LOWBAT_VOLTAGE 22 // Batterie-Leermeldung bei Unterschreiten der Spannung von U * 10
#define RELAY_PIN_1 15
#define RELAY_PIN_2 14
#define RELAY_PIN_3 16
#define RELAY_PIN_4 17
#define SENS_PIN_1 6
#define SENS_PIN_2 5
#define SENS_PIN_3 7
#define SENS_PIN_4 9
#define SABOTAGE_PIN_1 3
#define LED_PIN 4
#define CONFIG_BUTTON_PIN 8
// number of available peers per channel
#define CREATE_INTERNAL_PEERINGS
#define PEERS_PER_SwitchChannel 6
#define PEERS_PER_SENSCHANNEL 6
#ifdef USE_BATTERY_MODE
#define battOp_ARGUMENT BatterySensor
#define DEV_MODEL 0x33
#define CYCLETIME seconds2ticks(60UL * 60 * 12 * 0.88) // 60 seconds * 60 (= minutes) * 12 (=hours) * corrective factor
#else
#define battOp_ARGUMENT NoBattery
#define DEV_MODEL 0x31
#define CYCLETIME seconds2ticks(60UL * 3 * 0.88) // every 3 minutes
#endif
// all library classes are placed in the namespace 'as'
using namespace as;
// define all device properties
const struct DeviceInfo PROGMEM devinfo = {
{0xf3, DEV_MODEL, 0x01},// Device ID
"JPSENACT01", // Device Serial
{0xf3, DEV_MODEL}, // Device Model
0x10, // Firmware Version
as::DeviceType::Switch, // Device Type
{0x01, 0x00} // Info Bytes
};
/**
Configure the used hardware
*/
typedef AvrSPI<10, 11, 12, 13> RadioSPI;
typedef AskSin<StatusLed<LED_PIN>, battOp_ARGUMENT, Radio<RadioSPI, 2> > Hal;
Hal hal;
DEFREGISTER(Reg0, MASTERID_REGS, DREG_INTKEY, DREG_CYCLICINFOMSG, DREG_SABOTAGEMSG)
class SwList0 : public RegList0<Reg0> {
public:
SwList0(uint16_t addr) : RegList0<Reg0>(addr) {}
void defaults() {
clear();
intKeyVisible(true);
sabotageMsg(true);
cycleInfoMsg(true);
}
};
DEFREGISTER(Reg1, CREG_AES_ACTIVE, CREG_MSGFORPOS, CREG_EVENTDELAYTIME, CREG_LEDONTIME, CREG_TRANSMITTRYMAX)
class SensList1 : public RegList1<Reg1> {
public:
SensList1 (uint16_t addr) : RegList1<Reg1>(addr) {}
void defaults () {
clear();
msgForPosA(1);
msgForPosB(2);
aesActive(false);
eventDelaytime(0);
ledOntime(100);
transmitTryMax(6);
}
};
typedef SwitchChannel<Hal, PEERS_PER_SwitchChannel, SwList0> SwChannel;
typedef TwoStateChannel<Hal, SwList0, SensList1, DefList4, PEERS_PER_SENSCHANNEL> SensChannel;
class MixDevice : public ChannelDevice<Hal, VirtBaseChannel<Hal, SwList0>, 8, SwList0> {
class CycleInfoAlarm : public Alarm {
MixDevice& dev;
public:
CycleInfoAlarm (MixDevice& d) : Alarm (CYCLETIME), dev(d) {}
virtual ~CycleInfoAlarm () {}
void trigger (AlarmClock& clock) {
set(CYCLETIME);
clock.add(*this);
dev.switchChannel(1).changed(true);
}
} cycle;
public:
VirtChannel<Hal, SwChannel, SwList0> swChannel1, swChannel2, swChannel3, swChannel4;
VirtChannel<Hal, SensChannel, SwList0> sensChannel5, sensChannel6, sensChannel7, sensChannel8;
public:
typedef ChannelDevice<Hal, VirtBaseChannel<Hal, SwList0>, 8, SwList0> DeviceType;
MixDevice (const DeviceInfo& info, uint16_t addr) : DeviceType(info, addr), cycle(*this) {
DeviceType::registerChannel(swChannel1, 1);
DeviceType::registerChannel(swChannel2, 2);
DeviceType::registerChannel(swChannel3, 3);
DeviceType::registerChannel(swChannel4, 4);
DeviceType::registerChannel(sensChannel5, 5);
DeviceType::registerChannel(sensChannel6, 6);
DeviceType::registerChannel(sensChannel7, 7);
DeviceType::registerChannel(sensChannel8, 8);
}
virtual ~MixDevice () {}
SwChannel& switchChannel (uint8_t num) {
switch (num) {
case 1:
return swChannel1;
break;
case 2:
return swChannel2;
break;
case 3:
return swChannel3;
break;
case 4:
return swChannel4;
break;
}
}
SensChannel& sensorChannel (uint8_t num) {
switch (num) {
case 5:
return sensChannel5;
break;
case 6:
return sensChannel6;
break;
case 7:
return sensChannel7;
break;
case 8:
return sensChannel8;
break;
}
}
virtual void configChanged () {
if ( this->getList0().cycleInfoMsg() == true ) {
DPRINTLN("Activate Cycle Msg");
sysclock.cancel(cycle);
cycle.set(CYCLETIME);
sysclock.add(cycle);
}
else {
DPRINTLN("Deactivate Cycle Msg");
sysclock.cancel(cycle);
}
}
};
MixDevice sdev(devinfo, 0x20);
ConfigButton<MixDevice> cfgBtn(sdev);
void initPeerings (bool first) {
// create internal peerings - CCU2 needs this
if ( first == true ) {
#ifdef CREATE_INTERNAL_PEERINGS
HMID devid;
sdev.getDeviceID(devid);
for ( uint8_t i = 1; i <= 4; ++i ) {
Peer ipeer(devid, i + 4);
sdev.switchChannel(i).peer(ipeer);
}
for ( uint8_t i = 1; i <= 4; ++i ) {
Peer ipeer(devid, i);
sdev.sensorChannel(i + 4).peer(ipeer);
}
#endif
}
}
void setup () {
DINIT(57600, ASKSIN_PLUS_PLUS_IDENTIFIER);
bool first = sdev.init(hal);
sdev.switchChannel(1).init(RELAY_PIN_1, false);
sdev.switchChannel(2).init(RELAY_PIN_2, false);
sdev.switchChannel(3).init(RELAY_PIN_3, false);
sdev.switchChannel(4).init(RELAY_PIN_4, false);
sdev.sensorChannel(5).init(SENS_PIN_1, SABOTAGE_PIN_1);
sdev.sensorChannel(6).init(SENS_PIN_2, SABOTAGE_PIN_1);
sdev.sensorChannel(7).init(SENS_PIN_3, SABOTAGE_PIN_1);
sdev.sensorChannel(8).init(SENS_PIN_4, SABOTAGE_PIN_1);
buttonISR(cfgBtn, CONFIG_BUTTON_PIN);
initPeerings(first);
#ifdef USE_BATTERY_MODE
hal.activity.stayAwake(seconds2ticks(15));
hal.battery.low(LOWBAT_VOLTAGE);
// measure battery every 12 hours
hal.battery.init(seconds2ticks(60UL * 60 * 12 * 0.88), sysclock);
#endif
hal.radio.initReg(CC1101_FREQ2, 0x21);
hal.radio.initReg(CC1101_FREQ1, 0x65);
hal.radio.initReg(CC1101_FREQ0, 0xF2);
sdev.initDone();
}
void loop() {
bool worked = hal.runready();
bool poll = sdev.pollRadio();
if ( worked == false && poll == false ) {
#ifdef USE_BATTERY_MODE
hal.activity.savePower<Sleep<> >(hal);
#else
hal.activity.savePower<Idle<> >(hal);
#endif
}
}
Homegear Infos:
Code: Alles auswählen
Family 0 - peer 49> config print
MASTER
{
Channel: 8
{
[TRANSMIT_TRY_MAX]: 06
[MSG_FOR_POS_B]: 01
[MSG_FOR_POS_A]: 02
[AES_ACTIVE]: 00
[EVENT_DELAYTIME]: 00
}
Channel: 7
{
[TRANSMIT_TRY_MAX]: 06
[MSG_FOR_POS_B]: 01
[MSG_FOR_POS_A]: 02
[AES_ACTIVE]: 00
[EVENT_DELAYTIME]: 00
}
Channel: 6
{
[TRANSMIT_TRY_MAX]: 06
[MSG_FOR_POS_B]: 01
[MSG_FOR_POS_A]: 02
[AES_ACTIVE]: 00
[EVENT_DELAYTIME]: 00
}
Channel: 1
{
[TRANSMIT_TRY_MAX]: 06
[STATUSINFO_MINDELAY]: 04
[AES_ACTIVE]: 00
[STATUSINFO_RANDOM]: 01
[POWERUP_ACTION]: 00
}
Channel: 0
{
[SABOTAGE_MSG]: 01
[CYCLIC_INFO_MSG]: 01
}
Channel: 2
{
[TRANSMIT_TRY_MAX]: 06
[STATUSINFO_MINDELAY]: 04
[AES_ACTIVE]: 00
[STATUSINFO_RANDOM]: 01
[POWERUP_ACTION]: 00
}
Channel: 3
{
[TRANSMIT_TRY_MAX]: 06
[STATUSINFO_MINDELAY]: 04
[AES_ACTIVE]: 00
[STATUSINFO_RANDOM]: 01
[POWERUP_ACTION]: 00
}
Channel: 4
{
[TRANSMIT_TRY_MAX]: 06
[STATUSINFO_MINDELAY]: 04
[AES_ACTIVE]: 00
[STATUSINFO_RANDOM]: 01
[POWERUP_ACTION]: 00
}
Channel: 5
{
[TRANSMIT_TRY_MAX]: 06
[MSG_FOR_POS_B]: 01
[MSG_FOR_POS_A]: 02
[AES_ACTIVE]: 00
[EVENT_DELAYTIME]: 00
}
}
VALUES
{
Channel: 8
{
[STATE]: 00
[LOWBAT]: 00
[ERROR]: 00
[INSTALL_TEST]: 00
}
Channel: 7
{
[STATE]: 00
[LOWBAT]: 00
[ERROR]: 00
[INSTALL_TEST]: 00
}
Channel: 6
{
[STATE]: c8
[LOWBAT]: 00
[ERROR]: 00
[INSTALL_TEST]: 00
}
Channel: 1
{
[WORKING]: 00
[STATE]: c8
[ON_TIME]: 00
[INHIBIT]: 00
[INSTALL_TEST]: 00
}
Channel: 0
{
[UNREACH]: 00
[CONFIG_PENDING]: 00
[STICKY_UNREACH]: 00
[AES_KEY]: 00
[LAST_PACKET_RECEIVED]: 63 a5 9f 0c
[RSSI_DEVICE]: 40
[RSSI_PEER]: 00
}
Channel: 2
{
[WORKING]: 00
[STATE]: c8
[ON_TIME]: 00
[INHIBIT]: 00
[INSTALL_TEST]: 00
}
Channel: 3
{
[WORKING]: 00
[STATE]: 00
[ON_TIME]: 00
[INHIBIT]: 00
[INSTALL_TEST]: 00
}
Channel: 4
{
[WORKING]: 00
[STATE]: 00
[ON_TIME]: 00
[INHIBIT]: 00
[INSTALL_TEST]: 00
}
Channel: 5
{
[STATE]: c8
[LOWBAT]: 00
[ERROR]: 00
[INSTALL_TEST]: 00
}
}
LINK
{
Channel: 8
{
Address: 0xf33101
{
Remote channel: 4
{
[PEER_NEEDS_BURST]: 00
[EXPECT_AES]: 00
}
}
}
Channel: 7
{
Address: 0xf33101
{
Remote channel: 3
{
[PEER_NEEDS_BURST]: 00
[EXPECT_AES]: 00
}
}
}
Channel: 2
{
Address: 0xf33101
{
Remote channel: 6
{
[SHORT_ON_TIME]: ff
[SHORT_ONDELAY_TIME]: 00
[SHORT_OFF_TIME_MODE]: 00
[SHORT_JT_ON]: 04
[UI_HINT]: 00
[SHORT_OFFDELAY_TIME]: 00
[SHORT_JT_ONDELAY]: 03
[SHORT_CT_ON]: 00
[SHORT_CT_OFFDELAY]: 00
[SHORT_OFF_TIME]: ff
[SHORT_CT_OFF]: 00
[SHORT_COND_VALUE_LO]: 32
[SHORT_JT_OFF]: 01
[SHORT_COND_VALUE_HI]: 64
[LONG_ON_TIME_MODE]: 00
[LONG_ON_TIME]: ff
[LONG_COND_VALUE_HI]: 64
[LONG_CT_OFFDELAY]: 00
[SHORT_CT_ONDELAY]: 00
[LONG_JT_ONDELAY]: 03
[LONG_CT_OFF]: 00
[LONG_CT_ONDELAY]: 00
[LONG_COND_VALUE_LO]: 32
[LONG_ACTION_TYPE]: 01
[SHORT_ACTION_TYPE]: 01
[LONG_ONDELAY_TIME]: 00
[LONG_JT_OFF]: 01
[LONG_MULTIEXECUTE]: 00
[SHORT_ON_TIME_MODE]: 00
[LONG_JT_OFFDELAY]: 06
[LONG_OFFDELAY_TIME]: 00
[LONG_OFF_TIME]: ff
[SHORT_JT_OFFDELAY]: 06
[LONG_CT_ON]: 00
[LONG_JT_ON]: 04
[LONG_OFF_TIME_MODE]: 00
}
}
}
Channel: 1
{
Address: 0xf33101
{
Remote channel: 5
{
[SHORT_ON_TIME]: ff
[SHORT_ONDELAY_TIME]: 00
[SHORT_OFF_TIME_MODE]: 00
[SHORT_JT_ON]: 04
[UI_HINT]: 00
[SHORT_OFFDELAY_TIME]: 00
[SHORT_JT_ONDELAY]: 03
[SHORT_CT_ON]: 00
[SHORT_CT_OFFDELAY]: 00
[SHORT_OFF_TIME]: ff
[SHORT_CT_OFF]: 00
[SHORT_COND_VALUE_LO]: 32
[SHORT_JT_OFF]: 01
[SHORT_COND_VALUE_HI]: 64
[LONG_ON_TIME_MODE]: 00
[LONG_ON_TIME]: ff
[LONG_COND_VALUE_HI]: 64
[LONG_CT_OFFDELAY]: 00
[SHORT_CT_ONDELAY]: 00
[LONG_JT_ONDELAY]: 03
[LONG_CT_OFF]: 00
[LONG_CT_ONDELAY]: 00
[LONG_COND_VALUE_LO]: 32
[LONG_ACTION_TYPE]: 01
[SHORT_ACTION_TYPE]: 01
[LONG_ONDELAY_TIME]: 00
[LONG_JT_OFF]: 01
[LONG_MULTIEXECUTE]: 00
[SHORT_ON_TIME_MODE]: 00
[LONG_JT_OFFDELAY]: 06
[LONG_OFFDELAY_TIME]: 00
[LONG_OFF_TIME]: ff
[SHORT_JT_OFFDELAY]: 06
[LONG_CT_ON]: 00
[LONG_JT_ON]: 04
[LONG_OFF_TIME_MODE]: 00
}
}
}
Channel: 3
{
Address: 0xf33101
{
Remote channel: 7
{
[SHORT_ON_TIME]: ff
[SHORT_ONDELAY_TIME]: 00
[SHORT_OFF_TIME_MODE]: 00
[SHORT_JT_ON]: 04
[UI_HINT]: 00
[SHORT_OFFDELAY_TIME]: 00
[SHORT_JT_ONDELAY]: 03
[SHORT_CT_ON]: 00
[SHORT_CT_OFFDELAY]: 00
[SHORT_OFF_TIME]: ff
[SHORT_CT_OFF]: 00
[SHORT_COND_VALUE_LO]: 32
[SHORT_JT_OFF]: 01
[SHORT_COND_VALUE_HI]: 64
[LONG_ON_TIME_MODE]: 00
[LONG_ON_TIME]: ff
[LONG_COND_VALUE_HI]: 64
[LONG_CT_OFFDELAY]: 00
[SHORT_CT_ONDELAY]: 00
[LONG_JT_ONDELAY]: 03
[LONG_CT_OFF]: 00
[LONG_CT_ONDELAY]: 00
[LONG_COND_VALUE_LO]: 32
[LONG_ACTION_TYPE]: 01
[SHORT_ACTION_TYPE]: 01
[LONG_ONDELAY_TIME]: 00
[LONG_JT_OFF]: 01
[LONG_MULTIEXECUTE]: 00
[SHORT_ON_TIME_MODE]: 00
[LONG_JT_OFFDELAY]: 06
[LONG_OFFDELAY_TIME]: 00
[LONG_OFF_TIME]: ff
[SHORT_JT_OFFDELAY]: 06
[LONG_CT_ON]: 00
[LONG_JT_ON]: 04
[LONG_OFF_TIME_MODE]: 00
}
}
}
Channel: 4
{
Address: 0xf33101
{
Remote channel: 8
{
[SHORT_ON_TIME]: ff
[SHORT_ONDELAY_TIME]: 00
[SHORT_OFF_TIME_MODE]: 00
[SHORT_JT_ON]: 04
[UI_HINT]: 00
[SHORT_OFFDELAY_TIME]: 00
[SHORT_JT_ONDELAY]: 03
[SHORT_CT_ON]: 00
[SHORT_CT_OFFDELAY]: 00
[SHORT_OFF_TIME]: ff
[SHORT_CT_OFF]: 00
[SHORT_COND_VALUE_LO]: 32
[SHORT_JT_OFF]: 01
[SHORT_COND_VALUE_HI]: 64
[LONG_ON_TIME_MODE]: 00
[LONG_ON_TIME]: ff
[LONG_COND_VALUE_HI]: 64
[LONG_CT_OFFDELAY]: 00
[SHORT_CT_ONDELAY]: 00
[LONG_JT_ONDELAY]: 03
[LONG_CT_OFF]: 00
[LONG_CT_ONDELAY]: 00
[LONG_COND_VALUE_LO]: 32
[LONG_ACTION_TYPE]: 01
[SHORT_ACTION_TYPE]: 01
[LONG_ONDELAY_TIME]: 00
[LONG_JT_OFF]: 01
[LONG_MULTIEXECUTE]: 00
[SHORT_ON_TIME_MODE]: 00
[LONG_JT_OFFDELAY]: 06
[LONG_OFFDELAY_TIME]: 00
[LONG_OFF_TIME]: ff
[SHORT_JT_OFFDELAY]: 06
[LONG_CT_ON]: 00
[LONG_JT_ON]: 04
[LONG_OFF_TIME_MODE]: 00
}
}
}
Channel: 5
{
Address: 0xf33101
{
Remote channel: 1
{
[PEER_NEEDS_BURST]: 00
[EXPECT_AES]: 00
}
}
}
Channel: 6
{
Address: 0xf33101
{
Remote channel: 2
{
[PEER_NEEDS_BURST]: 00
[EXPECT_AES]: 00
}
}
}
}
Code: Alles auswählen
Family 0 - peer 49> peers list
Channel: 8 Address: 0xf33101 Remote channel: 4 Serial number: Virtual: False
Channel: 7 Address: 0xf33101 Remote channel: 3 Serial number: Virtual: False
Channel: 2 Address: 0xf33101 Remote channel: 6 Serial number: Virtual: False
Channel: 1 Address: 0xf33101 Remote channel: 5 Serial number: Virtual: False
Channel: 3 Address: 0xf33101 Remote channel: 7 Serial number: Virtual: False
Channel: 4 Address: 0xf33101 Remote channel: 8 Serial number: Virtual: False
Channel: 5 Address: 0xf33101 Remote channel: 1 Serial number: Virtual: False
Channel: 6 Address: 0xf33101 Remote channel: 2 Serial number: Virtual: False