• Stars
    star
    195
  • Rank 199,374 (Top 4 %)
  • Language
    C++
  • License
    Other
  • Created over 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

🔷😬Bluetooth serial port communication for Node.js

node-bluetooth NPM version

Bluetooth serial port communication for Node.js

Requirements

This package require node-gyp installed .

Linux

You'll need libbluetooth-dev. On Ubuntu/Debian : $ sudo apt-get install libbluetooth-dev

Installation

$ npm install node-bluetooth --save

Example

create device

const bluetooth = require('node-bluetooth');

// create bluetooth device instance
const device = new bluetooth.DeviceINQ();

list already paired devices

device.listPairedDevices(console.log);

will output

  node-bluetooth git:(master)  node example/index.js
[ { name: 'Lsong’s Trackpad',
    address: 'd0-a6-37-f1-e7-87',
    services: [ [Object], [Object] ] },
  { name: 'Lsong’s iPhone',
    address: 'dc-2b-2a-82-76-29',
    services: [ [Object], [Object], [Object], [Object] ] },
  { name: 'Lsong’s Keyboard',
    address: '60-c5-47-19-d3-76',
    services: [ [Object], [Object] ] } ]

find devices

device
.on('finished',  console.log.bind(console, 'finished'))
.on('found', function found(address, name){
  console.log('Found: ' + address + ' with name ' + name);
}).scan();

will output

➜  node-bluetooth git:(master) ✗ node example/index.js
Found: 22-22-a3-0d-63-09 with name Meizu MX4 Pro
Found: dc-2b-2a-82-76-29 with name Lsong's iPhone
Found: 38-bc-1a-37-2d-d4 with name MEIZU MX5
finished

find serial port channel

device.findSerialPortChannel(address, function(channel){
  console.log('Found RFCOMM channel for serial port on %s: ', name, channel);

  // make bluetooth connect to remote device
  bluetooth.connect(address, channel, function(err, connection){
    if(err) return console.error(err);
    connection.write(new Buffer('Hello!', 'utf-8'), () => {
      console.log("wrote");
    });
  });

});

create connection to device, read and write

// make bluetooth connect to remote device
bluetooth.connect(address, channel, function(err, connection){
  if(err) return console.error(err);

  connection.on('data', (buffer) => {
    console.log('received message:', buffer.toString());
  });

  connection.write(new Buffer('Hello!', 'utf-8'), () => {
    console.log("wrote");
  });
});

API

Contributing

  • Fork this Repo first
  • Clone your Repo
  • Install dependencies by $ npm install
  • Checkout a feature branch
  • Feel free to add your features
  • Make sure your features are fully tested
  • Publish your local branch, Open a pull request
  • Enjoy hacking <3

MIT license

Copyright (c) 2016 lsong

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


More Repositories

1

node-escpos

🖨️ ESC/POS Printer driver for Node.js
TypeScript
1,353
star
2

node-dns

🌐 DNS Server and Client Implementation in Pure JavaScript with no dependencies.
JavaScript
432
star
3

node-yeelight

💡 A Node.js Library for the Yeelight smart bulb
JavaScript
84
star
4

input-event

🎹 Read and parse input device(like mouse, keyboard, joystick and IR-Remote)'s event data.
JavaScript
57
star
5

wake-on-lan

💻 wake on lan
JavaScript
47
star
6

homekit

🏠 A HomeKit Accessory implementation in Node.js
JavaScript
40
star
7

wechat-lite

🌱 WeChat JavaScript API
JavaScript
33
star
8

node-irc

💻 IRC server implementation in Node.js
JavaScript
24
star
9

simsimi

🐥 Simsimi API in Node.js 🐔
JavaScript
24
star
10

node-ntp

⌛ simple network time protocol implementation for node.js
JavaScript
24
star
11

node-gsm

📲 gsm modem module for node.js
JavaScript
24
star
12

bjguahao

🏥 北京市预约挂号统一平台
JavaScript
23
star
13

RFID-RC522

RFID-RC522 for Arduino
C++
20
star
14

node-javbus

🔞 [NSFW] simple javbus api in javascript
JavaScript
19
star
15

multiline.js

Multiline strings in JavaScript
JavaScript
16
star
16

node-rtmp

A Node.js implementation of RTMP Server
JavaScript
16
star
17

chromium-runner-game

runner game in chromium web browser 🏃
JavaScript
15
star
18

ofo

🚲 free bike for everyone 🚲
JavaScript
15
star
19

vxapp

🚀 wechat mini-program framework
JavaScript
13
star
20

dsensor

📈 Digital universal particle concentration sensor ⏲️
JavaScript
13
star
21

node-mijia

🏠 Control Mi Home devices, such as Mi Robot Vacuums, Mi Air Purifiers, Mi Smart Home Gateway (Aqara) and more
JavaScript
12
star
22

koa-routeify

the next router for koajs.
JavaScript
12
star
23

node-alipay

💰 alipay sdk for node.js
JavaScript
10
star
24

pinyin.js

convert Chinese to PinYin 🇨🇳
JavaScript
10
star
25

express-favicon

favicon for express middleware .
JavaScript
9
star
26

node-dht

🕷️ Distributed Hash Table
JavaScript
9
star
27

konke

🔌 konke sdk for node.js
JavaScript
9
star
28

dns2socks

Forward DNS requests to a DNS server via a SOCKS tunnel
C
8
star
29

node-v2ray

v2ray in javascript
JavaScript
8
star
30

node-smtp

📫 simple smtp client and server for node.js
JavaScript
8
star
31

xfind

🔍 Simple and fast glob alternative in Node.js, just ~65lines!
JavaScript
7
star
32

aria2-api

