{"id":15175373,"url":"https://github.com/siva7170/ble-connection","last_synced_at":"2026-03-09T13:06:35.371Z","repository":{"id":227093978,"uuid":"770476083","full_name":"siva7170/ble-connection","owner":"siva7170","description":"Node.js Bluetooth SPP communication for Windows","archived":false,"fork":false,"pushed_at":"2025-05-03T12:18:05.000Z","size":786,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-06T14:24:05.305Z","etag":null,"topics":["bluetooth","bluetooth-spp","electronjs","node-js","rfcomm","rfcomm-client","serial-port-profile","windows"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/siva7170.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-03-11T16:08:13.000Z","updated_at":"2025-11-02T10:15:32.000Z","dependencies_parsed_at":"2025-05-20T00:33:03.907Z","dependency_job_id":"2fc041a0-8f28-4a80-8221-5217d6ee7fa1","html_url":"https://github.com/siva7170/ble-connection","commit_stats":{"total_commits":8,"total_committers":1,"mean_commits":8.0,"dds":0.0,"last_synced_commit":"e5ab3ca20e014571a29ade5c3b1289f492b2a26f"},"previous_names":["siva7170/ble-connection"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/siva7170/ble-connection","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siva7170%2Fble-connection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siva7170%2Fble-connection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siva7170%2Fble-connection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siva7170%2Fble-connection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/siva7170","download_url":"https://codeload.github.com/siva7170/ble-connection/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/siva7170%2Fble-connection/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30297111,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-09T11:12:22.024Z","status":"ssl_error","status_checked_at":"2026-03-09T11:10:54.577Z","response_time":61,"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":["bluetooth","bluetooth-spp","electronjs","node-js","rfcomm","rfcomm-client","serial-port-profile","windows"],"created_at":"2024-09-27T12:23:27.996Z","updated_at":"2026-03-09T13:06:30.354Z","avatar_url":"https://github.com/siva7170.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bluetooth SPP\n\nThis is a node addon api package used for connecting other bluetooth through Bluethooth SPP. IMPORTANT! It supports for Windows platform. Now, we can use it as server and client.\n\n## Getting Started\n\nThis library is developed in C++ and support for Node.js.\n\n### Installation\n\nInstall this package into your project by below command\n\n```\nnpm install @siva7170/ble-connection\n```\n\n## Usage\n\nBelow code is sample for how to use it. Please see methods and its functionalities below sections.\n\n```javascript\nconst bleConnection = require('@siva7170/ble-connection');\n\nconst bleConnInstance = new bleConnection.BLEConnection();\n```\n\n## Client Methods\n\n### Initiate(successCallback,failureCallback)\n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n\nIt initializes the necessary things.\n\n```javascript\nbleConnInstance.Initiate(()=\u003e{\n\tconsole.log(\"Initiated!\");\n\t// rest of the code\n},()=\u003e{\n\tconsole.log(\"Failed to initiate!\");\n});\n```\n\n### Connect(bluetooth_addr, uuid, successCallback,failureCallback)\n\n- **bluetooth_addr**:\n  - Type: `String`\n\n- **uuid**:\n  - Type: `String`\n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n\nThis method will try to connect to the given bluetooth address and uuid from bluetooth spp server.\n\n```javascript\n// please use valid bluetooth address and UUID\nbleConnInstance.Connect(\"00:00:00:00:00:E0\",\"aaaaaaaa-aaaa-4444-cccc-999888999888\",()=\u003e{\n\tconsole.log(\"Connected!\");\n    // rest of the code\n},()=\u003e{\n\tconsole.log(\"Failed to connect!\");\n});\n```\n\n### SendData(data, successCallback, failureCallback) (optional)\n\n- **data**:\n  - Type: `String`\n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n  \nWith this method, you can send data to client\n\n```javascript\nbleConnInstance.SendData('Hi server!',(res)=\u003e{\n\tconsole.log(\"Data sent: \"+sData);\n}, (err)=\u003e{\n\n});\n```\n\n### OnReceiveData(onDataRecvCallback)\n\n- **onDataRecvCallback**:\n  - Type: `Function`\n\nThis method will be triggered when the data sent from bluetooth server\n\n```javascript\nbleConnInstance.OnReceiveData((data)=\u003e{\n\tconsole.log(\"Data receivedd: \"+data);\n});\n```\n\n## Full Example\n  \nPlease find full example of implementation\n\n```javascript\nconst bleConnection = require('@siva7170/ble-connection');\n\nconst bleConnInstance = new bleConnection.BLEConnection();\n\ntry{\n    bleConnInstance.Initiate(()=\u003e{\n        console.log(\"Initiated!\");\n\n        bleConnInstance.Connect(\"00:00:00:00:00:E0\",\"aaaaaaaa-aaaa-4444-cccc-999888999888\",()=\u003e{\n            console.log(\"Connected!\");\n            let sData=\"Hi client\";\n            bleConnInstance.SendData(sData,(res)=\u003e{\n                console.log(\"Data sent: \"+sData);\n            }, (err)=\u003e{\n\n            });\n\n            bleConnInstance.OnReceiveData((data)=\u003e{\n                console.log(\"Data receivedd: \"+data);\n            });\n            \n            sData=\"How are you?\";\n            bleConnInstance.SendData(sData,(res)=\u003e{\n                console.log(\"Data sent: \"+sData);\n            }, (err)=\u003e{\n\n            });\n        },()=\u003e{\n            console.log(\"Failed to connect!\");\n        });\n    },()=\u003e{\n        console.log(\"Failed to initiate!\");\n    });\n}catch(e){\n    console.error(e.toString());\n}\n```\n\n\n# Version 2\n\n\n## Client Usage\n\nBelow code is sample for how to use it. Please see methods and its functionalities below sections.\n\n```javascript\nconst bleConnection = require('@siva7170/ble-connection');\n\nconst bleConnInstance = new bleConnection.BLEConnection();\n```\n\n## Methods\n\n### SetBtInfo(bluetooth_addr, uuid, timeout_for_reconnect, no_of_attempt_to_reconnect)\n\n- **bluetooth_addr**:\n  - Type: `String`\n\n- **uuid**:\n  - Type: `String`\n\n- **timeout_for_reconnect**:\n  - Type: `Integer`\n\n- **no_of_attempt_to_reconnect**:\n  - Type: `Integer`\n\nIt sets necessary things to BLE Connection before it initialize. \n\n```javascript\nbleConnInstance.SetBtInfo(\"00:00:00:00:00:E0\",\"aaaaaaaa-aaaa-4444-cccc-999888999888\",5000,0);\n```\n\n### GetStatus(statusCallback) (optional)\n\n- **statusCallback**:\n  - Type: `Function`\n\nThis method will give current state of BLE Connection when it is changed from one to another.\n\n```javascript\nbleConnInstance.GetStatus((res)=\u003e{\n  console.log(\"Status: \"+res);\n});\n```\n\n### MakeConnection(successCallback, failureCallback) \n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n  \nIt will make connection to device which is defined in SetBtInfo()\n\n```javascript\nbleConnInstance.MakeConnection(()=\u003e{\n    console.log(\"Connected...!\");\n},\n()=\u003e{\n    console.log(\"Failed to connect!\");\n});\n```\n\n### IsConnected(successCallback, failureCallback) (optional)\n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n\nThis method will be triggered when connection made to Bluetooth Server.\n\n```javascript\n    bleConnInstance.IsConnected(()=\u003e{\n        console.log(\"Connection status: Connected!\");\n    },\n    ()=\u003e{\n        console.log(\"Failed to connect!\");\n    });\n```\n\n### SendDataToServer(data, successCallback, failureCallback) (optional)\n\n- **data**:\n  - Type: `String`\n\n- **successCallback**:\n  - Type: `Function`\n\n- **failureCallback**:\n  - Type: `Function`\n  \nWith this method, you can send data to client\n\n```javascript\nbleConnInstance.SendDataToServer('Hi server!',(res)=\u003e{\n\tconsole.log(\"Data sent: \"+sData);\n}, (err)=\u003e{\n\n});\n```\n\n### OnReceiveDataFromServer(onDataRecvCallback)\n\n- **onDataRecvCallback**:\n  - Type: `Function`\n\nThis method will be triggered when the data sent from bluetooth server\n\n```javascript\nbleConnInstance.OnReceiveDataFromServer((data)=\u003e{\n\tconsole.log(\"Data receivedd: \"+data);\n});\n```\n\n\n## Full Example\n  \nPlease find full example of implementation\n\n```javascript\nconst bleConnection = require('@siva7170/ble-connection');\n\nconst bleConnInstance = new bleConnection.BLEConnection();\n\ntry{\n    bleConnInstance.SetBtInfo(\"00:00:00:00:00:E0\",\"aaaaaaaa-aaaa-4444-cccc-999888999888\",5000,0);\n\n    \n    bleConnInstance.GetStatus((res)=\u003e{\n        console.log(\"Status: \"+res);\n    });\n\n\n    bleConnInstance.MakeConnection(()=\u003e{\n        console.log(\"Connected...!\");\n    },\n    ()=\u003e{\n        console.log(\"Failed to connect!\");\n    });\n\n    bleConnInstance.IsConnected(()=\u003e{\n        console.log(\"Connection status: Connected!\");\n\n       // INITIATE\n      bleConnInstance.SendDataToServer(\"INITIATE\",(res)=\u003e{\n        console.log(\"Initiating...!\");\n      }, (err)=\u003e{\n\n      });\n\n      bleConnInstance.OnReceiveDataFromServer((data)=\u003e{\n        bleConnInstance.SendDataToServer(\"READY_SCAN\",(res)=\u003e{\n          console.log(\"Ready scan...!\");\n        }, (err)=\u003e{\n                    \n        });\n      });\n    },\n    ()=\u003e{\n        console.log(\"Failed to connect!\");\n    });\n\n}catch(e){\n    console.error(e.toString());\n}\n```\n\n\n## Server Usage\n\nBelow code is sample for how to use it. Please see methods and its functionalities below sections.\n\n```javascript\nconst bleConnection = require('@siva7170/ble-connection');\n\nconst bleServerInstance = new bleConnection.BLEServer();\n```\n\n## Methods\n\n### Initiate()\n\nIt sets necessary things to BLE Server before it initialize. \n\n```javascript\nbleServerInstance.Initiate();\n```\n\n### StartServer(serviceName)\n\n- **serviceName**:\n  - Type: `String`\n\nThis method will start the Bluetooth SPP server.\n\n```javascript\nbleServerInstance.StartServer(serviceName);\n```\n\n### StopServer()\n\nThis method will stop the Bluetooth SPP server.\n\n```javascript\nbleServerInstance.StopServer();\n```\n\n### OnData(dataCallback) \n\n- **dataCallback**:\n  - Type: `Function`\n  \nIt will call the data callback when new data received from client.\n\n```javascript\nbleServerInstance.OnData((data)=\u003e{\n    console.log(\"Data\u003e\",data);\n});\n```\n\n\n### SendData(data) \n\n- **data**:\n  - Type: `String`\n  \nIt will send data to client.\n\n```javascript\nbleServerInstance.SendData(\"Hello!\");\n```\n\n### OnClientConnected(callback) (optional)\n\n- **callback**:\n  - Type: `Function`\n\nThis method will be triggered when connection made to Bluetooth Client.\n\n```javascript\n    bleServerInstance.OnClientConnected(()=\u003e{\n        console.log(\"Connected!\");\n    });\n```\n\n### OnClientDisconnected(callback) (optional)\n\n- **callback**:\n  - Type: `Function`\n\nThis method will be triggered when connection lost with Bluetooth Client.\n\n```javascript\n    bleServerInstance.OnClientDisconnected(()=\u003e{\n        console.log(\"Disconnected!\");\n    });\n```\n\n## Full Example\n  \nPlease find full example of implementation\n\n```javascript\n// Please refer  \"./test/server.js\"\n```\n\n## TODO\n\n- [x] Bluetooth SPP Client (Windows)\n- [ ] Bluetooth SPP Client (Other platform)\n- [x] Bluetooth SPP Server (Windows)\n- [ ] Bluetooth SPP Server (Other platform)\n- [ ] Modify all code more efficient\n\n## Contribution\n\nI created this package for my own usage. I welcome contribution for this package improvement.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiva7170%2Fble-connection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsiva7170%2Fble-connection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsiva7170%2Fble-connection/lists"}