Bluetooth | android 蓝牙开发 android 打开 、 搜索 、 配对 、 连接 、 通信 发送文字 、 传输默认文件
kandi X-RAY | Bluetooth Summary
kandi X-RAY | Bluetooth Summary
Android 蓝牙开发 Android 打开、搜索、配对、连接、通信 发送文字、传输默认文件.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Initializes the state of the bridge
- Initialize the titlebar
- Connect to bluetooth device
- Creates the activity
- Region List View
- Start scan
- Start bluetooth server
- Initialize thread pool executor
- Click BLT
- Required by Android adapter
- Check if BluetoothAdapter is enabled
- Initialize view
- Initialize the view
- Sets the status bar to show when the app is created
- Receive a message from bluetooth socket
- Handle view clicked
- Layout layout
- Removes an action from the action bar
- Adds a list of actions
- Callback method for receiving Bluetooth devices
- Bind bluetooth device
- Get bond list
- Set custom title view
- Register blt event receiver
- Calculate the layout
- Receive message event
Bluetooth Key Features
Bluetooth Examples and Code Snippets
Community Discussions
Trending Discussions on Bluetooth
QUESTION
I have an app that communicates with a bluetooth device, and I'm trying to replace that app with some code.
I tried using C# InTheHand nuget, Microsoft's Bluetooth LE Explorer, python's sockets and others to send data and see what happens.
But there's something I still don't understand - in each way using different libraries I saw in wireshark a different protocol: ATT, RFCOMM, L2CAP...
When I sniffed my bluetooth traffic from my phone using the app mentioned before, I saw mostly HCI_CMD protocol traffic.
How can I choose the protocol I want to send? Is there a simple package for that? something to read?
Do I need to build the packet myself? including headers and such?
Thank you!
Update:
Using Microsoft's Bluetooth LE Explorer I was able to send a packet that lit up my lamp, starting with 02010e10000c00040012(data)
Using bleak I was able to send a packet starting with 02010e10000c00040052(data)
the difference makes the lamp not ligh up and I'm not sure if I can change it via bleak as it's not part of the data I send
ANSWER
Answered 2021-Jun-14 at 18:48I think what you are showing is that bleak does a write without response
while MS BLE Explorer does a write_with_response
.
Looking at the Bleak documentation for write_gatt_char
that seems to be consistent as response
is False
by default
write_gatt_char Parameters:
char_specifier (BleakGATTCharacteristic, int, str or UUID). The characteristic to write to, specified by either integer handle, UUID or directly by the BleakGATTCharacteristic object representing it.
data (bytes or bytearray) – The data to send.
response (bool) – If write-with-response operation should be done. Defaults to False.
I would expect the following to have the desired effect:
QUESTION
I am a newbie to RXKotlin/RXJava. I am developing the background service in Android.
In my service, I have
- Bluetooth socket
- TCP Socket
Whenever the data is available on the Bluetooth socket, read and write to the TCP socket. And whenever data is received in the TCP socket, write to the Bluetooth socket.
Can someone help me:
- how to achieve this using Observables?
- how to exchange the socket id information?
- how to exchange the data? Thanks
ANSWER
Answered 2021-Jun-14 at 08:16Please try using RxSubjects (https://blog.mindorks.com/understanding-rxjava-subject-publish-replay-behavior-and-async-subject-224d663d452f)
Let me take PublishSubject as an example here.
QUESTION
Right now I am developing web which has ability to connect thermal printer. I am using angular framework, and I successfully connect the thermal printer with USB using library ng-thermal-printer
. But I want to my web also being able to connect thermal printer via web bluetooth which is BLE (Bluetooth Low Energy). As far as I know, BLE has specification in term of GATT and has services and characteristics in it.
The progress I did so far, I can connect and send a value to the thermal printer device in a Service and a Characteristic, let's say Service with UUID AS and Characteristics with UUID AC, using my android phone with the help of application named nRF Connect. Targeting Service AS and send hexadecimal value at charateristic AC make me successfully print something on the thermal paper.
But there is a problem. After knowing the right service and characteristic. I implemented it in my project. But, my chrome browser console showed error:
- Origin is not allowed to access any service... and it told me to add optionalServices when requestiDevice()
- After I added Service AS in property optionalServices, the console showed error DOMException: Connection failed for unknown reason. The errors showed both in chrome PC and chrome android.
NB:
- I have enabled Experimental Web Platform features on chrome
- I have enabled Use the new permissions backend for Web Bluetooth on chrome
- I have enabled Allow invalid certificates for resources loaded from localhost. on chrome
- I have enabled Enable new USB backend on chrome
- I have used https.
Additional question. is bluetooth connection that application nRF Connect used different from BLE? if so, why it displays services and characteristics?
...ANSWER
Answered 2021-Jun-14 at 07:34I'd recommend you try sending those hex values directly from the about:bluetooth-internals
page and see if you can reproduce the connection error from there as well. See https://web.dev/bluetooth/#tips
If so, check out https://www.chromium.org/developers/how-tos/file-web-bluetooth-bugs to learn how to properly file a chromium bug so that the team can fix the underlying issue.
If not, could you share your JS code so that we can help you diagnose what could be going wrong in your code?
QUESTION
I'd like to send a beacon signal from my mobile web browser. Is there a way to broadcast BLE in a browser? I checked the non-standard Bluetooth API, but there was no such function.
Thank you for reading it.
...ANSWER
Answered 2021-Jun-14 at 06:31Unfortunately there doesn't seem to be support for this yet. There's an open request for this feature as can be seen here:-
- https://bugs.chromium.org/p/chromium/issues/detail?id=1043409
- https://github.com/WebBluetoothCG/web-bluetooth/issues/231
More information about web bluetooth support is found here:-
QUESTION
I have been trying to install Angular but everytime this part:
@angular/cli@12.0.3 postinstall C:\Users\Marco\AppData\Roaming\npm\node_modules@angular\cli
node ./bin/postinstall/script.js
Seems to throw an error. I'm not sure if I need this to work or not so I'll leave the last couple lines of the log here.
...ANSWER
Answered 2021-Jun-12 at 16:10I fixed it by going to the actual file location of script.js and running the node command with that path. Like this:
node AppData/Roaming/npm/node_modules/@angular/cli/bin/postinstall/script.js
Actually that only helped a little bit. The problem was I was trying to install Angular using ConEmu GitBash and I should've been using cmd.
QUESTION
I need to check if my Xamarin.Forms
app has bluetooth permission and if not I would like to request it. I have been able to implement this as a Dependency service for Android but I do not know how to do it for iOS. I have seen some articles mentioning some differences between how this works on ios 13 vs earlier versions, but they have not been very clear.
I tried checking and testing on an iPhone 6s running ios 12.2 with this code:
...ANSWER
Answered 2021-Jun-12 at 04:29Apple introduced bluetooth permission from iOS 13.
Hence, you do not required to request or check Bluetooth permission for iOS 12 and below.
To enable Bluetooth, two keys have to be added in the plist file. Privacy — Bluetooth Peripheral Usage Description and Privacy — Bluetooth Always Usage Description. Give the description of why you want to use Bluetooth in your app.
Xamarin.Forms shared PCL code Dependency service interfaceQUESTION
I am implementing an APP with Xamarin.
I want to perform a Bluetooth scan. And get the device found.
Here is my code.
How could I implement this to start a scan and collect the result once"Button_Scan()" is triggered?
Thank you.
...ANSWER
Answered 2021-Jun-10 at 06:47You have defined a BluetoothReceiver
to receive the result ,you just add the device information into a deviceList
.
QUESTION
I run my Android app (based on Java), and it works. Next, I add to my app code:
FirebaseFirestore fdb = FirebaseFirestore.getInstance();
This code I got from the official Android site https://firebase.google.com/docs/firestore/quickstart
App runs, but next the running device shows the message "app has stopped".
I use a device simulator available in Android Studio.
It is my first Android app, and I can't understand what is going.
----Trace------ 2021-06-08 20:57:30.186 7155-7155/? D/AndroidRuntime: >>>>>> START com.android.internal.os.RuntimeInit uid 2000 <<<<<< 2021-06-08 20:57:30.188 7155-7155/? D/AndroidRuntime: CheckJNI is ON 2021-06-08 20:57:30.210 7155-7155/? W/art: Unexpected CPU variant for X86 using defaults: x86 2021-06-08 20:57:30.214 7155-7155/? D/ICU: No timezone override file found: /data/misc/zoneinfo/current/icu/icu_tzdata.dat 2021-06-08 20:57:30.229 7155-7155/? E/memtrack: Couldn't load memtrack module (No such file or directory) 2021-06-08 20:57:30.229 7155-7155/? E/android.os.Debug: failed to load memtrack module: -2 2021-06-08 20:57:30.230 7155-7155/? I/Radio-JNI: register_android_hardware_Radio DONE 2021-06-08 20:57:30.239 7155-7155/? D/AndroidRuntime: Calling main entry com.android.commands.am.Am
...ANSWER
Answered 2021-Jun-09 at 03:39At the end of your log, just before the initial crash. there is a warning:
Default FirebaseApp failed to initialize because no default options were found. This usually means that com.google.gms:google-services was not applied to your gradle project.
simply adding com.google.gms:google-services
should fix any issues you have, if you have issues, ensure your Gradle cache is cleared or run without the build cache
--no-build-cache
QUESTION
I need to run a batch file only if it's connected to Wifi and specifically not Bluetooth LAN
I have this code but it returns this and still runs the code while an internet connection isn't present
...ANSWER
Answered 2021-Jun-07 at 05:58You don't need a for
loop:
QUESTION
i am building an ecommerce website and i'm trying to add category button on the home page so that when you click a specific category, only those items will show. I am using redux to bring all the items to the home screen.
...ANSWER
Answered 2021-Jun-06 at 19:28You can create a state variable that will have the selected category name. Before you render products filter the products which have the category as selected category.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install Bluetooth
You can use Bluetooth like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the Bluetooth component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
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