Skip to content

WIP: Bluetooth functionality

Gordon Martin requested to merge bluetooth into develop
  • Load ssb-bluetooth scuttlebot plugin at startup
  • Configure bluetooth multiserv plugin
  • Load react-native-bluetooth-serial at startup
  • Establish bluetooth control socket bridge to scuttlebot plugin.
  • ssb-mobile-bluetooth-manager: receive app path as argument
  • 1ETH (to happy0) Fix addresses multiserver-bluetooth
    • multiserver bluetooth addresses cannot be the remote MAC raw, because : are not allowed. we need to convert 65:D9:00:DD:B3:53 to 65D900DDB353 and add the colons back only when we're about to give it to the Java module
    • multiserver-bluetooth needs to be fixed how it handles address strings. parse() is correct, but stringify() is wrong, and client(addr) should assume addr looks like bt:65D900DDB353 not the MAC address directly. see https://github.com/dominictarr/multiserver-address
  • 1ETH (to happy0) staltz/sbot-gossip needs to be modified so that gossip.connect() and gossip.add() also accept BT addresses
  • 1ETH (to happy0) peers first exchange SSB id through Bluetooth, not through QR code or similar
  • Close bluetooth related sockets / threads if bluetooth is disabled?
  • Refactor ssb-mobile-bluetooth-manager (tidy up code.)?
  • 0.5ETH Replace debugging console.logs with the npm package debug
  • Remove stale functions from react-native-bluetooth-serial fork (since control bridge does the work.) Refactor to remove circular dependencies.
  • 0.5ETH (to happy0) Add a bluetoothState source to the functions made available by ssb-bluetooth which emits the state of the bluetooth scan.
  • 0.5ETH (to happy0) remove hard coded paths from ssb-mobile-bluetooth-manager

Bugs (Happy0) :

  • Make the metadata service server stop when the discoverability period ends.
  • Are commands lost if there's too many writes across the command unix socket bridge at once? Is the marshaller swallowing too much text at once or something?
  • onActivityResult is no longer being called in react-native-bluetooth-socket-bridge , which means the callback for 'makeDeviceDiscoverable' is never called back with success / failure. Also, the code doesn't allow you to click this before the callback is completed. There's a bunch of oddness around onActivityResult for react-native on google ( https://github.com/expo/expo/issues/651 ) so it may be that the solution to this has to be 'fire and forget' (we'll see) :.
  • the TypeError: Cannot set property 'stream' of undefined issue identified by André. There's a couple callbacks in play for outgoing connections in ssb-mobile-bluetooth-manager. Perhaps my assumptions about which one is called first are wrong. Seems like some race / event loop shenanigans. I have an idea or two about how to sort this edge case (if my theory is right.)

UI

  • Allow user to make their device discoverable by other devices for a limited time (to allow incoming connections.)
  • List bluetooth peers that we are not connected to
  • 0.5ETH (to staltz) Functionality to connect to a bluetooth peer
    • Follow, gossipConnect, and gossipAdd upon clicking staged peer
    • Automatically ask Android permission for location
    • Remove staged peer once connection is established
  • 0.25ETH (to staltz) List bluetooth peers that we are connected to
  • 0.25ETH Bluetooth symbol lights up only if Bluetooth is active on the device or OS
  • 0.5ETH Show status of Bluetooth discovery, peer-validation, and replication
  • In-app Bluetooth enable / disable button (let's make in-app buttons for all connectivity modes, later)
  • Verify ssb-bluetooth mux-rpc functions make sense from UI perspective
  • Fix: if you press the staged bluetooth peer a second time, we should NOT publish a follow message twice
  • Test in the real world

Before merging:

  • 0.23ETH Rebase and/or rename some commits to follow the dx: ... or ux: ... commit message convention
Edited by staltz

Merge request reports