Playground Bluetooth

RSS for tag

Display and manage connections to Bluetooth peripherals in Swift Playgrounds using Playground Bluetooth.

Posts under Playground Bluetooth tag

6 Posts
Sort by:

Post

Replies

Boosts

Views

Activity

When iOS17 has a bug and cannot record audio, play the audio to a Bluetooth device
let session = AVAudioSession.sharedInstance() do { try session.setCategory(AVAudioSession.Category.playback) try session.setActive(true) //playAndRecord <AVAudioSessionPortDescription: 0x2828dc2b0, type = Speaker; name = 扬声器; UID = Speaker; selectedDataSource = (null)> //playback <AVAudioSessionPortDescription: 0x28204c1a0, type = BluetoothA2DPOutput; name = M2; UID = 00:02:5C:22:22:11-tacl; selectedDataSource = (null)> print(session.currentRoute.outputs) } catch { print(error) } when I ssession.setCategory(AVAudioSession.Category.playback) audio play output a2dp ble devices. session.currentRoute.outputs print bellow `<AVAudioSessionPortDescription: 0x28204c1a0, type = BluetoothA2DPOutput; name = M2; UID = 00:02:5C:22:22:11-tacl; selectedDataSource = (null)> when I ssession.setCategory(AVAudioSession.Category.playAndRecord) output <AVAudioSessionPortDescription: 0x2828dc2b0, type = Speaker; name = 扬声器; UID = Speaker; selectedDataSource = (null)> BluetoothA2DPOutput is gone. but it is normal in ios15-16. Is there any solution? I want to record audio and play music at the same time. And the music is output from the Bluetooth speaker
1
0
455
Dec ’23
Bluetooth Device Implementation
Hello all, I am interested in trying to develop a short-medium range (>100 meters) tracking device for a hobby project in order to gain some literacy in mobile phone software, and have a few questions. I am new to working with anything iOS so please correct me in any mistakes I make in this query. Is RFID or Bluetooth better for tracking and implementation on iOS? How difficult is device implementation into iOS and apps such as find my iPhone? How would one go about it? If I wanted a tracking device to send notifications based on location/distance from another device, could I do that with Apples framework or would I have to create my own app? What programming language would be used in this sort of endeavor? Would C++ work or does iOS use different ones? Thanks in advance, any and all advice is greatly appreciated.
1
0
536
Sep ’23
AVAudioSession allowBluetoothA2DP not working on external device iOS17 playAndRecord session
I saw a similar post to this where the issue was fixed in the final iOS17 release, but I am still having a problem since my situation is slightly different. I am wondering if its a bug based on current behavior, but was hoping maybe someone knows if the issue is with my setup? I am trying to monitor an external USB camera's audio input using the new iOS17 external call for iPad, over bluetooth. func setupAudioSession() { let audioSession = AVAudioSession.sharedInstance() do { try audioSession.setCategory(.playAndRecord, mode: .default, options: [.allowBluetoothA2DP, .defaultToSpeaker] ) try audioSession.setActive(true) } catch { print("Failed to set up audio session: \(error)") } } When my execution order is: setupAudioSession() // code above // discover and connect the session AV inputs to the external USB // start an audio engine // connect audio engine output to a buffer queue and play // start the session My app does not allow routing to the headphones and directly switches to speaker. However if I change the order to this: setupAudioSession() // code above // discover and connect the session AV inputs to the external USB // start an audio engine // start the session --- !starting before connecting output! // connect audio engine output to a buffer queue and play The session stays connected to Bluetooth and plays over the headphones. However if I suspend the app and relaunch, I get switched back to speaker. I understand maybe the system is trying to prevent an audio feedback loop? But don't understand why launching the session early would get the desired behavior. Any help would be greatly appreciated.
1
1
674
Oct ’23
iOS Health Application Bluetooth Data Transfer - Background Processing Issue
Hello, Our application is a health application that functions alongside a device transferring data via Bluetooth. There is continuous data transfer happening from this device. However, when operated on an iOS device, the application gets cut off in the background after a certain duration, negatively impacting the user experience. As is known, the background services of an application being terminated after a certain period is generally associated with how iOS manages system resources. In our case as well, we came across this issue before we implemented a formatted background task. Therefore, to address this situation, we used a formatted background task in our application, but the problem still persists. Unable to resolve the issue, we decided to analyze how other Bluetooth devices work on iOS devices. For example, when an electronic watch is connected, the Bluetooth connection never gets cut off. However, why can't we achieve the same performance with our device? I would be extremely grateful if you could shed technical insight on this matter and share your experiences. Furthermore, if you have any recommendations on how to handle such situations, I would love to hear all about them. Thanks in advance for your help.
1
1
849
Jul ’23
Bluetooth ANCS don't send ringing alarm clock and countdown timer
Hello everyone, sorry for my ignorance about it, with ANCS I managed to get all the notifications except the alarm that rings and the timer expired, where am I wrong? do they travel on other channels like gatt? if yes can someone help me understand how to receive these 2 information? the alarm goes off and the timer expired? Thanks in advance to everyone who will help me, Marco.
1
0
1.1k
Aug ’23