Read BLE characteristics and write them into a file - java

Good evening,
i am trying to build an app that connects with an arduino uno with BLE. It is not the center of my project and i had to learn Android programming in a short amount of time. That is why i am mainly using the BluetoothLeGatt app as a reference. My question may seem obvious for some of you.
I've managed to connect to my device but i do not understand how to read/receive notifications.
I understand the link between the functions used : boradcastUpdate, onCharacteristicChanged, onCharacteristicRead... but do not understand how the process starts(e.g how to launch these functions). Am i supposed to call an action myself ? Is there a problem with my emiter ?
I find the documentation of Android unclear and have spent a few hours searching for solutions before coming here.
Thank you for your answers

The documentation about Bluetooth GATT is quite clear about how to setup a basic project and its basic elements. You shouldn't have any problems to read/write on any characteristics your Arduino announce just by adapting a sample project like this.
Basically all you need is work with BluetoothGatt class getting a specific BluetoothGattCharacteristic of a service, and write into it like this after you've done the scanning and connecting process to your Arduino BLE peripheral.

Related

Using socket in Android development

I have been looking around for a guide on how to implement socket in android development but could not find any. I am currently recalling my API on activity created to ensure that data is updated for my app.
Can anyone assist with a guide to help achieve real time update with socket on android.
There is a powerful library called SOCKET.IO that you could use for this purpose. It supports multiple languages for both backend and client applications. Please check this link for more info and also here is an android example.

Java Bluetooth Proxy

I’m not sure if this is the right place to ask this question as this is my first question, but I have the following scenario and I need advice and guidance. Or, if this is the wrong place to ask this question, where should I post it?
I want to create a Java Bluetooth proxy application that will sit in the middle of an Android app and a bluetooth IoT device. I want this Java application to see all the traffic that is being exchanged between the app and the IoT device. I have found similar applications called btproxy and btlejuice, but I want to implement it within Java and I want it to be really simple. I have looked into Bluecove but I'm not having much luck. I’m guessing I will need 2 different machines or VM’s so I can use 2 different bluetooth adapters.
Basically, when you connect the Android app to the computer/VM, the data will be logged and it will be sent to the IoT device. The IoT device will then process it, and send its data back to the Android app via the computer/VM. I’m guessing this relies heavily on the UUID of the app and the device?
Is this possible to achieve, if so, have I got the right topology for this scenario and what would be the best Java API to use and is there any code that will help?

Combining Java + bluetooth + arduino

Today i came up with an idea to controle a arduino board or any other micro controller wirelessly using a java program. Im somewhat of an intermediate java programmer, meaning i can make basic applications. I know next to nothing about arduino, or the programming of microcontrollers in general, and i dont want to start to learn until i know i can link java with arduino, meaning running a program on the computer that, lets say, turn on a led. Ive done some research, and thats where i got the bluetooth from, but it seemed like the only videos were in spanish, and not much documentation about it, as far as i can see. I was just wondering how easy is it to link these two, is it possible, any links to tutorials of sorts, thanks. P.S. it doesn't have to be arduino, im just familier with that name, im just interested in controlling something physical through a java app, thanks.
Yes you can,
If you can program in java you will find arduino fairly easy but here is a arduino based tutorial with all the code your need:
http://playground.arduino.cc/Learning/Tutorial01#.UxClcvl_tFs
A majority of bluetooth modules will spit out serial data and this simply interacts with the RX/Tx (receive/transmit) inputs of the arduino. They are usually configured to standard board rates mainly 9600 to start.
All you have to do is spit a string out via bluetooth, an java based bluetooth example is below but you can also find bluetooth modules for PC that interact and install as a CDC (serial port).
Sending a string via bluetooth from a PC as client to a mobile as server.
Serial ports are a little easyier :)
http://www.java2s.com/Code/Java/Development-Class/COM-Port.htm
Cheers,
Chris

communication project using android

