{"id":20989183,"url":"https://github.com/latchdevel/picode","last_synced_at":"2026-02-17T00:31:05.287Z","repository":{"id":47547634,"uuid":"347482081","full_name":"latchdevel/PiCode","owner":"latchdevel","description":"C/C++ library to manage OOK protocols supported \"pilight\" project","archived":false,"fork":false,"pushed_at":"2024-10-03T16:07:42.000Z","size":188,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-09T12:05:34.792Z","etag":null,"topics":["315mhz","433mhz","ask","espilight","ook","picode","pilight","rc-switch","weather-station"],"latest_commit_sha":null,"homepage":"https://manual.pilight.org/protocols/433.92/index.html","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,"zenodo":null}},"created_at":"2021-03-13T21:25:55.000Z","updated_at":"2024-10-03T16:07:46.000Z","dependencies_parsed_at":"2025-04-12T04:23:21.430Z","dependency_job_id":null,"html_url":"https://github.com/latchdevel/PiCode","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/latchdevel/PiCode","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FPiCode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FPiCode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FPiCode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FPiCode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/latchdevel","download_url":"https://codeload.github.com/latchdevel/PiCode/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/latchdevel%2FPiCode/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29526640,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T21:45:09.491Z","status":"ssl_error","status_checked_at":"2026-02-16T21:44:58.452Z","response_time":115,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","espilight","ook","picode","pilight","rc-switch","weather-station"],"created_at":"2024-11-19T06:24:03.591Z","updated_at":"2026-02-17T00:31:05.264Z","avatar_url":"https://github.com/latchdevel.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PiCode Library\n\nC/C++ library to manage OOK protocols supported by [**\"pilight\"**](https://github.com/pilight/pilight) project.\n\nWorks on any libc/libc++ compatible system, like macOS, FreeBSD, Linux, 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/PiCode/actions/workflows/BuildTest.yml/badge.svg)](https://github.com/latchdevel/PiCode/actions/workflows/BuildTest.yml)\n\nA large number of wireless protocols of RC switches and weather stations using the 433/315Mhz radio frequency band via ASK/OOK pulse modulation are implemented by the excellent work of the \"pilight\" community. A list of supported protocols can be found in the pilight manual: https://manual.pilight.org/protocols/433.92/index.html\n\nInspired by [**\"ESPiLight\"**](https://github.com/puuu/ESPiLight) project, provides a standard C++ class to should help to implement IoT bridges between the RF 433/315MHz band and internet protocols.\n\nThe \"pilight\" project defines a special string format to easily transcribe an OOK pulse train, in order to be able to exchange it with other systems, such as a remote RF receiver/transmitter.\n\npilight string format: `c: \u003cpulses_index\u003e ; p: \u003cpulse_0_lenght\u003e, \u003cpulse_1_lenght\u003e, ... \u003cpulse_n_lenght\u003e [;r:\u003crepeats\u003e] @`\n\npilight string example: `c:001010101100101010101010101010110010101102;p:700,1400,7650;r:5@`\n\nThe main features are to encode and decode the pilight strings.\nWhen decoding a pilight string is successful, a json array is returned containing the protocol matches, as sometimes decoded string matches more than one protocol.\n\npilight string: `c:010002000200020002000200020002000200020002000200020002000200020002000200020002020000020200020002000002000200020200000200020002000203;p:315,2835,1260,10710@`\n\ndecode as:\n```json\n{\n  \"protocols\": [\n    {\n      \"arctech_contact\": {\n        \"id\": 92,\n        \"unit\": 0,\n        \"state\": \"opened\"\n      }\n    },\n    {\n      \"arctech_dimmer\": {\n        \"id\": 92,\n        \"unit\": 0,\n        \"state\": \"on\"\n      }\n    },\n    {\n      \"arctech_screen\": {\n        \"id\": 92,\n        \"unit\": 0,\n        \"state\": \"up\"\n      }\n    },\n    {\n      \"arctech_switch\": {\n        \"id\": 92,\n        \"unit\": 0,\n        \"state\": \"on\"\n      }\n    },\n    {\n      \"smartwares_switch\": {\n        \"id\": 92,\n        \"unit\": 0,\n        \"state\": \"on\"\n      }\n    }\n  ]\n}\n```\n\nTo encode to pilight string, you must provide the protocol and custom parameters of that protocol in json format.\n\nExample: `{\"arctech_switch\":{\"id\":92,\"unit\":0,\"on\":1}}`\n\n\n## BUILD\nNo external depends, can run on any libc/libc++ compatible system, like macOS, FreeBSD, Linux, even Windows.\n ```\n    $ git clone https://github.com/latchdevel/PiCode (or download .zip)\n    $ cd PiCode\n    $ mkdir build\n    $ cd build\n    $ cmake .. (or \"cmake -DCMAKE_BUILD_TYPE=debug ..\" for debug)\n    $ make\n    $ make install (optional)\n    # make picode_example (optional C++ example)\n    # make cpicode_example (optional C example)\n    $ make uninstall (to uninstall)\n```\n\n\n## C example\n```c\n/*  \n    Example of using the pure C PiCode Library \n    \n    https://github.com/latchdevel/PiCode\n\n    Copyright (c) 2021 Jorge Rivera. All right reserved.\n    License GNU Lesser General Public License v3.0.\n\n*/\n\n#include \u003cstdio.h\u003e          /* printf()              */\n#include \u003cstdlib.h\u003e         /* free(), uint8_t       */\n\n#include \"src/cPiCode.h\"    /* Pure C PiCode library */\n\nint main(){\n\n    int result = 0;\n\n    printf(\"cpicode_example (%s)\\n\", STRINGIFY(BUILD_VERSION));\n    printf(\"Compiled at \" __DATE__ \" \" __TIME__ \" %s (%s)\\n\",STRINGIFY(BUILD_COMPILER), BUILD_TYPE );\n\n    /* Get PiCode library version */\n\n    char* library_version = getPiCodeVersion();\n\n    if (library_version){\n        printf(\"PiCode library version: %s\\n\", library_version);\n        free(library_version);\n    }else{\n        printf(\"ERROR: Unable to get PiCode library version.\\n\");\n        result--;\n    }\n\n    printf(\"\\n\");\n\n    /* Decode from pilight string */\n\n    char* pilight_string = (char*) \"c:011010100101011010100110101001100110010101100110101010101010101012;p:1400,600,6800@\";\n\n    char* decoded_string = decodeString(pilight_string);\n\n    printf(\"String to decode: \\\"%s\\\"\\n\",pilight_string);\n\n    if (decoded_string){\n\n        printf(\"Decode string successful:\\n\");\n        printf(\"%s\\n\",decoded_string);\n\n        free(decoded_string);\n    \n    }else{\n        printf(\"ERROR: Unable to decode string.\\n\");\n        result--;\n    }\n\n    /* Encode to pilight string from json */\n\n    char*   json    = (char*) \"{ 'arctech_switch' : { 'id': 92, 'unit': 0, 'on': 1 }}\";\n    uint8_t repeats = 5;\n\n    char* encoded_json_string = encodeJson(json,repeats);\n\n    printf(\"\\nJSON to encode: \\\"%s\\\"\\n\",json);\n\n    if (encoded_json_string){\n\n        printf(\"Encode successful:\\n\");\n        printf(\"%s\\n\",encoded_json_string);\n\n        free(encoded_json_string);\n    \n    }else{\n        printf(\"ERROR: Unable to encode JSON.\\n\");\n        result--;\n    }\n\n    /* Encode from protocol name and json data to array of pulses if success */\n\n    char* protocol_name = (char*) \"arctech_switch\";\n    char* json_data     = (char*) \"{'id': 92, 'unit': 0, 'on': 1}\";\n\n    uint32_t*   pulses     = NULL;\n    uint16_t  n_pulses_max = 0;\n    int       n_pulses     = 0;\n\n    n_pulses_max = protocol_maxrawlen();\n\n    pulses = (uint32_t*)malloc(sizeof *pulses * (n_pulses_max + 1));\n\n    if (pulses != NULL){\n\n        printf(\"\\nEncode protocol: \\\"%s\\\" JSON data: \\\"%s\\\"\\n\",protocol_name,json_data);\n        \n        n_pulses = encodeToPulseTrainByName(pulses, n_pulses_max, protocol_name, json_data);\n\n        if (n_pulses\u003e0){\n            printf(\"Encode successful:\\n\");\n            printf(\"pulses[%d]={\",n_pulses);\n            for (int i = 0; i\u003cn_pulses; i++){\n                printf(\"%d\",pulses[i]);\n                if (i\u003cn_pulses-1){\n                    printf(\",\");\n                }else{\n                    printf(\"};\\n\");\n                }\n            }\n        }else{\n            printf(\"ERROR: Unable to encode (%i)\\n\",n_pulses);\n        }\n        free(pulses);\n    }else{\n        printf(\"ERROR: out of memory (%d)) \\n\",n_pulses_max);\n        result--;\n    }\n\n    printf(\"\\n\");\n    return result;\n}\n```\n\n## Output\n```\npicode_example (539485e)\nCompiled at Oct  6 2022 23:10:26 AppleClang 13.0.0.13000029 (Release)\nPiCode library version: v1.4-539485e\n\nString to decode: \"c:011010100101011010100110101001100110010101100110101010101010101012;p:1400,600,6800@\"\nDecode string successful:\n{\n   \"protocols\": [{\n      \"conrad_rsl_switch\": {\n         \"id\": 1,\n         \"unit\": 2,\n         \"state\": \"on\"\n      }\n   }]\n}\n\nJSON to encode: \"{ 'arctech_switch' : { 'id': 92, 'unit': 0, 'on': 1 }}\"\nEncode successful:\nc:010002000200020002000200020002000200020002000200020002000200020002000200020002020000020200020002000002000200020200000200020002000203;p:315,2835,1260,10710;r:5@\n\nEncode protocol: \"arctech_switch\" JSON data: \"{'id': 92, 'unit': 0, 'on': 1}\"\nEncode successful:\npulses[132]={315,2835,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,1260,315,315,315,315,315,1260,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,1260,315,315,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,315,315,1260,315,10710};\n```\n\n# License\nCopyright (c) 2021-2022 Jorge Rivera. All right reserved.\n\nLicense GNU Lesser General Public License v3.0.\n\nThis library 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 library 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 library; if not, write to the Free Software Foundation, \nInc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA.\n\nSee the [LICENSE](LICENSE.md) file for license rights and limitations (lgpl-3.0).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fpicode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flatchdevel%2Fpicode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flatchdevel%2Fpicode/lists"}