0

I have to design an android application using android studio sdk version 3.1.4 and developing on API 15: Android 4.0.3 (IceCreamSandwich) that is capable to receive csv data from arduino using HM 10 BLE module similar to BLE terminal app on playstore. BLE terminal App is used for scanning nearby BLE device and also use for serial communication. Control any Micro-controller that uses any BLE Module (based on Texas Instruments CC254x) through your smart phone. This app can send and receive commands via BLE so you can debug your hardware problems easily. Monitoring receiving data as ASCII or HEX. Sending Data as ASCII or HEX. At present I have imported BluetoothLEGATT sample code on android studio and installed the app, in which I am getting data but the data is not coming in stream I want it to be displayed on stream. I want to receive it on csv format. The data should come in stream format. At arduino side I am sending in csv format.

<?xml version="1.0" encoding="UTF-8"?>

<!--Copyright 2013 The Android Open Source ProjectLicensed under the Apache License, Version 2.0 (the "License");you may not use this file except in compliance with the License.You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed under the License is distributed on an "AS IS" BASIS,WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.See the License for the specific language governing permissions andlimitations under the License. -->

-<manifest android:versionName="1.0" android:versionCode="1" package="com.example.android.bluetoothlegatt" xmlns:android="http://schemas.android.com/apk/res/android">

<!-- Min/target SDK versions (<uses-sdk>) managed by build.gradle -->


<!-- Declare this required feature if you want to make the app available to BLE-capabledevices only. If you want to make your app available to devices that don't support BLE,you should omit this in the manifest. Instead, determine BLE capability by usingPackageManager.hasSystemFeature(FEATURE_BLUETOOTH_LE) -->


<uses-feature android:required="true" android:name="android.hardware.bluetooth_le"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>

<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>


-<application android:theme="@android:style/Theme.Holo.Light" android:icon="@drawable/ic_launcher" android:label="@string/app_name">


-<activity android:name=".DeviceScanActivity" android:label="@string/app_name">


-<intent-filter>

<action android:name="android.intent.action.MAIN"/>

<category android:name="android.intent.category.LAUNCHER"/>

</intent-filter>

</activity>

<activity android:name=".DeviceControlActivity"/>

<service android:name=".BluetoothLeService" android:enabled="true"/>

</application>

</manifest>
tshivam
  • 137
  • 1
  • 1
  • 7
  • These days I am working on a similar application. The app you are using is a good start. Do you want to store the data shown in the image in csv format? Describe objective and I might be able to help you. – Mahendra Gunawardena Sep 23 '18 at 21:12
  • yeah, thanks a lot for your kind response. I do want to store the data in CSV format and create an excel file but that is later part of the app. – tshivam Sep 25 '18 at 05:15
  • At present, i just want to display the live data coming from the harware side via UART in csv format. – tshivam Sep 25 '18 at 05:16
  • The challenge what i am facing is right now i am unable to connect to the device and get data from it all times. Sometimes it gets connected and gets disconnected after about 10 seconds and sometimes on connection data starts coming and sometimes it doesnot comes. – tshivam Sep 25 '18 at 05:18
  • yeah okay but thats a software question only data is coming from hardware side as if i am using other app on playstore like bleterminal i am getting the data in desired form but in case of my app i am not getting data in required form , the problems i am facing are connection disconnection with ble device and data is coming when i am selecting the particular service and characteristic which i dont want to happen it should begine data streaming and display as soon as it connects. – tshivam Sep 26 '18 at 06:30
  • Hey i have edited my question, please help me out with this problem. – tshivam Sep 26 '18 at 06:38
  • Thank you for updating the post with new information. You might also want to update the post with the BLE terminal information too. Also can you please tell which SDK version you are using. It would be good if you update the post with AndroidManifest.xml .This is very valuable information to help solve the problem. Note: Stackoverflow is good the SW questions. Also I suggest changing the title to something like `BLE connection issue with HM-10 temperature sensor` – Mahendra Gunawardena Sep 26 '18 at 09:28
  • Also take a look at [Large data transmission in Bluetooth Low Energy between HM10 with Arduino & Android BLE](https://stackoverflow.com/questions/51570654/large-data-transmission-in-bluetooth-low-energy-between-hm10-with-arduino-andr) – Mahendra Gunawardena Sep 26 '18 at 09:38
  • Hey i have made the suggested edits. Please take a look. – tshivam Sep 26 '18 at 19:58
  • Also the sdk is 3.1.4 – tshivam Sep 26 '18 at 20:00
  • In your build.gradle file, can you please tell me what your minimum, maximum and target android SDK. Here is [link](https://d1ohg4ss876yi2.cloudfront.net/android-studio-indicate-progression-with-progressbar-example/import-into-gradle-build-module-app.jpg) to help find the gradle file. Also you state you have attached the image, The image is no longer present. A few other things to note BLE uses a pub/sub model. Also I am not too sure if you can access directly a UART port via Android BLE API. The data will be presented asynchronous with the BLE android platform. One more don't cross post. – Mahendra Gunawardena Sep 27 '18 at 08:28
  • If i am using higher API versions than 15, then sync is getting failed. – tshivam Sep 28 '18 at 12:08
  • I don't know to much about the Sync, but BLE for android was deployed API 18 and above. Before that it was bluetooth classic only – Mahendra Gunawardena Sep 28 '18 at 12:11

1 Answers1

0

Bluetooth Low Energy (BLE) was introduced to Android with 4.3 release. So one of your problems might be API 15: Android 4.0.3 (IceCreamSandwich). Try changing the minimum API to 18. Until API level 21, Lollipop android used the BlueZ software stack. Although BlueZ worked it still had some stability issues with BLE on Android 4.3 particularly scanning in maintaining connectivity. With Android API 21 release Bluedroid software stack was used which was more stable and had improved API's for BLE.

Mahendra Gunawardena
  • 1,956
  • 5
  • 26
  • 45
  • Hey Thanks for your reply, further i want to ask how can i enable the uart service & its characteristics in my android application. – tshivam Sep 26 '18 at 19:51
  • I just want to connect to my HM10 through the app and select its uart service and RX TX characteristic and start displaying data thats it. – tshivam Sep 26 '18 at 20:00
  • @tshivam BTW I just uploaded the source code of a BLE Andorid app that I have been working on to github. The Link is https://github.com/mahengunawardena/ShapeTheWorld – Mahendra Gunawardena Oct 07 '18 at 02:44
  • That is so nice of you sir!! But i am facing an issue over here of in importing the project into my ide. I think i have to migrate to gradle. How should i migrate it to gradle build system? – tshivam Oct 09 '18 at 18:55
  • @tshivam What build system you using? I thought you are using Android Studio. gradle is the default build system on AS. – Mahendra Gunawardena Oct 09 '18 at 22:11
  • yeah i am using android studio, but still its asking migrating to gradle. – tshivam Oct 10 '18 at 04:51
  • Based on what I read I don't think build systems is the problem. I am not sure how deep you into Android Studio, it might be a good idea to start from the beginning. – Mahendra Gunawardena Oct 10 '18 at 09:15