{"id":14963482,"url":"https://github.com/blinker-iot/blinker-js","last_synced_at":"2025-05-14T01:04:10.745Z","repository":{"id":39978948,"uuid":"131698648","full_name":"blinker-iot/blinker-js","owner":"blinker-iot","description":"Blinker node.js library for hardware. Works with Raspberry Pi, Banana Pi, linux, windows, macos.","archived":false,"fork":false,"pushed_at":"2025-03-26T06:55:59.000Z","size":249,"stargazers_count":3578,"open_issues_count":4,"forks_count":11,"subscribers_count":5,"default_branch":"typescript","last_synced_at":"2025-04-03T08:51:23.715Z","etag":null,"topics":["iot","linux","mqtt","raspberry-pi","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/blinker-iot.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2018-05-01T09:59:11.000Z","updated_at":"2025-04-03T08:18:29.000Z","dependencies_parsed_at":"2024-11-19T17:35:53.303Z","dependency_job_id":"f40afdab-0188-43ec-a6a0-24cf17c9fb12","html_url":"https://github.com/blinker-iot/blinker-js","commit_stats":{"total_commits":164,"total_committers":5,"mean_commits":32.8,"dds":"0.35365853658536583","last_synced_commit":"f73b9dbeb63b05fc0b45eec9008f903bc4ece82f"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinker-iot%2Fblinker-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinker-iot%2Fblinker-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinker-iot%2Fblinker-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/blinker-iot%2Fblinker-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/blinker-iot","download_url":"https://codeload.github.com/blinker-iot/blinker-js/tar.gz/refs/heads/typescript","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248223828,"owners_count":21068069,"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":["iot","linux","mqtt","raspberry-pi","typescript"],"created_at":"2024-09-24T13:31:34.943Z","updated_at":"2025-04-10T13:06:44.824Z","avatar_url":"https://github.com/blinker-iot.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# blinker JavaScript/TypeScript SDK  \n\n本SDK可用于 **Linux/Windows/MacOS** 设备MQTT接入  \n**亦适用于树莓派等带操作系统的嵌入式设备**  \n\n使用WiFi接入，当设备和手机在同一个局域网中，为局域网通信  \n其余情况，使用MQTT远程通信  \n\n## 准备工作\n开始使用前您需要做好如下准备:  \n\n**下载并安装blinker APP**  \n**Android下载：**  \n[点击下载](https://github.com/blinker-iot/app-release/releases) 或 在android应用商店搜索“blinker”下载安装  \n**IOS下载：**  \n[点击下载](https://itunes.apple.com/cn/app/id1357907814) 或 在app store中搜索“blinker”下载  \n\n\n## 环境/依赖安装  \n运行blinker程序需要最新nodejs LTS版本及Ts-Node支持  \n```\nnpm i -g ts-node\ngit clone https://github.com/blinker-iot/blinker-js.git\ncd blinker-js\nnpm i\n```\n\n## 在app中添加设备，获取Secret Key  \n1. 进入App，点击右上角的“+”号，然后选择 **添加设备**    \n2. 点击选择**Arduino \u003e WiFi接入**  \n3. 复制申请到的**Secret Key**  \n\n## DIY界面  \n1. 在设备列表页，点击设备图标，进入设备控制面板  \n2. 首次进入设备控制面板，会弹出向导页\n3. 在向导页点击 **载入示例**，即可载入示例组件  \n   \n## 编译并上传示例程序 \n\n**.\\example\\example_hello.ts** 为入门示例， 替换示例中的以下语句，修改参数为app中申请到的设备的Secret Key  \n```\nlet device = new BlinkerDevice('xxxxxxxxxxxx');\n```\n运行示例程序：\n```\nts-node .\\example\\example_hello.ts\n```\n\n\u003e blinker在局域网通信时会使用到81端口，如遇到权限报错，请使用sudo等方式提权运行  \n\n## 恭喜！一切就绪  \n\n在APP中点击刚才您添加的设备，即可进入控制界面，点点按钮就可以控制设备了  \n另一个按钮也点下试试，放心，您的手机不会爆炸~  \n\n## 进一步使用blinker  \n\n#### 想了解各接入方式的区别？  \n看看[添加设备](?file=002-开发入门/001-添加设备 \"添加设备\")  \n\n#### 想深入理解以上例程？  \n\n看看[Nodejs开发入门](https://diandeng.tech/doc/getting-start-nodejs \"Nodejs开发入门\") 和 [JavaScript/TypeScript 支持库函数参考](https://diandeng.tech/doc/javascript-support)) \n#### 更多示例程序？  \n\n看看[Github](https://github.com/blinker-iot/blinker-js/tree/typescript/example)  \n\n#### 想制作与众不同的物联网设备？  \n看看[自定义界面](https://diandeng.tech/doc/layouter-2)  \n\n#### 树莓派GPIO控制？  \n看看[pigpio](https://github.com/fivdi/pigpio)  \n\n## 完整示例程序  \n\n\n```javascript\nimport { BlinkerDevice } from '../lib/blinker';\nimport { ButtonWidget, NumberWidget } from '../lib/widget';\n\nlet device = new BlinkerDevice(/*您申请到的Secret Key*/);\n\n// 注册组件\nlet button1: ButtonWidget = device.addWidget(new ButtonWidget('btn-123'));\nlet button2: ButtonWidget = device.addWidget(new ButtonWidget('btn-abc'));\nlet number1: NumberWidget = device.addWidget(new NumberWidget('num-abc'));\n\nlet num = 0;\n\ndevice.ready().then(() =\u003e {\n\n    device.dataRead.subscribe(message =\u003e {\n        console.log('otherData:', message);\n    })\n\n    button1.listen().subscribe(message =\u003e {\n        console.log('button1:', message.data);\n        num++;\n        number1.value(num).update();\n    })\n\n    button2.listen().subscribe(message =\u003e {\n        console.log('button2:', message.data);\n        // 其他控制代码\n    })\n\n})\n```\n\n## 为什么设备显示不在线？  \n\n0. blinker App如何判断设备是否在线？  \n\nblinker App在 **App打开时、进入设备页面时、在设备页面中每隔一定时间** 会向设备发送心跳请求，内容为**{\"get\":\"state\"}**。  \n设备收到请求后，会返回 **{\"state\":\"online\"}**，app接收到这个返回，即会显示设备在线。  \n\n1. 程序没有成功上传到开发板  \n\n解决办法：重新上传，上传后打开串口监视器，确认程序正确运行  \n\n2. 程序中没有设置正确的ssid和密码，导致没有连接上网络  \n\n解决办法：设置后再重新上传程序，上传后打开串口监视器，确认程序正确运行  \n\n3. 程序错误，导致程序运行不正确  \n\n解决办法：先使用并理解blinker例程，再自由发挥  \n\n4. 开发板供电不足   \n\n解决办法：换电源 或 换USB口  \n\n## 为什么无法切换到局域网通信？  \n\n1. 路由器开启了AP隔离功能或禁止了UDP通信，从而阻止了局域网中设备的发现和通信  \n\n解决办法：关闭路由器AP隔离功能 或 允许UDP通信；如果找不到相关设置，通常可重置路由器解决  \n\n2. mdns没有及时发现设备  \n\n解决办法：在首页下拉刷新，可以重新搜索局域网中的设备  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblinker-iot%2Fblinker-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fblinker-iot%2Fblinker-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fblinker-iot%2Fblinker-js/lists"}