T
T
Terroris3372021-10-14 22:33:25
Android
Terroris337, 2021-10-14 22:33:25

How to send data to mac address BLE Android?

There is a ListView with found devices.

boxesListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                Box selectedBox = (Box) adapterView.getItemAtPosition(i);
               
                BluetoothDevice device = adapter.getRemoteDevice(selectedBox.getMacAddress());
                device.connectGatt(BoxesActivity.this, false, new BluetoothGattCallback() {

                });
            }
        });


By clicking on the list item, you need to send data to mac address (string). Do I need to make a connection to send data (if necessary, how)?
Or can I send directly to the mac address?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2021-10-15
@402d

data is sent to the low-energy device by
writing to the desired characteristic.
Thus, knowing only the poppy address is not enough.
So far you only have two lines (address and text).
Bluetooth devices are still classic and combined (dual).
It's easier with the classics, there you can open a channel to "00001101-0000-1000-8000-00805F9B34FB"
But with plaques, the main headache is the lack of standardization where to write.
If it's stupid in everything that has a record attribute, then you can run into a device flashing.
Therefore, you can only write there with what you figured out. Those. Before writing, it would be good to check if you have slipped a compatible device.
https://github.com/weliem/blessed-android
mess around with this library

A
anikavoi, 2021-10-15
@anikavoi

https://developer.android.com/guide/topics/connect...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question