Commit graph

34 commits

Author SHA1 Message Date
Christopher Willis-Ford
7daf7143fe style(Win): apply automatic code cleanup 2023-06-01 14:52:19 -07:00
Christopher Willis-Ford
798c92166e refactor(macbt): add more logging to MacBT discovery 2023-04-06 13:26:01 -07:00
Christopher Willis-Ford
23ff634560 fix(win): discover both paired and unpaired BT devices 2023-03-01 15:39:25 -08:00
Christopher Willis-Ford
9ecc2ad57f refactor: clarify that PeripheralSession tracks discovered peripherals
Windows will use different types for discovered peripherals vs.
connected peripherals, so it's now important to distinguish between the
two types.
2023-01-30 09:36:53 -08:00
Christopher Willis-Ford
e51fa01b79 fix: make didDiscoverPeripheral a notification
The `didDiscoverPeripheral` message was already a notification for BLE,
and should also be a notification for BT.
2023-01-13 08:21:38 -08:00
Christopher Willis-Ford
616ed440cc chore: move StyleCop settings to a shared props file 2023-01-13 08:21:38 -08:00
Christopher Willis-Ford
f59d16112d chore: convert remaining Debug logging to Trace 2023-01-13 08:21:38 -08:00
Christopher Willis-Ford
907ea9158e chore: add logging to help debug macOS 10/11 issues 2023-01-13 08:21:38 -08:00
Christopher Willis-Ford
53bbe3b6e3 fix(MacBT): make BT disconnect/reconnect more reliable, especially after pairing 2023-01-13 08:21:38 -08:00
Christopher Willis-Ford
a55075b81d refactor(bt): support PIN code argument for Connect 2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
9032a013c8 fix(common): remove EventAwaiter(EventHandler<T>, ...
Turns out that C# doesn't actually let you do this. It compiles and
runs, but just silently fails to hook the event. Something to do with
the EventHandler delegate magic... maybe a "+= on a struct" kind of
thing?
2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
d53d5c8a9d fix(common): make session immediately so we don't miss the first message
The previous code dropped the very first message on the very first
session for a given instance of the application.
2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
eed937fd18 fix: fix DisposedException by removing cancellation token
We really use the socket state to control the session, so there's no
need to also pass a CancellationToken around. The exception was being
caused when an unlucky callback happened after a session was disposed
and the callback tried to get a new token to check cancellation. If the
token source is already disposed, it can't provide a new token.

Also, remove some excessive logging and add more exception logging.
2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
5bae1ea319 fix(Mac): fix Safari, especially Link->Client notifications 2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
72a0308e9c Mac: fix symbols being optimized out
Using "SdkOnly" instead of "Full" doesn't increase the app size by even
1MB, and it no longer leads to seemingly random crashes due to some part
of the code being optimized out.
2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
953144379d Mac: misc reliability improvements
An `EventAwaiter` timeout now throws a `TimeoutException` instead of a
`TaskCanceledException`.

Disconnecting a micro:bit while subscribed for change notifications was
causing an exception because a notification was being triggered after
the socket closed. Fixing that led to an attempt to close the socket
after it was closed and set to `null`. That one was solved with a null
check.

For BT, connection is still not reliable but it's a step in the right
direction... I think. The socket lock is now held while opening the
RFCOMM channel, which is an awful long time to hold a lock, but really
no other thread should be messing with the socket during that time so I
guess it's the right thing to do. I also added debug printouts on the
RFCOMM event delegate.
2023-01-13 08:21:37 -08:00
Christopher Willis-Ford
db051ddf65 Mac: add status bar item 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
ffc72af923 BT: fix property name typo 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
a7314886f4 minor JsonElement TryGetProperty cleanup 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
bddf0dc50f clean up JsonRpc2Exception a bit 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
7ec18de421 share BTSession's address privacy implementation with BLESession 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
0b0b8802a8 add an extension to lock a SemaphoreSlim with 'using' 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
3cd2113daf Mac BT: implement 'didReceiveMessage' 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
aa15fd0be2 Mac BT: implement send() 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
5312199e6b Mac BT: implement 'connect', remove 'ouiPrefix' 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
8fa4207a2b Mac BT: implement discovery tracking with device address privacy 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
8193d33f6d implement Mac BT discover 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
37f5cde173 implement enough BTSession to test Mac BT libs 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
ac5e4a4431 close BLE session if the device disconnects 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
172fc2c534 switch to Fleck for WebSockets 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
8be1d8b021 make ScratchLinkApp to take the place of MAUI app
Note that this builds and runs, but doesn't work: the Xamarin.Mac
implementation of `System.Net` always sets `IsWebSocketRequest` to
`false` and doesn't actually support WebSockets connections as a server.
2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
2c9e4c600a fixed usings and namespaces 2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
2897e2d16f begin splitting scratch-link into scratch-link-{common,mac}
Note that this currently doesn't build since the files have not yet been
adapted to the new framework.
2023-01-13 08:21:36 -08:00
Christopher Willis-Ford
a929cf2bbe add empty Xamarin projects for Mac & common code 2023-01-13 08:21:36 -08:00