i'm doin my project in 8th sem telecomm engineering, and i'm plannin to create a DUPLEX(not confident whether it'd be full or half) communication app using bluetooth and wifi as channels,something more advanced than a simple walkie talkie, and i was wondering if this is possible for a one man army??? also i was wondering if it is possible to do so with android versions 2.2 and above... can i just program the bluetooth settings in app in such a way, that, it doesn't pop up for user permission to accept a voice message from the calling party??
and is there a possibility for creating multiple channels(one for Forward Voice Channel and one for Reverse Voice Channel) using bluetooth or wifi?? here's a list of few knowledge i possess:
JAVA: basics, done some gui in desktops, know some imp classes,only SE6...
WIRELESS COMMUNICATION: learning it this semester, stuff like how base station accepts incoming mobile station request and redirects it to dest, mostly 1g in our portions...
OPERATING SYSTEMS: general, looking forward to learning android and linux os...
C,C++,DSP,and SOME ELECTRONICS...
oh, and iwoul like to implement these well within 7 months duration...
people please ENLIGTHEN me with your wisdom and references to useful websites ASAP...
my THANKS AND WISHES to thee...:)
The first big problem i see is that on using wifi for this, and as i understood it is some sort of (advanced) walkie-talkie app with no rooter inbetween the communicating phones, you have to implement adhoc-wlan on your android device, which is not supported by android, so you will need a rooted device for that, and the implementation of adhoc-wlan on android is definitve possible (have a look at this code: http://code.google.com/p/android-wifi-tether/) but nothing easy (i have done it myself for an university project).
And you asked if you can avoid the permission pop-up for an incoming message, but on an android phone activating your bluetooth or pairing it with an other device will always ask for permission from the user.
I cant help about the multiple channels you were asking for.
As Answer to your big Question: "is it possible for a one man army?" i would say generelly yes, but it depends on how much other stuff you have to do. Since you were writing this is an project for university, i dont know if this is your only project and you can invest a lot of time in it. If so i guess it is possible, but it will be an quite big project and you should be willing to work yourself relativly deep into networking stuff.
On google.Code you can find some projects similar (at least the wifi part) to what you think about to do, take a look at them...

Device to Device Communication in Android

I have been tasked for university to program a mobile phone application. I have oppted for two mobiles to communicate with each other via message.
I would like the application to connect the mobile to the internet to send the message and the other mobile to connect to the internet to recieve the message.
I am using Eclipse IDE.
Does anyone have any ideas for good examples of similar application source code so I can develop my application using appropriate protocols.
I would appreciate any advice and I am certainly not looking for someone to give me "the answer" I am really looking forward to getting stuck in. Though I have never touched an android phone let alone programed one. So some advice would be amazing!!
Thanks
Si
Get used to this site: http://developer.android.com/index.html Learn it, love it. It's full of useful information. The Videos section gives plenty of live talks about what exactly Android is among other topics. One of the first things you need to do is go to the SDK section. It gives a detailed guide on how to get setup. The Dev Guide is great for learning more about Android and how to program Android apps (not just Java programs) especially while just getting started. Resources is full of code examples and articles on specific issues and Reference is the entire platform documentation. #Matthew Willis has already given a helpful link from the Dev Guide.
Look around the site, download and install the SDK, and come back whenever you have any questions. Good Luck!
Before you determine the technical solution you need to figure out how any two devices that don't know about each other will communicate.
In your case, where you seem to be attempting to develop some kind of peer-to-peer solution you most probably will need some kind of server in between where your phones send messages to and poll for messages.
If you are using WIFI, you would have each phones IP address and could configure each phone to communicate with each other directly.
Once you determine your architecture then something simple like http may be enough to communicate.
You might check out What is Android? to get an idea of the frameworks/libraries that are available on Android. Reading the links in the left pane at that site lead you through a nice series of articles about Android.
In terms of ways for two devices to communicate, they are many and difficult to enumerate. In general you will have much better luck with specific questions here than you will with broad questions.
You might be interested in reading about C2DM for pushing messages to a device; if not, there are many other alternatives involving polling.
GCM CSS is probably your best bet
https://developer.android.com/google/gcm/ccs.html

Categories

Resources