Skip to content

Commit

Permalink
Added sendCommandWithCode method
Browse files Browse the repository at this point in the history
* Added sendCommandWithCode to enable use of custom rollingCode storage
  • Loading branch information
Mirdinus authored and Legion2 committed Jul 11, 2023
1 parent 36681e0 commit 50a440a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ Currently, there are two implementations of the storage available:

Most [examples](examples/) use the EEPROM implementation. See the [ESP32-NVS](examples/ESP32-NVS/ESP32-NVS.ino) example for NVS.

Eventually you can pass NULL into the constructor of the SomfyRemote class in place of *rollingCodeStorage* and use external rolling code keeping logic.
If you are not using any storage, then you have to use `sendCommandWithCode` method instead of `sendCommand`.

#### Available commands

| Name | Description | HEX code |
Expand Down
4 changes: 4 additions & 0 deletions src/SomfyRemote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ void SomfyRemote::setup() {

void SomfyRemote::sendCommand(Command command, int repeat) {
const uint16_t rollingCode = rollingCodeStorage->nextCode();
sendCommandWithCode(command, repeat, rollingCode);
}

void SomfyRemote::sendCommandWithCode(Command command, uint16_t rollingCode, int repeat) {
byte frame[7];
buildFrame(frame, command, rollingCode);
sendFrame(frame, 2);
Expand Down
9 changes: 9 additions & 0 deletions src/SomfyRemote.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ class SomfyRemote {
* only be used when simulating holding a button.
*/
void sendCommand(Command command, int repeat = 4);
/**
* Send a command with this SomfyRemote.
*
* @param command the command to send
* @param rollingCode the rolling code to use. Should only be used with external storage.
* @param repeat the number how often the command should be repeated, default 4. Should
* only be used when simulating holding a button.
*/
void sendCommandWithCode(Command command, uint16_t rollingCode, int repeat = 4);
};

Command getSomfyCommand(const String &string);

0 comments on commit 50a440a

Please sign in to comment.