Getting Bluetooth Device Paired[Technical Questions] #118
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
Thank you for reaching out @nick-allen21! You will need to run the application on a physical device to test any Bluetooth-related functionality. It won't work on the simulator or preview as the stack there doesn't have access to the macOS bluetooth stack. You can find more instructions how to run the app on your phone here: https://developer.apple.com/documentation/xcode/running-your-app-in-simulator-or-on-a-device. Happy to use some time in the class today to see how we can work on that and show you how to run the app on your phone. |
Beta Was this translation helpful? Give feedback.
-
Hi All, here is how I ended up getting around the Bluetooth Issue if anyone ends up with the same problem. Step 1) Add the Spezi Bluetooth module to your Xcode app. You need to download the bluetooth and add it as a dependency. Instructions for this can be found in the Stanford Spezi Bluetooth module Step 2) Download the app LightBlue. LightBlue allows you to connect to any bluetooth device. Your phone only filters to distinct set of devices that Apple has authorized prior. On LightBlue you will find your device. Once connected, step into the page for your device, and you will see something called an advertised service. Step 3) Go to your SpeziAppDelegate. You need to add the following code. anywhere in the Configuration section Advertised_Service_String = "String from step 1" ` Bluetooth { Step 4) Go to the info.plist file. Add 'NSBluetoothAlwaysUsageDescription' as a key with the string "This app uses Bluetooth to connect to external devices for enhanced functionality." or something along the likes. This will allow the proper privacy functions for connecting to an external bluetooth device. Step 5) We are now ready to make our view and find our device. Create a custom class for your device
} ` struct MyView: View {
} Then when your preview, make sure to inject the device into the environment
Step 6) Awesome, now we are ready to test it out. In order to test, we need to use an actual iphone or device. The preview menu does not have access to that part of the stack. I would recommend connecting your iphone to your computer and downloading the app as a developer. |
Beta Was this translation helpful? Give feedback.
Hi All, here is how I ended up getting around the Bluetooth Issue if anyone ends up with the same problem.
Step 1) Add the Spezi Bluetooth module to your Xcode app. You need to download the bluetooth and add it as a dependency. Instructions for this can be found in the Stanford Spezi Bluetooth module
Step 2) Download the app LightBlue. LightBlue allows you to connect to any bluetooth device. Your phone only filters to distinct set of devices that Apple has authorized prior. On LightBlue you will find your device. Once connected, step into the page for your device, and you will see something called an advertised service.
You want to get this advertised service code, which will be the cus…