You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This log shows a successful start on Linux, the virtual serial port was opened on `/dev/pts/8`, the number at the end changes, depending on how many pseudo terminals are already open on the system. It uses the same mechanism on macOS, just the path is slightly different, in the format `/dev/ttys000`.
235
-
In addition it automatically creates a symlink to `/tmp/ttyBLE`, so you can easily access it always on the same file, the default can be changed with the `-p`/`--port` option.
228
+
In addition it automatically creates a symlink to `/tmp/ttyBLE`, so you can easily access it always on the same file, the default can be changed with:
229
+
```
230
+
serial port parameters:
231
+
-p PORT, --port PORT Symlink to virtual serial port (default: /tmp/ttyBLE)
232
+
```
236
233
237
234
On Windows it uses the port pair created in the setup described above, this does not dynamically change and endpoint is always `COM9` if you use the default script.
238
235
@@ -273,6 +270,13 @@ This works also the other way around with `wo` = write only.
273
270
274
271
### Logging
275
272
There is an option to log all traffic on the link to a text file:
273
+
```
274
+
logging options:
275
+
-l FILENAME, --log FILENAME
276
+
Enable optional logging of all bluetooth traffic to file (default: None)
277
+
-b, --binary Log data as raw binary, disable transformation to hex. Works only in combination with -l (default: False)
Per default it is transformed to hex bytes, use `-b`/`--binary` to log raw data.
288
+
Per default it is transformed to hex bytes, use `-b`/`--binary` to log raw data, useful if your input is already ASCII etc.
285
289
286
290
You can use `-v` to increase the log verbosity to DEBUG:
287
291
```console
@@ -306,10 +310,49 @@ It also helps with figuring out how characteristics are selected:
306
310
Always try the verbose option if something is not working properly.
307
311
308
312
## Advanced Usage
313
+
### TCP socket server
314
+
Instead of the serial port emulation there is a also builtin raw tcp server since version 2.7:
315
+
```
316
+
network options:
317
+
--expose-tcp-host TCP_HOST
318
+
Network interface for the server listen on (default: 127.0.0.1)
319
+
--expose-tcp-port TCP_PORT
320
+
Port to listen on, disables local serial port and enables TCP server if specified (default: None)
321
+
```
322
+
This is only activated if TCP_PORT is set. Also it removes the dependency to com0com or other drivers.
323
+
324
+
The server is listening on localhost per default, therefore only reachable from apps running on the same machine. Other interfaces or `0.0.0.0` for all interfaces can be specified with TCP_HOST.
325
+
Security is to consider though, this is plain TCP without encryption or authentication. Only recommended on a separate local network, otherwise stay with the default/localhost.
326
+
327
+
Note: this is limited to one concurrent connection, it will reject all connection attempts if there is already a client connected and emit a warning, example:
19:30:26.726 | INFO | tcp_socket.py: New TCP peer connected: ('127.0.0.1', 56172)
340
+
19:30:26.726 | WARNING | tcp_socket.py: More than one connection is not allowed, closing
341
+
```
342
+
343
+
Now there a various ways to connect to it.
344
+
#### Linux and macOS
345
+
- Very simple option: `netcat 127.0.0.1 4002` or `telnet 127.0.0.1 4002`
346
+
- More powerful: `socat -dd tcp:localhost:4002 -`, can forward data to many modules, not only stdin/stdout.
347
+
- Custom apps are easy to make with tcp too
348
+
#### Windows
349
+
- Graphical: Putty, just put in the IP+port and select Other - Raw as connection type.
350
+
- Terminal: netcat/telnet/socat can be installed separately
351
+
309
352
### Multi device connection
310
353
It is possible to connect several devices to a host simultaneously. Limiting factor is only the bluetooth baseband layer, which uses a Active Member Address (AMA, 3 bit). From these 8 possible values address zero is always occupied by the host, so it can be connected to (up to) 7 devices at the same time.
311
354
312
-
There is no special mode, ble-serial can be just stated multiple times with different parameters. Following are some tips, showing how to do this in practice.
355
+
There is no special mode, ble-serial can be just started multiple times with different parameters. Following are some tips, showing how to do this in practice.
313
356
314
357
#### Linux and macOS
315
358
Common shells (bash, zsh, fish) have a useful background job feature. Add the `-p` (port) option to make sure every instance has a unique path. Also you probably want to redirect the log output to keep it separate. Resulting command lines could look like:
0 commit comments