Skip to content

Commit

Permalink
fix: start scan in the uart example after state changed to poweredOn
Browse files Browse the repository at this point in the history
  • Loading branch information
stoprocent committed Oct 25, 2023
1 parent 286a8e5 commit f7b04a2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions examples/uart-bind-params.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ const noble = require('../with-custom-binding')
const noble_uart_a = noble ({ bindParams: { uart: { port: "/dev/tty.usbmodem1..." } } } )

Check failure on line 5 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Identifier 'noble_uart_a' is not in camel case

Check failure on line 5 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected whitespace between function name and paren

Check failure on line 5 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 5 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

There should be no space before this paren

Check failure on line 5 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
const noble_uart_b = noble ({ bindParams: { uart: { port: "/dev/tty.usbmodem2..." } } } )

Check failure on line 6 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Identifier 'noble_uart_b' is not in camel case

Check failure on line 6 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Unexpected whitespace between function name and paren

Check failure on line 6 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

Strings must use singlequote

Check failure on line 6 in examples/uart-bind-params.js

View workflow job for this annotation

GitHub Actions / lint

There should be no space before this paren

noble_uart_a.on('discover', (peripheral) => {
noble_uart_a.on('discover', peripheral => {
console.log("UART A", peripheral.address)
})

noble_uart_b.on('discover', (peripheral) => {
noble_uart_b.on('discover', peripheral => {
console.log("UART B", peripheral.address)
})

noble_uart_a.startScanning()
noble_uart_b.startScanning()
noble_uart_a.on('stateChange', state => {
if(state === 'poweredOn') {
noble_uart_a.setAddress("00:11:22:33:44:01");
noble_uart_a.startScanning()
}
});

noble_uart_b.on('stateChange', state => {
if(state === 'poweredOn') {
noble_uart_b.setAddress("00:11:22:33:44:02");
noble_uart_b.startScanning()
}
});

0 comments on commit f7b04a2

Please sign in to comment.