Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/transport/gatt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export async function connect(): Promise<RpcTransport> {
// Reconnect to the same device will lose notifications if we don't first force a stop before starting again.
await char.stopNotifications();
await char.startNotifications();

let vc = (ev: Event) => {
let buf = (ev.target as BluetoothRemoteGATTCharacteristic)?.value
?.buffer;
Expand All @@ -47,14 +48,22 @@ export async function connect(): Promise<RpcTransport> {
};

dev.addEventListener('gattserverdisconnected', cb);

},
});

let writable = new WritableStream({
let writableWithoutResponse = new WritableStream({
write(chunk) {
return char.writeValueWithoutResponse(chunk);
},
});

return { label, readable, writable };
let writableWithResponse = new WritableStream({
write(chunk) {
return char.writeValueWithResponse(chunk);
},
});

return { label, readable,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we defer creation of the two writables until this ternary resolves, to avoid the spurious object creation?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just made an update, how does that look?

writable: char.properties.writeWithoutResponse ? writableWithoutResponse : writableWithResponse };
}