bluetooth

How to do a string compare with the incoming message

跟風遠走 提交于 2020-02-16 06:33:10
问题 I know it sounds simple but I got some trouble with it. I am trying to make a system with a pic Microcontroller (MCU) and an xamarin android app. The sending part from app to the pic MCU is solved but when I want to send data from the MCU to the app it won't go as flaweless. I am using a HC-06 as a bluetooth device for receiving and sending messages. The code for receiving from the MCU to the app is: public void beginListenForData() { try { inStream = btSocket.InputStream; } catch

Android Bluetooth ScanFilter Partial String Matching

落爺英雄遲暮 提交于 2020-02-15 08:01:07
问题 I'm looking to use a ScanFilter to search for a set of bluetooth devices. I know the address of all these devices starts with 00:A0:50, and then the last 6 digits vary, so all addresses will look like 00:A0:50:XX:XX:XX. I'm looking for a way to use setDeviceAddress to find devices with addresses beginning with those 6 digits. This takes a string as input. The relevant code is below. ScanFilter cypressFilter = new ScanFilter().Builder() //we know that their mac address will always start with

How to extract latitude and longitude from location_and_speed characteristic?

那年仲夏 提交于 2020-02-06 04:26:24
问题 In an Android app in central role - how do you please get a hold of the latitude and longitude stored in the org.bluetooth.characteristic.location_and_speed characteristic in the org.bluetooth.service.location_and_navigation service of a BLE peripheral? I am trying the following Java-code - private float mLatitude; private float mLongitude; private static final UUID LOCATION_AND_NAVIGATION = UUID.fromString("00001819-0000-1000-8000-00805f9b34fb"); private static final UUID LOCATION_AND_SPEED

iOS BluetoothManager Framework

为君一笑 提交于 2020-02-04 02:37:27
问题 I understand the BluetoothManager Framework is part of the private API, but I'm curious if anyone has any experience working with it. I'm able to turn Bluetooth on and off, but I'd like to get a list of devices. Calling the pairedDevices method seems to write all the info I need to the log, but doesn't return an array of devices. 回答1: You can get the list of devices, by registering a notification for discovered devices, and then triggering the discovery itself. The incoming notification

How to switch audio output from Phone, Phone Speaker, earphones or Bluetooth device

徘徊边缘 提交于 2020-02-03 23:38:52
问题 Im trying to switch the audio source between different source in my app. We use a 3rd party Video Library and use AudioManager to play the sound. Now we are trying to have a UI option to select between audio output between Phone ear piece, Phone Speaker, Headphones/ Bluetooth (is any connected). Like we see in Phone Call app (when multiple audio output sources are available phone, speaker, bluetooth). 回答1: Got it working: 'if(false) { //For BT mAudioManager.setMode(AudioManager.MODE_IN

How to switch audio output from Phone, Phone Speaker, earphones or Bluetooth device

女生的网名这么多〃 提交于 2020-02-03 23:38:22
问题 Im trying to switch the audio source between different source in my app. We use a 3rd party Video Library and use AudioManager to play the sound. Now we are trying to have a UI option to select between audio output between Phone ear piece, Phone Speaker, Headphones/ Bluetooth (is any connected). Like we see in Phone Call app (when multiple audio output sources are available phone, speaker, bluetooth). 回答1: Got it working: 'if(false) { //For BT mAudioManager.setMode(AudioManager.MODE_IN

Android bluetooth send message working first time only

怎甘沉沦 提交于 2020-01-26 04:35:30
问题 I need to send string message from Raspberry PI to Android device. I am getting message first time only. After that it does not work at all. I am using PYTHON code in Raspberry PI. After first time, it is unable to search for a bluetooth device, which is running that UUID. However, if I restart Android application - again it works fine for first time. I am using AcceptThread as suggested here. I have not used ConnectThread or ConnectedThread in my application, as I need only incoming messages

First three characters missing from string when send from android via bluetooth

可紊 提交于 2020-01-26 04:15:48
问题 When I send "M" String to the Device I call time function from where I make my String. Code: ` mManButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { man = 1; clearScreen(); mManButton.setBackgroundResource(R.color.button_pressed); mStartButton.setBackgroundResource(R.color.button_default); mCalButton.setBackgroundResource(R.color.button_default); mTestButton.setBackgroundResource(R.color.button_default); mLinearButtton.setBackgroundResource(R.color.button

Android Bluetooth sending concatenated data at once

╄→гoц情女王★ 提交于 2020-01-25 20:59:11
问题 I am using Bluetooth Chat App code to transfer data between two android device. But the code is sending concatenated data. For example: When I try to send data like below: a b c d It sometime send data in this form: a bc d Here is my write code for sending data: public synchronized void write(byte[] buffer) { try { mmOutStream.write(buffer); mHandler.obtainMessage(BluetoothHelper.MESSAGE_WRITE, -1, -1, buffer) .sendToTarget(); mmOutStream.flush(); } catch (IOException e) { Log.e(TAG,

How to establish connection and then read characteristics in one activity?

有些话、适合烂在心里 提交于 2020-01-25 16:35:31
问题 Currently modifying the sample code and I am encountering an error when try to establish a connection and then read a characteristic in one activity. I am getting BleAlreadyConnectedException when attempting to read from the device. I am first connecting on onCreate. @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_device); // How to listen for connection state changes bleDevice.observeConnectionStateChanges()