{"id":20989163,"url":"https://github.com/latchdevel/rc-switch-lib","last_synced_at":"2026-04-24T11:31:31.089Z","repository":{"id":239459228,"uuid":"799587944","full_name":"latchdevel/rc-switch-lib","owner":"latchdevel","description":"Adaptation of RCSwitch Arduino library to be used on any system to encode and decode RC codes","archived":false,"fork":false,"pushed_at":"2024-05-15T06:54:46.000Z","size":40,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T07:46:00.265Z","etag":null,"topics":["315mhz","433mhz","ask","ook","rc-switch","rcswitch","rcswitch-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/latchdevel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-12T15:34:21.000Z","updated_at":"2024-11-15T07:21:52.000Z","dependencies_parsed_at":"2024-11-19T06:40:23.634Z","dependency_job_id":null,"html_url":"https://github.com/latchdevel/rc-switch-lib","commit_stats":null,"previous_names":["latchdevel/rc-switch-lib"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Frc-switch-lib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Frc-switch-lib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Frc-switch-lib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2Frc-switch-lib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/latchdevel","download_url":"https://codeload.github.com/latchdevel/rc-switch-lib/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243401482,"owners_count":20285051,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["315mhz","433mhz","ask","ook","rc-switch","rcswitch","rcswitch-library"],"created_at":"2024-11-19T06:24:00.275Z","updated_at":"2025-12-29T12:09:13.865Z","avatar_url":"https://github.com/latchdevel.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RCSwitch Common Library\n\nAdaptation of [\"RCSwitch\"](https://github.com/sui77/rc-switch) Arduino library to be used on any system to encode and decode RC codes of supported protocols.\n\nWorks on any **libc++** compatible system, such as macOS, FreeBSD, Linux, and even Windows.\n\n[![License: LGPL v3](https://img.shields.io/badge/License-LGPL%20v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)\n[![Build tests](https://github.com/latchdevel/rc-switch-lib/actions/workflows/BuildTest.yml/badge.svg)](https://github.com/latchdevel/rc-switch-lib/actions/workflows/BuildTest.yml)\n\nOriginally developed for Arduino framework, it has been ported to Raspberry Pi using the WiringPi library.\n\nIts main use is to capture and reproduce operation codes of radio control devices like the popular low cost power outlet sockets, which works on the 315Mhz or 433MHz frequency in AM ASK/OOK modulation.\n\nIt supports only a few very basic protocols (up to 64 pulses):\n - SC5262 / SC5272\n - HX2262 / HX2272\n - PT2262 / PT2272\n - EV1527 / RT1527 / FP1527 / HS1527 \n - Intertechno outlets\n - HT6P20X\n\nThere are other similar projects that support a large number of protocols, including some very complex ones, with a large number of pulses, such as [**PiCode**](https://github.com/latchdevel/PiCode). However, RCSwitch is very popular for its simplicity and ease of use.\n\n## Usage\nRCSwitch Common Library is a C++ library built statically and dynamically on any **libc++** compatible system.\n\nIt implements the original RCSwitch class, simulating the transmissions and receptions of RC codes, exchanging objects of the [**std::list** class](https://en.cppreference.com/w/cpp/container/list) that store the pulse trains.\n\n```c++\ntypedef std::list\u003cunsigned int\u003e pulse_list_t;\n```\n\n### Encode\nYou can use any transmission RCSwitch class method to encode an RC code into a pulse train.\n\n```c++\n    pulse_list_t switchOn(int nGroupNumber, int nSwitchNumber);\n    pulse_list_t switchOff(int nGroupNumber, int nSwitchNumber);\n    pulse_list_t switchOn(const char* sGroup, int nSwitchNumber);\n    pulse_list_t switchOff(const char* sGroup, int nSwitchNumber);\n    pulse_list_t switchOn(char sFamily, int nGroup, int nDevice);\n    pulse_list_t switchOff(char sFamily, int nGroup, int nDevice);\n    pulse_list_t switchOn(const char* sGroup, const char* sDevice);\n    pulse_list_t switchOff(const char* sGroup, const char* sDevice);\n    pulse_list_t switchOn(char sGroup, int nDevice);\n    pulse_list_t switchOff(char sGroup, int nDevice);\n    pulse_list_t sendTriState(const char* sCodeWord);\n    pulse_list_t send(unsigned long code, unsigned int length);\n    pulse_list_t send(const char* sCodeWord);\n```\n\nAll related TX methods are functional:\n```c++\n    void setProtocol(int nProtocol);\n    void setPulseLength(uint16_t nPulseLength);\n    void setRepeatTransmit(int nRepeatTransmit);\n```\n\n### Decode\nTo decode a pulse train, a specific method has been added to the RCSwitch class that takes a pulse train as a parameter, simulating its reception as an AM ASK/OOK radio frequency receiver.\n```c++\n    bool decodePulseTrain(pulse_list_t);\n```\nReturns a bool indicating whether it was successfully decoded, and any case all related RX methods are functional:\n```c++\n    bool available();\n    void resetAvailable();\n    unsigned long getReceivedValue();\n    unsigned int getReceivedBitlength();\n    unsigned int getReceivedDelay();\n    unsigned int getReceivedProtocol();\n    unsigned int* getReceivedRawdata();\n    void setReceiveTolerance(int nPercent);\n```\n\n## BUILD\nNo external depends, can run on any libc++ compatible system, such as macOS, FreeBSD, Linux, and even Windows.\n\nRequires a **C++** compiler, **CMake** and **git** optionally. Debian linux based example: `apt install build-essential cmake git`\n\n ```\n    $ git clone https://github.com/latchdevel/rc-switch-lib (or download .zip)\n    $ cd rc-switch-lib\n    $ mkdir build\n    $ cd build\n    $ cmake .. (or \"cmake -DCMAKE_BUILD_TYPE=debug ..\" for debug)\n    $ make\n    $ make install (optional)\n    $ make uninstall (to uninstall)\n```\n\n### Output\nExample of use: `$ ./example`\n```\nEncoding: switchOn(\"11111\", \"00010\")\nraw_pulses[50]={350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,1050,350,350,1050,1050,350,350,1050,1050,350,350,1050,350,1050,350,1050,1050,350,350,1050,350,1050,350,1050,1050,350,350,10850};\nOK: decode value: 5393 (24 bits) Protocol: 1 Delay: 350\ndec_pulses[50]={350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,350,1050,1050,350,350,1050,1050,350,350,1050,1050,350,350,1050,350,1050,350,1050,1050,350,350,1050,350,1050,350,1050,1050,350,350,10850};\nOK: pulse lists match.\n```\n\n# License\nCopyright (c) 2011 Suat Özgür. All right reserved.\n\nCopyright (c) 2024 Jorge Rivera. All right reserved.\n\nLicense GNU Lesser General Public License v3.0.\n\nThis program is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 3 of the License, or (at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public License\nalong with this program; if not, write to the Free Software Foundation,\nInc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n\nSee the [LICENSE](LICENSE.txt) file for license rights and limitations (lgpl-3.0).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Frc-switch-lib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flatchdevel%2Frc-switch-lib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Frc-switch-lib/lists"}