Some days ago I have written this question: Is possible to detect touches in MiBand 2?
I discovered using Wireshark that when I pulse MiBand button, the band send a UUID code to the mobile device.
I modifed this sample https://github.com/googlesamples/android-BluetoothLeGatt to capture this event and for example show a Toast in screen. But However hard I tried, I do not advance.
Methods onDescriptorRead() and onCharacteristicRead() never called.
How is the way to capture this special characteristic using GATT in Android?
Thanks a lot
Related
I have viewed many unofficial MiBand SDKs in Github. (e.g. https://github.com/Freeyourgadget/Gadgetbridge) None includes detect when button touching, but I have viewed apps to detect this feature.
For example Mi Band 2 Func Button.
Also I have tried sniffing bluetooth data traces, but just show data because mobile device is not rooted and I haven't rooted.
Is there any way I can detect the touch of a miband button?
Thanks a lot!
You can listen if there is any touches event on the Mi Band device.
Assuming that the app authenticated...
Start notification to UUID_CHARACTERISTIC_DEVICEEVENT characteristic (In my case it's "00000010-0000-3512-2118-0009af100700")
and you shall receive '\x04' if the device touched.
I want to build a simple challenge response protocol in order to authenticate a user to an Arduino via the smartphone (Android and iOS) using BLE. I'm having problems seeing how this would be implemented with BLE. What I want to do:
Arduino sends/broadcasts a challenge
Smartphone receives challenge and computes response
Smarpthone sends response to Arduino
The way I thought about implementing this is to have the Arduino (peripheral and server) start advertising when a button is pressed. Ideally an event would be triggered on the smartphone (central and client) when a certain service shows up. Then the smartphone connects to Arduino, reads the challenge characteristic and writes the response to it. Is this a good approach?
It appears though that it is not possible to trigger an event when a BLE service appears and I would continuously need to scan with the smartphone which is very battery intensive. Not sure how to get around this? Geofencing is not really an option since it can be inside. Maybe detecting if the user is walking, biking, standing still? Any suggestions are greatly appreciated =).
On iOS BLE connectivity looks like this:
initialize CBluetoothManager,
start discovering devices through bluetooth.
when found particular peripheral that u're intrested in, connect to it via core manager and store this peripheral variable in ur Class,
then.. u should STOP discovering cuz it's terrible for batteries ;) (as u said),
after device's found, you can search through services, characteristic and at the end through descriptors <-- IN THIS ORDER otherwise u won't get any of these,
ofc, from now on you're able to store each of these vars in your Class and work with them as you wish to. BLE on iOS's based on delegates and it's own lifecycle, each time when there will be something to read the event will trigger. When you will want to send some msg to Arduino back it shouldn't be a problem. In the partial answer for your question about
'when a certain service shows up. THEN the smarphone connects to
Arduino.'
you have to make steps ABOVE in order to read services. Hope that helps.
I'm completely new to the arduino controlling and programming.
I want to get signal my android smartphone , When a call receive to smartphone I want to acknowledge my Arduino uno board by blinking a LED.
Then if I want to take a call using a physical button I have to answer the call or reject it.
Simply I want to send digital signals from my smartphone to Arduino board and I want to receive the analog button press as response to the phone call(Whether answer/ignore)
I connect phone and Arduino via Bluetooth
This is the Where I have struggling right now.
I need some help on this please!!
It just so happens that I wrote an answer that fits this question a couple of days ago here, this is an edited version of it:
You'll have to buy a module to allow the Arduio to communicate via bluetooth. An example of such a module is the HTC-06, wich can be bought online for less then $10 and for which there is an exellent tutorial over at instructables.
The phone side of the story is explained here, in the official Android documentation. It is sometimes convenient to test with a terminal on your phone, I used this one.
I have some code laying around that can send some data between the Arduino and my phone, I can post it later today if you'd like that.
Alternatively, if you don't want to write everyting yourself, you can use an app like Tinkernut does is one of his videos.
I am building a small robot that I can drive around outside of bluetooth range -- so I want to send signals via the internet. The eyes and ears are an old Droid phone (running android 2.2.3). I can get the phone to talk to a bluetooth module to control the robot (tap the left button, it sends the letter L to the bluetooth, which turns the robot etc etc). I have got Skype or Tango to both give me video and sound to a pc, so that problem is sorted. The thing I cannot solve is how to send e.g. the letter L over the internet and for the phone to know what I sent. I wrote an app that checks the contents of a WebDB every second (it works), but that app stops running when I power up the video chat application. So the question is...how can I get my old Android phone to know that someone via the internet has sent the letter L via Skype or some other way, and for that to happen while I'm also running a video chat application? PS...my phone has no number, no carrier, and can't receive sms messages or calls.
You wrote:
I wrote an app that checks the contents of a WebDB every second (it works), but that app stops running when I power up the video chat application.
So the answer is simple. Write an Android Service that runs on the background and polling the internet. Read about android service, and you can see a real example in the ApiDemos. Good luck!
Ok, I watched the Google I/O from 2011 presentation on NFC on peer to peer.
The demo was done on Gingerbread and using the application Sticky Notes found
Now in this demo, both device the onNewIntent() was called at the same time so both devices are trying to share information to one another.
On ICS and above, you have Android Beam..
With Android Beam, you have to touch to trigger the onNewIntent() event that will send the NDef message across.
Now the problem with this is that now to trigger the onNewIntent() on both devices, both user on each device has to "Touch To Beam" at the same time.
Is there a way that when you Touch To Beam on one device, both can have the onNewIntent() to be called?
I am trying to develop an app that will exchange data to each other but for it to work in a nice friendly fashion I need the devices to share the data at the same time once the Touch To Beam has been initiated on one device. I do hope this is possible.
Edit: It looks like this might not be possible to do :(
As far as I can tell, the feature you want is not available over NFC itself. The touch-to-beam/SNEP/NPP transfer is one direction only on Android. The user that clicks his screen will push an NDEF message to the other phone.
What I believe they've done in the video is set up a bluetooth connection with the NDEF message to make the transfer (as you saw in the stickynotes demo). Unfortunately there is no nice API for this.
However, the EasyNFC project promises to be able to allow you to create a bluetooth connection and socket between two phones/applications. Check it out here
I had a try and didn't really like the Touch-to-Beam UI that was still required in the set up of the bluetooth connection. It also didnt really suit my needs, as I wanted to transfer phone to computer and didn't really want to implement NFC P2P and a bluetooth connection.
Did you try this:
Use the Touch to Beam on phone-1 to "PUSH" the data, while on the other (phone-2), use the NDEF_DISCOVERED/TECH_DISCOVERED intent to trigger/start the data capture/reception. I vaguely remember one of the above intents were triggered when a PUSH is done. Although, every transmission requires a "Touch" to start the beaming.
When you think in general, Android should not allow the NFC data transfer in both direction at the same time. Lets think of a scenario where I want to send a thing to my friend with NFC. What is actively open on my friend's phone is not important. I should send this thing even the same app is not open on the receiver side. There may be another app in my friends phone that tries to send another thing to me. When we touch our phones, Android Beam (TM) appears and he data is sent from the phone that is touched.
In you case I think you should disable Android Beam (TM) by setting setNdefPushMessage(null) and do sending both ways using the old way.
https://developer.android.com/preview/api-overview.html
I think it will be available in L!!!
NFC enhancements
Your app can invoke the Android Beam on the user’s device to share data by calling android.nfc.NfcAdapter.invokeBeam(). This avoids the need for the user to manually tap the device against another NFC-capable device to complete the data transfer.