Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from loetmeister/master
new device HBW-DIS-Key-4 and some clean-up
- Loading branch information
Showing
33 changed files
with
2,394 additions
and
208 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
** HBWLinkKeyInfoEventSensor | ||
** | ||
** Einfache direkte Verknuepfung (Peering), vom Sensor ausgehend | ||
** Ein Link-Objekt steht immer fuer alle (direkt aufeinander folgenden) Verknuepfungen | ||
** des entsprechenden Typs. | ||
** | ||
*/ | ||
|
||
|
||
#include "HBWLinkKeyInfoEventSensor.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
** HBWLinkKeyInfoEventSensor | ||
** | ||
** Einfache direkte Verknuepfung (Peering), vom Sensor ausgehend | ||
** Ein Link-Objekt steht immer fuer alle (direkt aufeinander folgenden) Verknuepfungen | ||
** des entsprechenden Typs. | ||
** | ||
*/ | ||
|
||
// TODO: remove these files and add option to the lib, allowing to combine different LinkSender | ||
|
||
#ifndef HBWLinkKeyInfoEventSensor_h | ||
#define HBWLinkKeyInfoEventSensor_h | ||
|
||
#include "HBWired.h" | ||
|
||
|
||
template<uint8_t numLinks, uint16_t eepromStart> | ||
class HBWLinkKeyInfoEventSensor : public HBWLinkSender { | ||
public: | ||
HBWLinkKeyInfoEventSensor(); | ||
void sendInfoEvent(HBWDevice* device, uint8_t srcChan, uint8_t length, uint8_t const * const data); | ||
void sendKeyEvent(HBWDevice* device, uint8_t srcChan, uint8_t keyPressNum, boolean longPress); | ||
private: | ||
static const uint8_t EEPROM_SIZE = 6; // "address_step" in XML | ||
}; | ||
|
||
#include "HBWLinkKeyInfoEventSensor.hpp" | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* | ||
** HBWLinkKeyInfoEventSensor | ||
** | ||
** Einfache direkte Verknuepfung (Peering), vom Sensor ausgehend | ||
** Ein Link-Objekt steht immer fuer alle (direkt aufeinander folgenden) Verknuepfungen | ||
** des entsprechenden Typs. | ||
** | ||
*/ | ||
|
||
|
||
#ifdef Support_HBWLink_InfoEvent | ||
template<uint8_t numLinks, uint16_t eepromStart> | ||
HBWLinkKeyInfoEventSensor<numLinks, eepromStart>::HBWLinkKeyInfoEventSensor() { | ||
} | ||
|
||
|
||
// TODO: Der Beginn aller Verknuepfungen ist gleich. Eigentlich koennte man | ||
// das meiste in einer gemeinsamen Basisklasse abhandeln | ||
template<uint8_t numLinks, uint16_t eepromStart> | ||
void HBWLinkKeyInfoEventSensor<numLinks, eepromStart>::sendInfoEvent(HBWDevice* device, uint8_t srcChan, | ||
uint8_t length, uint8_t const * const data) { | ||
uint8_t channelEEPROM; | ||
uint32_t addrEEPROM; | ||
// care for peerings | ||
for(int i = 0; i < numLinks; i++) { | ||
// get channel number | ||
device->readEEPROM(&channelEEPROM, eepromStart + EEPROM_SIZE * i, 1); | ||
// valid peering? | ||
// TODO: Really like that? This always goes through all possible peerings | ||
if(channelEEPROM == 0xFF) continue; | ||
// channel is key? | ||
if(channelEEPROM != srcChan) continue; | ||
// get address and channel of actuator | ||
device->readEEPROM(&addrEEPROM, eepromStart + EEPROM_SIZE * i + 1, 4, true); | ||
device->readEEPROM(&channelEEPROM, eepromStart + EEPROM_SIZE * i +5, 1); | ||
// own address? -> internal peering | ||
if(addrEEPROM == device->getOwnAddress()) { | ||
device->receiveInfoEvent(addrEEPROM, srcChan, channelEEPROM, length, data); | ||
}else{ | ||
// external peering | ||
// TODO: If bus busy, then try to repeat. ...aber zuerst feststellen, wie das die Original-Module machen (bzw. hier einfach so lassen) | ||
/* byte result = */ | ||
device->sendInfoEvent(srcChan, length, data, addrEEPROM, channelEEPROM, !NEED_IDLE_BUS, 1); // free/idle bus was checked before calling sendInfoEvent. Send peer message only once | ||
}; | ||
}; | ||
} | ||
|
||
template<uint8_t numLinks, uint16_t eepromStart> | ||
void HBWLinkKeyInfoEventSensor<numLinks, eepromStart>::sendKeyEvent(HBWDevice* device, uint8_t srcChan, | ||
uint8_t keyPressNum, boolean longPress) { | ||
uint8_t channelEEPROM; | ||
uint32_t addrEEPROM; | ||
// care for peerings | ||
for(int i = 0; i < numLinks; i++) { | ||
// get channel number | ||
device->readEEPROM(&channelEEPROM, eepromStart + EEPROM_SIZE * i, 1); | ||
// valid peering? | ||
// TODO: Really like that? This always goes through all possible peerings | ||
if(channelEEPROM == 0xFF) continue; | ||
// channel is key? | ||
if(channelEEPROM != srcChan) continue; | ||
// get address and channel of actuator | ||
device->readEEPROM(&addrEEPROM, eepromStart + EEPROM_SIZE * i + 1, 4, true); | ||
device->readEEPROM(&channelEEPROM, eepromStart + EEPROM_SIZE * i +5, 1); | ||
// own address? -> internal peering | ||
if(addrEEPROM == device->getOwnAddress()) { | ||
device->receiveKeyEvent(addrEEPROM, srcChan, channelEEPROM, keyPressNum, longPress); | ||
}else{ | ||
// external peering | ||
// TODO: If bus busy, then try to repeat. ...aber zuerst feststellen, wie das die Original-Module machen (bzw. hier einfach so lassen) | ||
/* byte result = */ | ||
device->sendKeyEvent(srcChan, keyPressNum, longPress, addrEEPROM, channelEEPROM, !NEED_IDLE_BUS, 1); // free/idle bus was checked before calling sendKeyEvent - by broadcast message. Send peer message only once | ||
}; | ||
}; | ||
} | ||
#endif |
Oops, something went wrong.