BleManager | ble library and sample | Networking library
kandi X-RAY | BleManager Summary
kandi X-RAY | BleManager Summary
ble library and sample
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the BluetoothDevice
- Display a character
- Convert hex string to byte array
- Connect to Bluetooth
- Initialize BluetoothManager
- Initializes the BluetoothManager
- Opens the result fragment
- Start Bluetooth scan
- Process a Gatt characteristic
- Read a characteristic
- Enable notification of a given characteristic
- Update LogModel
- Convert byte array to hex string
- Update Bluetooth service
- Convert byte array to hex string
- Handle connection state change
- From interface Adapter
- Disconnect the binding
- Registers a ViewHolder onBindViewHolder
- Invoked when the activity has been clicked
- Releases resources
- OnBindViewHolder method is called onBindViewHolder
- Print the stack trace of this method
- On bind view holder
- Print the debug log
- Print an error message
- Print a log message
BleManager Key Features
BleManager Examples and Code Snippets
Community Discussions
Trending Discussions on BleManager
QUESTION
I am having trouble with understanding why the code below will not compile. I'm getting an error stating that I must conform to ObservableObject and I cannot see why I wouldn't be.
I've simplified to show that I am seeing. I have two classes. The second observes the first and then the view observes the second.
First Class
...ANSWER
Answered 2021-May-04 at 21:06ObservedObject is a property wrapper mainly for Views. Use Published instead..
QUESTION
I'm learning iOS vs OSX BLE.
I notice that I can't instantiate CBCentralManager in iOS because of:
ANSWER
Answered 2021-Apr-06 at 16:21See the main Core Bluetooth docs:
Your app will crash if its Info.plist doesn’t include usage description keys for the types of data it needs to access. To access Core Bluetooth APIs on apps linked on or after iOS 13, include the NSBluetoothAlwaysUsageDescription key. In iOS 12 and earlier, include NSBluetoothPeripheralUsageDescription to access Bluetooth peripheral data.
QUESTION
I am a new in Bluetooth connection and I want to add second device in my iOS project. I already have one device, and the new device is very similar with first one, but little bit deferent. I have one process for the two devices, and I did not change a lot of code, just created all value for the new device. My all devices have different name and identifier, first device is working fine.
For creating UUID values, I used UUID generator (https://www.guidgenerator.com/online-guid-generator.aspx).
...ANSWER
Answered 2021-Jan-08 at 06:18Receiving the same service and characteristic UUID for multiple BLE devices is perfectly normal and only means that all the devices offer exactly the same service.
For example: If you have two devices which measure the heart rate of a person, e.g. a smartwatch, both devices might offer the heart rate service with the same UUID.
If you want to differentiate between the device you can use the identifier which you received in step 3 of your provided log.
QUESTION
I have the following function in my Fragment -
...ANSWER
Answered 2020-Dec-27 at 16:47the easiest way to fix it is stop the scan when the fragment is destroyed
QUESTION
i used bluetooth low energy in my mobile app with react-native . and i want to just find other mobile devices, so i can't find any other mobile phone and theirs supported bluetooth low-energy , but i find my Smartwatch , well my question is bluetooth low energy can find other mobile phone or is just for Accessory?
and what are you advicing me to find other mobile phone .
my code
...ANSWER
Answered 2020-Oct-26 at 06:20Bluetooth Low Energy (BLE) works different than the "old" Bluetooth (Bluetooth Classic). As soon as you turn on Bluetooth your device is visible for Bluetooth Classic scans, but not for BLE scans.
To find a BLE device it's necessary that the device advertises its present. That's one of the differences between BLE and Bluetooth Classic and allows small accessories to save power. You need to run a GATT Server on your other phone and advertise a service. One very generic tool that would work is nRF Connect.
Please read more about how BLE works.
QUESTION
I'm looking at the open source Bluefruit code as an example, specifically the BleManager class that is the interface with the CBCentralManager. I've emailed the author and they didn't respond:
It looks like the class is designed in a singleton architecture ("shared" on line 23) and so is constructed lazily when the first "BleManager.connect() is called elsewhere in the code.
What confuses me is in the init(), there's a semaphore "wait" function:
...ANSWER
Answered 2020-Oct-25 at 20:52They are using the semaphore to block any operations on the BleManager
object until the central exits the .unknown
state.
The semaphore is created with an initial value of 1. The wait
in the init
will decrement it to 0, and not block. The central is then initialised and at some point the powered on state is entered. At this point the signal
will return the semaphore to 1.
Now looking at the other functions, such as the connect
function (line 167) you will see the first thing they do is wait
and then signal
the semaphore. Consider what happens in two different states:
- The central is not yet in the
.poweredOn
state - the semaphore count is 0 so thewait
blocks. Assuming the BLE state becomes.poweredOn
at some point, thewait
will end and the semaphore is immediately released and then theconnect
function proceeds. - The central is already in the
.poweredOn
state - the semaphore count is 1, so thewait
does not block, the semaphore is then immediately released and theconnect
function proceeds.
The other functions work in a similar way.
The advantage of this approach is that the calling code doesn't need to keep checking the state; it can access the sharedInstance
and then immediately call startScan
without needing to check that the Central is powered on.
QUESTION
I am seeing some strange behaviour on a Pixel 4XL (Android 11). My foreground service's onTaskRemoved is being called unexpectedly. This doesn't occur on any other devices but I don't have any other Android 11 devices and the emulator can't do BLE.
My app uses an ongoing BLE connection to communicate with another non-android device. A foreground service is used to ensure the program remains active to receive BLE communications from the device.
It doesn't always happen but in most cases (75% of the time) after pressing home (swiping up from the bottom of the screen on a Pixel 4XL) this will cause the foreground service's onTaskRemoved to be called.
Opening a different activity in my app (i.e. an activity other than MainActivity) is almost guaranteed to make this occur.
Opening settings from the notification bar then swiping home still triggers this to occur, so it can't be that I'm accidentally killing the app since I'm swiping up when the settings app is in focus.
From my understanding, this method is only supposed to be triggered when the user terminates the app by swiping it in the task switcher.
If I go back to the task switcher, after the service was killed, my app is still available and showing the last activity opened and it's state. Switching to it resumes to the correct place, so the app itself must not have been terminated. The phone is plugged in an charging so it shouldn't be and doze/sleeping functions. This can occur within 60 seconds of launching the app, it's not a 30 minute thing.
What on earth could be going on here? The only thing I can think of is that it's not considered a foreground service for some reason. There are no errors in logcat at or around the time of the onTaskRemoved. I am not calling onTaskRemoved myself anywhere in code.
I've tried following the dumpsys in this post but it seems to be different and I couldn't find any of the references mentioned.
The notification itself is listed like this:
...ANSWER
Answered 2020-Oct-07 at 01:07For me, changing the activity launch mode away from singleInstance
resolved the problem.
Change
QUESTION
I am trying to return data from the BlueTooth device after connected because to use the read and write function, need some data.
Example data name, overflowServiceUUIDs, solicitedServiceUUIDs, mtu, rssi...
and many others. Because if I want to read or write I need some attributes. I am using the library react-native-ble-plx
.
After the device connected I lost some values.
Important ...ANSWER
Answered 2020-Oct-04 at 22:35Checking the lib you're using, it creates another device object from the reponse it gets when calling the native module, it could be the case this new object comes with null values on those fields and replaces the values you need. Because it's just as it works by now, you could copy those values to another object before they get erased
QUESTION
I am having issues running some asynchronous code in a bluetooth RN app.
I am trying to create a listener function that does the following: connect to a device (using an async function), log that I have connected, then disconnect from the device (using an async function).
This listener function is provided as a parameter to a bluetooth low energy (ble) device scan function:
...ANSWER
Answered 2020-Oct-02 at 03:37@Jaromanda X provided the solution:
The fix was to add try catches around the connectToDevice() and cancelDeviceConnection() async functions as they were getting rejected and the the listener would return (hence why the 'Connected to Device' log never printed).
QUESTION
I'm developing an App in Swift 5 that connects to a wereable device that measure body information (temperature, heart rate, etc.)
For measure this information, I have to write a Data object in one characteristic of the device (and recieve the information in other characteristic with notifications activated), and now i have to measure it every 30 minutes, so i have to create a timer with repeata every 30 minutes to execute that "write" in the BLE characteristic. (All the options in Capabilities are already activated - bluetooth-central, bluetooth-peripheral, background-processing, background-fetch)
I've read a lot of topics in Stackoverflow and there are people that says that you can't write to BLE in background and other that say that you can.
Before to implement all the posibilities i've read: ¿It's possbile to execute every 30 minutos a task to connect to a device, set notification to true to one characteristic, and write a Data object in one characteristic in Background Mode?
If the response is "Yes", is there any code that I have to implement apart from the corresponding bluetooth methods that already work in the foreground?
I've not attach my BLEManager class (centralManager) because is the "standard" from the Apple Documentation, but if you need, ask me and I'll attatch it.
Thank u all!
...ANSWER
Answered 2020-Aug-20 at 08:37It's possible to use CoreBluetooth in background mode: https://developer.apple.com/library/archive/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothBackgroundProcessingForIOSApps/PerformingTasksWhileYourAppIsInTheBackground.html
Note a few caveats here:
To perform certain peripheral role tasks while in the background, you must include the UIBackgroundModes key with the bluetooth-peripheral value in your app’s Info.plist file. When this key-value pair is included in the app’s Info.plist file, the system wakes up your app to process read, write, and subscription events.
I think you can wake the app directly with the peripheral, but scheduling probably won't work.
Upon being woken up, an app has around 10 seconds to complete a task
Not sure what you're trying to do, but you're time limited so keep that in mind as well.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install BleManager
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page