@stoprocent/bleno 0.7.7 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/FUNDING.yml +15 -0
- package/LICENSE +13 -12
- package/README.md +42 -32
- package/examples/uart/main.js +28 -3
- package/package.json +2 -2
- package/prebuilds/darwin-x64+arm64/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-ia32/@stoprocent+bleno.node +0 -0
- package/prebuilds/win32-x64/@stoprocent+bleno.node +0 -0
package/FUNDING.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# These are supported funding model platforms
|
|
2
|
+
|
|
3
|
+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
|
4
|
+
patreon: # Replace with a single Patreon username
|
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
|
6
|
+
ko_fi: # Replace with a single Ko-fi username
|
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
|
9
|
+
liberapay: # Replace with a single Liberapay username
|
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
|
11
|
+
lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry
|
|
12
|
+
polar: # Replace with a single Polar username
|
|
13
|
+
buy_me_a_coffee: stoprocent # Replace with a single Buy Me a Coffee username
|
|
14
|
+
thanks_dev: # Replace with a single thanks.dev username
|
|
15
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
package/LICENSE
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Marek Serafin
|
|
4
4
|
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
the Software without restriction, including without limitation the rights
|
|
8
|
-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
the Software, and to permit persons to whom the Software is
|
|
10
|
-
subject to the following conditions:
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
11
|
|
|
12
12
|
The above copyright notice and this permission notice shall be included in all
|
|
13
13
|
copies or substantial portions of the Software.
|
|
14
14
|
|
|
15
15
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,15 +1,52 @@
|
|
|
1
1
|
# bleno
|
|
2
2
|
|
|
3
|
-
[](
|
|
6
|
+
https://GitHub.com/stoprocent/bleno/network/
|
|
7
|
+
)
|
|
8
|
+
[](MIT)
|
|
11
|
+
[](
|
|
14
|
+
https://www.npmjs.com/package/@stoprocent/bleno
|
|
15
|
+
)
|
|
5
16
|
|
|
6
17
|
A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals.
|
|
7
18
|
|
|
8
|
-
Need a BLE central module? See [noble](https://github.com/stoprocent/noble).
|
|
19
|
+
Need a BLE central module? See [@stoprocent/noble](https://github.com/stoprocent/noble).
|
|
20
|
+
|
|
21
|
+
## About This Fork
|
|
22
|
+
|
|
23
|
+
This fork of `bleno` was created to introduce several key improvements and new features:
|
|
24
|
+
|
|
25
|
+
1. **HCI UART Support**: This version enables HCI UART communication through the `@stoprocent/node-bluetooth-hci-socket` dependency, allowing more flexible use of Bluetooth devices across platforms.
|
|
26
|
+
|
|
27
|
+
2. **macOS Native Bindings Fix**: I have fixed the native bindings for macOS, ensuring better compatibility and performance on Apple devices.
|
|
28
|
+
|
|
29
|
+
3. **New Features**: A `setAddress` function has been added, allowing users to set the MAC address of the peripheral device. Additionally, I plan to add raw L2CAP channel support, enhancing low-level Bluetooth communication capabilities.
|
|
30
|
+
|
|
31
|
+
If you appreciate these enhancements and the continued development of this project, please consider supporting my work.
|
|
32
|
+
|
|
33
|
+
[](https://www.buymeacoffee.com/stoprocent)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
## Install
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
npm install @stoprocent/bleno --save
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
```javascript
|
|
45
|
+
const bleno = require('@stoprocent/bleno');
|
|
46
|
+
```
|
|
9
47
|
|
|
10
|
-
|
|
48
|
+
See [examples folder](https://github.com/stoprocent/bleno/blob/master/examples) for code examples.
|
|
11
49
|
|
|
12
|
-
__Note:__ macOS / Mac OS X, Linux, FreeBSD and Windows are currently the only supported OSes.
|
|
13
50
|
|
|
14
51
|
## Prerequisites
|
|
15
52
|
|
|
@@ -113,20 +150,6 @@ Make sure you have read and write permissions on the ```/dev/usb/*``` device tha
|
|
|
113
150
|
* Compatible Bluetooth 4.0 USB adapter
|
|
114
151
|
* [WinUSB](https://msdn.microsoft.com/en-ca/library/windows/hardware/ff540196(v=vs.85).aspx) driver setup for Bluetooth 4.0 USB adapter, using [Zadig tool](http://zadig.akeo.ie/)
|
|
115
152
|
|
|
116
|
-
## Install
|
|
117
|
-
|
|
118
|
-
```sh
|
|
119
|
-
npm install bleno@npm:@stoprocent/bleno
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
## Usage
|
|
123
|
-
|
|
124
|
-
```javascript
|
|
125
|
-
var bleno = require('bleno');
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
See [examples folder](https://github.com/stoprocent/bleno/blob/master/examples) for code examples.
|
|
129
|
-
|
|
130
153
|
### Actions
|
|
131
154
|
|
|
132
155
|
#### Set address
|
|
@@ -437,16 +460,3 @@ Advertising intervals must be between 20 ms to 10 s (10,000 ms).
|
|
|
437
460
|
* LightBlue for [iOS](https://itunes.apple.com/us/app/lightblue/id557428110)/[OS X](https://itunes.apple.com/us/app/lightblue/id639944780)
|
|
438
461
|
* [nRF Master Control Panel (BLE)](https://play.google.com/store/apps/details?id=no.nordicsemi.android.mcp&hl=en) for Android
|
|
439
462
|
* [hcitool](http://linux.die.net/man/1/hcitool) and ```gatttool``` by [BlueZ](http://www.bluez.org) for Linux
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
## License
|
|
443
|
-
|
|
444
|
-
Copyright (C) 2015 Sandeep Mistry <sandeep.mistry@gmail.com>
|
|
445
|
-
|
|
446
|
-
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:
|
|
447
|
-
|
|
448
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
449
|
-
|
|
450
|
-
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.
|
|
451
|
-
|
|
452
|
-
[](https://github.com/igrigorik/ga-beacon)
|
package/examples/uart/main.js
CHANGED
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
const bleno = require('../../with-custom-binding')({
|
|
2
2
|
bindParams: {
|
|
3
3
|
uart: {
|
|
4
|
-
port: '/dev/tty...',
|
|
4
|
+
port: '/dev/tty...', // Specify the path to the UART device
|
|
5
5
|
baudRate: 1000000
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
8
|
});
|
|
9
9
|
|
|
10
|
+
function generateRandomBLEMacAddress () {
|
|
11
|
+
// Create an array to store 6 bytes for the MAC address
|
|
12
|
+
let macAddr = [];
|
|
13
|
+
// Generate 6 random bytes
|
|
14
|
+
for (let i = 0; i < 6; i++) {
|
|
15
|
+
// Generate a random byte between 0x00 and 0xFF
|
|
16
|
+
let randomByte = Math.floor(Math.random() * 256);
|
|
17
|
+
// Ensure the first byte is a locally administered unicast address
|
|
18
|
+
if (i === 0) {
|
|
19
|
+
randomByte = (randomByte & 0xFE) | 0x02; // Clear multicast bit and set locally administered bit
|
|
20
|
+
}
|
|
21
|
+
// Convert the byte to a two-character hexadecimal string
|
|
22
|
+
macAddr.push(randomByte.toString(16).padStart(2, '0'));
|
|
23
|
+
}
|
|
24
|
+
// Join the array into a MAC address string with colons
|
|
25
|
+
return macAddr.join(':');
|
|
26
|
+
}
|
|
27
|
+
let interval = null;
|
|
10
28
|
bleno.on('stateChange', state => {
|
|
11
29
|
console.log('on -> stateChange: ' + state);
|
|
12
30
|
|
|
13
31
|
if (state === 'poweredOn') {
|
|
14
|
-
|
|
15
|
-
|
|
32
|
+
clearInterval(interval);
|
|
33
|
+
interval = setInterval(() => {
|
|
34
|
+
// Stop advertising
|
|
35
|
+
bleno.stopAdvertising();
|
|
36
|
+
// Set a random MAC address
|
|
37
|
+
bleno.setAddress(generateRandomBLEMacAddress());
|
|
38
|
+
// Start advertising as an iBeacon
|
|
39
|
+
bleno.startAdvertisingIBeacon('a2744045-7004-4da9-8ed3-6d2d9a208c0a', 1234, 5678);
|
|
40
|
+
}, 4000);
|
|
16
41
|
} else {
|
|
17
42
|
bleno.stopAdvertising();
|
|
18
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stoprocent/bleno",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "A Node.js module for implementing BLE (Bluetooth Low Energy) peripherals",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"node-gyp-build": "^4.8.1"
|
|
71
71
|
},
|
|
72
72
|
"optionalDependencies": {
|
|
73
|
-
"@stoprocent/bluetooth-hci-socket": "^1.
|
|
73
|
+
"@stoprocent/bluetooth-hci-socket": "^1.4.1",
|
|
74
74
|
"bplist-parser": "0.3.2",
|
|
75
75
|
"xpc-connect": "^3.0.0"
|
|
76
76
|
},
|
|
Binary file
|
|
Binary file
|
|
Binary file
|