Aria2 RPC Library in Node.js
JavaScript
7
star
33

garbage-recycle

🚮 中国垃圾分类查询
HTML
6
star
34

tiny-matter

⚡ super tiny front matter parser just ~20 lines with no dependencies.
JavaScript
6
star
35

node-qqwry

🌎 A lightweight native JavaScript implementation of GeoIP API
JavaScript
6
star
36

kelp

dead simple nodejs http(s) web framework written in ~40 lines! 🚀
JavaScript
5
star
37

chatgpt-cli

This is a command-line interface (CLI) that uses OpenAI's GPT-3 model to provide conversational answers to user prompts.
Go
5
star
38

tinyact

Super Tiny React Alternative, Just ~300 lines.
JavaScript
5
star
39

the-programmer

open source movie script 🎬
4
star
40

node-ftp

📃 ftp server and client written in pure javascript
JavaScript
4
star
41

create-z

Universal Project Scaffold Tools
JavaScript
4
star
42

node-tftp

📄 Tiny tftp server and client in node.js
JavaScript
4
star
43

deps-parser

A simple way to get module dependencies
JavaScript
4
star
44

python-escpos

Python library to manipulate ESC/POS Printers.
Python
4
star
45

node-gps

📡 A GPS NMEA parser library
JavaScript
4
star
46

socks-proxy

simple socks proxy client/server
JavaScript
4
star
47

163-music

Netease Music SDK in Node.js
JavaScript
3
star
48

node-open-falcon

open-falcon for nodejs
JavaScript
3
star
49

scripts

🧪 ESM Scripts
JavaScript
3
star
50

big-watermelon

JavaScript
3
star
51

simctl

📱Bring simctl to Node.js
JavaScript
3
star
52

node-ssdp

🔍 simple service discovery protocol implementation in nodejs
JavaScript
3
star
53

smtp-go

📤 An SMTP client & server library written in Go
Go
3
star
54

server-sent-events

server send events library for node.js
JavaScript
3
star
55

node-instagram

📷 Parse and Download Instagram Resources
JavaScript
3
star
56

node-dhcp

dhcp client and server in nodejs
JavaScript
3
star
57

json-editor

Super Tiny JSON Editor
JavaScript
3
star
58

mytv

📺 Simple IPTV App for Android TV
Kotlin
3
star
59

node-mail

📮 mail for nodejs 📧
JavaScript
3
star
60

android-apk

🤖 A Simple Android APK Reader in Node.js
JavaScript
3
star
61

chatgpt-api.js

🤖 ChatGPT API in JavaScript
JavaScript
3
star
62

mongoose-paginate

mongoose-paginate
JavaScript
3
star
63

fast-gbk

🚀 encode and decode utf8 to gbk string as fast as possible
JavaScript
3
star
64

VirtualWire

VirtualWire library for Arduino and other boards
C++
3
star
65

china-area

Provide administrative regional structure in China
JavaScript
3
star
66

openai.js

OpenAI JavaScript Library
JavaScript
3
star
67

chatgpt-demo

Simple ChatGPT Web Client
JavaScript
3
star
68

feedreader

📖 FeedReader - Self-hosted RSS Feed Aggregator Service
Go
3
star
69

superagent-retry

A retrying middleware for a superagent request
JavaScript
2
star
70

color-picker

🎨 simple color picker
JavaScript
2
star
71

covid-19

新型冠状病毒 肺炎疫情实时动态
JavaScript
2
star
72

superror

🚨Error stack parser and printer
JavaScript
2
star
73

binary-xml

Read and Parse Binary XML in Node.js
JavaScript
2
star
74

xiaoai

xiaoai, mi-soundbox
JavaScript
2
star
75

promise.js

⚡ A fast and simple Promise/A+ implementation
JavaScript
2
star
76

kelp-config

✨ Simple light-weight configuration for kelp
JavaScript
2
star
77

qqwry-go

🌎 A lightweight native Golang implementation of GeoIP API
Go
2
star
78

tinyh

super tiny network library
JavaScript
2
star
79

kelp-cors

Cross-Origin Resource Sharing(CORS) Middleware for Kelp Project.
JavaScript
2
star
80

imessage

Apple iMessage
JavaScript
2
star
81

openai-go

OpenAI Golang Library
Go
2
star
82

youdao-fanyi

🌐 Simple API for Youdao Translate in JavaScript
JavaScript
2
star
83

song940.github.io

🏠 Home website
HTML
2
star
84

kelp-static

serve static files for kelp and express
JavaScript
2
star
85

node-xmind

🧠 [WIP] Simple JavaScript API for Xmind
JavaScript
2
star
86

mycenter

user center
JavaScript
2
star
87

xreplay

TypeScript
2
star
88

mp4ba

🎥 Simple JavaScript API for Mp4ba
JavaScript
2
star
89

telegram-bot

🤖 Simple JavaScript API for Telegram Bot
JavaScript
2
star
90

qualcomm-4g-lte-modem

JavaScript
2
star
91

m3u.js

JavaScript
2
star
92

router-monitor

📺 NetData Display with ESP8266 and SPI LCD
C
2
star
93

maimai

maimai.cn(脉脉) javascript api
JavaScript
2
star
94

xmljs

simple xml reader and parser
JavaScript
1
star
95

dnsmasq

simple wrapper for dnsmasq in javascript
JavaScript
1
star
96

photos

📷
HTML
1
star
97

go-fetch

Go
1
star
98

fresh-launcher

🍐 Fresh Launcher - Minimalist App Launcher for Android Home Screen
Kotlin
1
star
99

keyboard.js

🎹
JavaScript
1
star
100

qmk-keymap

C
1
star