@technoculture/data-bridge 0.1.0
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/CMakeLists.txt +57 -0
- package/README.md +77 -0
- package/dist/index.d.mts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +314 -0
- package/dist/index.mjs +285 -0
- package/lib/index.ts +171 -0
- package/lib/resilient.ts +276 -0
- package/package.json +75 -0
- package/prebuilds/darwin-arm64/.ninja_deps +0 -0
- package/prebuilds/darwin-arm64/.ninja_log +6 -0
- package/prebuilds/darwin-arm64/CMakeCache.txt +398 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CMakeCCompiler.cmake +84 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CMakeCXXCompiler.cmake +104 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CMakeDetermineCompilerABI_C.bin +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CMakeDetermineCompilerABI_CXX.bin +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CMakeSystem.cmake +15 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdC/CMakeCCompilerId.c +905 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdC/a.out +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdC/apple-sdk.c +1 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdCXX/CMakeCXXCompilerId.cpp +920 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdCXX/a.out +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/4.0.3/CompilerIdCXX/apple-sdk.cpp +1 -0
- package/prebuilds/darwin-arm64/CMakeFiles/CMakeConfigureLog.yaml +531 -0
- package/prebuilds/darwin-arm64/CMakeFiles/InstallScripts.json +7 -0
- package/prebuilds/darwin-arm64/CMakeFiles/TargetDirectories.txt +3 -0
- package/prebuilds/darwin-arm64/CMakeFiles/cmake.check_cache +1 -0
- package/prebuilds/darwin-arm64/CMakeFiles/data_bridge_node.dir/Users/satyamtiwary/Documents/Python-Things/data-bridge/src/protocol/crc16.cpp.o +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/data_bridge_node.dir/Users/satyamtiwary/Documents/Python-Things/data-bridge/src/transport/platform/linux/linux_serial.cpp.o +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/data_bridge_node.dir/src/addon.cpp.o +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/data_bridge_node.dir/src/serial_wrapper.cpp.o +0 -0
- package/prebuilds/darwin-arm64/CMakeFiles/rules.ninja +64 -0
- package/prebuilds/darwin-arm64/Release/data_bridge_node.node +0 -0
- package/prebuilds/darwin-arm64/build.ninja +192 -0
- package/prebuilds/darwin-arm64/cmake_install.cmake +61 -0
- package/src/addon.cpp +219 -0
- package/src/serial_wrapper.cpp +8 -0
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
cmake_minimum_required(VERSION 3.15)
|
|
2
|
+
project(data_bridge_node)
|
|
3
|
+
|
|
4
|
+
set(CMAKE_CXX_STANDARD 17)
|
|
5
|
+
|
|
6
|
+
# Root of the data-bridge project
|
|
7
|
+
get_filename_component(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/../.." ABSOLUTE)
|
|
8
|
+
|
|
9
|
+
# Include Node-API headers
|
|
10
|
+
include_directories(${CMAKE_JS_INC})
|
|
11
|
+
|
|
12
|
+
# Platform-specific serial implementation
|
|
13
|
+
if(WIN32)
|
|
14
|
+
set(PLATFORM_SOURCES
|
|
15
|
+
${PROJECT_ROOT}/src/transport/platform/windows/windows_serial.cpp
|
|
16
|
+
)
|
|
17
|
+
else()
|
|
18
|
+
set(PLATFORM_SOURCES
|
|
19
|
+
${PROJECT_ROOT}/src/transport/platform/linux/linux_serial.cpp
|
|
20
|
+
)
|
|
21
|
+
endif()
|
|
22
|
+
|
|
23
|
+
# Build core library sources directly
|
|
24
|
+
set(CORE_SOURCES
|
|
25
|
+
${PROJECT_ROOT}/src/protocol/crc16.cpp
|
|
26
|
+
${PLATFORM_SOURCES}
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Build the native addon
|
|
30
|
+
add_library(${PROJECT_NAME} SHARED
|
|
31
|
+
src/addon.cpp
|
|
32
|
+
src/serial_wrapper.cpp
|
|
33
|
+
${CORE_SOURCES}
|
|
34
|
+
${CMAKE_JS_SRC}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
# Set properties for Node.js addon
|
|
38
|
+
set_target_properties(${PROJECT_NAME} PROPERTIES
|
|
39
|
+
PREFIX ""
|
|
40
|
+
SUFFIX ".node"
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# Include paths
|
|
44
|
+
target_include_directories(${PROJECT_NAME} PRIVATE
|
|
45
|
+
${PROJECT_ROOT}/include
|
|
46
|
+
${CMAKE_JS_INC}
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
target_link_libraries(${PROJECT_NAME} PRIVATE
|
|
50
|
+
${CMAKE_JS_LIB}
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# Enable N-API version 8
|
|
54
|
+
target_compile_definitions(${PROJECT_NAME} PRIVATE
|
|
55
|
+
NAPI_VERSION=8
|
|
56
|
+
NODE_ADDON_API_DISABLE_DEPRECATED
|
|
57
|
+
)
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# @aspect-labs/data-bridge
|
|
2
|
+
|
|
3
|
+
Guaranteed reliable serial communication for Node.js and Electron.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @aspect-labs/data-bridge
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Pre-built binaries are included for Windows and Linux (x64, arm64).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { DataBridge } from '@aspect-labs/data-bridge';
|
|
17
|
+
|
|
18
|
+
// Open a serial port
|
|
19
|
+
const bridge = await DataBridge.open('/dev/ttyUSB0', { baudRate: 115200 });
|
|
20
|
+
|
|
21
|
+
// Receive data
|
|
22
|
+
bridge.on('data', (data) => {
|
|
23
|
+
console.log('Received:', data.toString());
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
// Send with guaranteed delivery
|
|
27
|
+
await bridge.send('Hello, World!');
|
|
28
|
+
|
|
29
|
+
// Close when done
|
|
30
|
+
await bridge.close();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- **Guaranteed Delivery** — Every packet is acknowledged; lost packets are automatically retried
|
|
36
|
+
- **Corruption Detection** — CRC32 checksum on every packet
|
|
37
|
+
- **Large Message Support** — Automatic fragmentation and reassembly
|
|
38
|
+
- **Electron Compatible** — Works in both main and renderer processes
|
|
39
|
+
|
|
40
|
+
## API
|
|
41
|
+
|
|
42
|
+
### `DataBridge.open(port, options?)`
|
|
43
|
+
|
|
44
|
+
Opens a serial port with reliable communication enabled.
|
|
45
|
+
|
|
46
|
+
- `port` — Port path (e.g., `/dev/ttyUSB0` on Linux, `COM3` on Windows)
|
|
47
|
+
- `options.baudRate` — Baud rate (default: 115200)
|
|
48
|
+
|
|
49
|
+
Returns: `Promise<DataBridge>`
|
|
50
|
+
|
|
51
|
+
### `bridge.send(data)`
|
|
52
|
+
|
|
53
|
+
Sends data with guaranteed delivery.
|
|
54
|
+
|
|
55
|
+
- `data` — `Buffer` or `string` to send
|
|
56
|
+
|
|
57
|
+
Returns: `Promise<void>` — Resolves when acknowledged
|
|
58
|
+
|
|
59
|
+
### `bridge.on('data', callback)`
|
|
60
|
+
|
|
61
|
+
Subscribe to received data.
|
|
62
|
+
|
|
63
|
+
### `bridge.close()`
|
|
64
|
+
|
|
65
|
+
Closes the serial port.
|
|
66
|
+
|
|
67
|
+
## Building from Source
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
cd bindings/node
|
|
71
|
+
npm install
|
|
72
|
+
npm run build
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## License
|
|
76
|
+
|
|
77
|
+
MIT
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ResilientDataBridge - Connection-resilient wrapper
|
|
5
|
+
*
|
|
6
|
+
* Guarantees message delivery across USB disconnections by:
|
|
7
|
+
* 1. Auto-reconnection with exponential backoff
|
|
8
|
+
* 2. Message queue for pending sends during disconnect
|
|
9
|
+
* 3. Automatic re-handshake and queue flush on reconnect
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface ResilientOptions extends DataBridgeOptions {
|
|
13
|
+
/** Enable auto-reconnection (default: true) */
|
|
14
|
+
reconnect?: boolean;
|
|
15
|
+
/** Initial reconnect delay in ms (default: 1000) */
|
|
16
|
+
reconnectDelay?: number;
|
|
17
|
+
/** Maximum reconnect delay in ms (default: 30000) */
|
|
18
|
+
maxReconnectDelay?: number;
|
|
19
|
+
/** Maximum queue size before dropping old messages (default: 1000) */
|
|
20
|
+
maxQueueSize?: number;
|
|
21
|
+
}
|
|
22
|
+
interface ResilientEvents {
|
|
23
|
+
data: (data: Buffer) => void;
|
|
24
|
+
error: (error: Error) => void;
|
|
25
|
+
close: () => void;
|
|
26
|
+
disconnect: () => void;
|
|
27
|
+
reconnecting: (attempt: number, delay: number) => void;
|
|
28
|
+
reconnected: () => void;
|
|
29
|
+
}
|
|
30
|
+
declare class ResilientDataBridge extends EventEmitter {
|
|
31
|
+
private bridge;
|
|
32
|
+
private port;
|
|
33
|
+
private options;
|
|
34
|
+
private messageQueue;
|
|
35
|
+
private isConnected;
|
|
36
|
+
private isReconnecting;
|
|
37
|
+
private shouldReconnect;
|
|
38
|
+
private reconnectAttempt;
|
|
39
|
+
private reconnectTimeout;
|
|
40
|
+
private constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Open a resilient serial connection.
|
|
43
|
+
*
|
|
44
|
+
* @param port - Serial port path
|
|
45
|
+
* @param options - Configuration including reconnection settings
|
|
46
|
+
*/
|
|
47
|
+
static open(port: string, options?: ResilientOptions): Promise<ResilientDataBridge>;
|
|
48
|
+
private connect;
|
|
49
|
+
private handleDisconnect;
|
|
50
|
+
private scheduleReconnect;
|
|
51
|
+
/**
|
|
52
|
+
* Send data with guaranteed delivery.
|
|
53
|
+
*
|
|
54
|
+
* If disconnected, the message is queued and will be sent
|
|
55
|
+
* automatically when the connection is restored.
|
|
56
|
+
*
|
|
57
|
+
* @param data - Data to send
|
|
58
|
+
* @returns Promise that resolves when data is acknowledged
|
|
59
|
+
*/
|
|
60
|
+
send(data: Buffer | string): Promise<void>;
|
|
61
|
+
private queueMessage;
|
|
62
|
+
private flushQueue;
|
|
63
|
+
/**
|
|
64
|
+
* Close the connection permanently.
|
|
65
|
+
* Rejects all pending queued messages.
|
|
66
|
+
*/
|
|
67
|
+
close(): Promise<void>;
|
|
68
|
+
/** Current connection state */
|
|
69
|
+
get connected(): boolean;
|
|
70
|
+
/** Number of messages waiting in queue */
|
|
71
|
+
get queueLength(): number;
|
|
72
|
+
on<K extends keyof ResilientEvents>(event: K, listener: ResilientEvents[K]): this;
|
|
73
|
+
once<K extends keyof ResilientEvents>(event: K, listener: ResilientEvents[K]): this;
|
|
74
|
+
emit<K extends keyof ResilientEvents>(event: K, ...args: Parameters<ResilientEvents[K]>): boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Data Bridge - Guaranteed Reliable Serial Communication
|
|
79
|
+
*
|
|
80
|
+
* TypeScript wrapper for the native Node-API addon.
|
|
81
|
+
* Provides a clean, async-friendly API for Electron applications.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
interface DataBridgeOptions {
|
|
85
|
+
baudRate?: number;
|
|
86
|
+
}
|
|
87
|
+
interface DataBridgeEvents {
|
|
88
|
+
data: (data: Buffer) => void;
|
|
89
|
+
error: (error: Error) => void;
|
|
90
|
+
close: () => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* DataBridge provides guaranteed reliable serial communication.
|
|
94
|
+
*
|
|
95
|
+
* Features:
|
|
96
|
+
* - Automatic retransmission on packet loss
|
|
97
|
+
* - CRC32 integrity checking
|
|
98
|
+
* - COBS framing for robust delimitation
|
|
99
|
+
* - Fragmentation for large messages
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const bridge = await DataBridge.open('/dev/ttyUSB0');
|
|
104
|
+
*
|
|
105
|
+
* bridge.on('data', (data) => {
|
|
106
|
+
* console.log('Received:', data.toString());
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* await bridge.send('Hello, World!');
|
|
110
|
+
* await bridge.close();
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare class DataBridge extends EventEmitter {
|
|
114
|
+
private native;
|
|
115
|
+
private _isOpen;
|
|
116
|
+
private constructor();
|
|
117
|
+
/**
|
|
118
|
+
* Open a serial port with guaranteed reliable communication.
|
|
119
|
+
*
|
|
120
|
+
* @param port - Serial port path (e.g., '/dev/ttyUSB0' or 'COM3')
|
|
121
|
+
* @param options - Configuration options
|
|
122
|
+
* @returns Promise resolving to a DataBridge instance
|
|
123
|
+
*/
|
|
124
|
+
static open(port: string, options?: DataBridgeOptions): Promise<DataBridge>;
|
|
125
|
+
/**
|
|
126
|
+
* Send data with guaranteed delivery.
|
|
127
|
+
*
|
|
128
|
+
* The data will be fragmented if necessary, checksummed, and
|
|
129
|
+
* retransmitted until acknowledged by the receiver.
|
|
130
|
+
*
|
|
131
|
+
* @param data - Data to send (Buffer or string)
|
|
132
|
+
* @returns Promise resolving when data is acknowledged
|
|
133
|
+
*/
|
|
134
|
+
send(data: Buffer | string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Close the serial port.
|
|
137
|
+
*/
|
|
138
|
+
close(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Check if the port is currently open.
|
|
141
|
+
*/
|
|
142
|
+
get isOpen(): boolean;
|
|
143
|
+
on<K extends keyof DataBridgeEvents>(event: K, listener: DataBridgeEvents[K]): this;
|
|
144
|
+
once<K extends keyof DataBridgeEvents>(event: K, listener: DataBridgeEvents[K]): this;
|
|
145
|
+
emit<K extends keyof DataBridgeEvents>(event: K, ...args: Parameters<DataBridgeEvents[K]>): boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { DataBridge, type DataBridgeEvents, type DataBridgeOptions, ResilientDataBridge, type ResilientEvents, type ResilientOptions, DataBridge as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* ResilientDataBridge - Connection-resilient wrapper
|
|
5
|
+
*
|
|
6
|
+
* Guarantees message delivery across USB disconnections by:
|
|
7
|
+
* 1. Auto-reconnection with exponential backoff
|
|
8
|
+
* 2. Message queue for pending sends during disconnect
|
|
9
|
+
* 3. Automatic re-handshake and queue flush on reconnect
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
interface ResilientOptions extends DataBridgeOptions {
|
|
13
|
+
/** Enable auto-reconnection (default: true) */
|
|
14
|
+
reconnect?: boolean;
|
|
15
|
+
/** Initial reconnect delay in ms (default: 1000) */
|
|
16
|
+
reconnectDelay?: number;
|
|
17
|
+
/** Maximum reconnect delay in ms (default: 30000) */
|
|
18
|
+
maxReconnectDelay?: number;
|
|
19
|
+
/** Maximum queue size before dropping old messages (default: 1000) */
|
|
20
|
+
maxQueueSize?: number;
|
|
21
|
+
}
|
|
22
|
+
interface ResilientEvents {
|
|
23
|
+
data: (data: Buffer) => void;
|
|
24
|
+
error: (error: Error) => void;
|
|
25
|
+
close: () => void;
|
|
26
|
+
disconnect: () => void;
|
|
27
|
+
reconnecting: (attempt: number, delay: number) => void;
|
|
28
|
+
reconnected: () => void;
|
|
29
|
+
}
|
|
30
|
+
declare class ResilientDataBridge extends EventEmitter {
|
|
31
|
+
private bridge;
|
|
32
|
+
private port;
|
|
33
|
+
private options;
|
|
34
|
+
private messageQueue;
|
|
35
|
+
private isConnected;
|
|
36
|
+
private isReconnecting;
|
|
37
|
+
private shouldReconnect;
|
|
38
|
+
private reconnectAttempt;
|
|
39
|
+
private reconnectTimeout;
|
|
40
|
+
private constructor();
|
|
41
|
+
/**
|
|
42
|
+
* Open a resilient serial connection.
|
|
43
|
+
*
|
|
44
|
+
* @param port - Serial port path
|
|
45
|
+
* @param options - Configuration including reconnection settings
|
|
46
|
+
*/
|
|
47
|
+
static open(port: string, options?: ResilientOptions): Promise<ResilientDataBridge>;
|
|
48
|
+
private connect;
|
|
49
|
+
private handleDisconnect;
|
|
50
|
+
private scheduleReconnect;
|
|
51
|
+
/**
|
|
52
|
+
* Send data with guaranteed delivery.
|
|
53
|
+
*
|
|
54
|
+
* If disconnected, the message is queued and will be sent
|
|
55
|
+
* automatically when the connection is restored.
|
|
56
|
+
*
|
|
57
|
+
* @param data - Data to send
|
|
58
|
+
* @returns Promise that resolves when data is acknowledged
|
|
59
|
+
*/
|
|
60
|
+
send(data: Buffer | string): Promise<void>;
|
|
61
|
+
private queueMessage;
|
|
62
|
+
private flushQueue;
|
|
63
|
+
/**
|
|
64
|
+
* Close the connection permanently.
|
|
65
|
+
* Rejects all pending queued messages.
|
|
66
|
+
*/
|
|
67
|
+
close(): Promise<void>;
|
|
68
|
+
/** Current connection state */
|
|
69
|
+
get connected(): boolean;
|
|
70
|
+
/** Number of messages waiting in queue */
|
|
71
|
+
get queueLength(): number;
|
|
72
|
+
on<K extends keyof ResilientEvents>(event: K, listener: ResilientEvents[K]): this;
|
|
73
|
+
once<K extends keyof ResilientEvents>(event: K, listener: ResilientEvents[K]): this;
|
|
74
|
+
emit<K extends keyof ResilientEvents>(event: K, ...args: Parameters<ResilientEvents[K]>): boolean;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Data Bridge - Guaranteed Reliable Serial Communication
|
|
79
|
+
*
|
|
80
|
+
* TypeScript wrapper for the native Node-API addon.
|
|
81
|
+
* Provides a clean, async-friendly API for Electron applications.
|
|
82
|
+
*/
|
|
83
|
+
|
|
84
|
+
interface DataBridgeOptions {
|
|
85
|
+
baudRate?: number;
|
|
86
|
+
}
|
|
87
|
+
interface DataBridgeEvents {
|
|
88
|
+
data: (data: Buffer) => void;
|
|
89
|
+
error: (error: Error) => void;
|
|
90
|
+
close: () => void;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* DataBridge provides guaranteed reliable serial communication.
|
|
94
|
+
*
|
|
95
|
+
* Features:
|
|
96
|
+
* - Automatic retransmission on packet loss
|
|
97
|
+
* - CRC32 integrity checking
|
|
98
|
+
* - COBS framing for robust delimitation
|
|
99
|
+
* - Fragmentation for large messages
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const bridge = await DataBridge.open('/dev/ttyUSB0');
|
|
104
|
+
*
|
|
105
|
+
* bridge.on('data', (data) => {
|
|
106
|
+
* console.log('Received:', data.toString());
|
|
107
|
+
* });
|
|
108
|
+
*
|
|
109
|
+
* await bridge.send('Hello, World!');
|
|
110
|
+
* await bridge.close();
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare class DataBridge extends EventEmitter {
|
|
114
|
+
private native;
|
|
115
|
+
private _isOpen;
|
|
116
|
+
private constructor();
|
|
117
|
+
/**
|
|
118
|
+
* Open a serial port with guaranteed reliable communication.
|
|
119
|
+
*
|
|
120
|
+
* @param port - Serial port path (e.g., '/dev/ttyUSB0' or 'COM3')
|
|
121
|
+
* @param options - Configuration options
|
|
122
|
+
* @returns Promise resolving to a DataBridge instance
|
|
123
|
+
*/
|
|
124
|
+
static open(port: string, options?: DataBridgeOptions): Promise<DataBridge>;
|
|
125
|
+
/**
|
|
126
|
+
* Send data with guaranteed delivery.
|
|
127
|
+
*
|
|
128
|
+
* The data will be fragmented if necessary, checksummed, and
|
|
129
|
+
* retransmitted until acknowledged by the receiver.
|
|
130
|
+
*
|
|
131
|
+
* @param data - Data to send (Buffer or string)
|
|
132
|
+
* @returns Promise resolving when data is acknowledged
|
|
133
|
+
*/
|
|
134
|
+
send(data: Buffer | string): Promise<void>;
|
|
135
|
+
/**
|
|
136
|
+
* Close the serial port.
|
|
137
|
+
*/
|
|
138
|
+
close(): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* Check if the port is currently open.
|
|
141
|
+
*/
|
|
142
|
+
get isOpen(): boolean;
|
|
143
|
+
on<K extends keyof DataBridgeEvents>(event: K, listener: DataBridgeEvents[K]): this;
|
|
144
|
+
once<K extends keyof DataBridgeEvents>(event: K, listener: DataBridgeEvents[K]): this;
|
|
145
|
+
emit<K extends keyof DataBridgeEvents>(event: K, ...args: Parameters<DataBridgeEvents[K]>): boolean;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export { DataBridge, type DataBridgeEvents, type DataBridgeOptions, ResilientDataBridge, type ResilientEvents, type ResilientOptions, DataBridge as default };
|