1. Are you ready for the Galaxy S20? Here is everything we know so far!

Bluetooth LE Service and Characteristics Design

Discussion in 'Android Development' started by Marcio Valenzuela, Apr 14, 2016.

  1. Marcio Valenzuela

    Thread Starter

    Im building an Android app to interface Arduino with a BLE module from HMSoft10.

    I found a tutorial online for an android app and it takes care of the connectivity and it uses 3 seekbars to send information from the android app to the BLE module. So far because the app sends 3 values, 1 for each seek bar, the class has an array declared as int[]:

    Code (Text):
    2. private int[] RGBFrame = {0,0,0};
    3. // Then it creates variables to hold the values
    4. private SeekBar mRed,mGreen,mBlue;
    5. //Then it accesses those components from the view
    6. mRed = (SeekBar) findViewById(R.id.seekRed);
    7. mGreen = (SeekBar) findViewById(R.id.seekGreen);
    8. mBlue = (SeekBar) findViewById(R.id.seekBlue);
    9. //Finally it sends the component's value to a method that parses the data
    10. readSeek(mRed,0);
    11. readSeek(mGreen,1);
    12. readSeek(mBlue,2);
    Because I need to increase the seek bars to a total of 6 (one for each pwm pin), I redeclared the array as:
    Code (Text):
    2. private int[] RGBFrame = {0,0,0,0,0,0};
    But now I need to also account for 12 buttons for the 12 pins without PWM. Although I could add 12 more items to that array, it might get confusing. So I was thinking of a creating a second array for the buttons. But this would mean I need a new BLE characteristic to be able to accomodate the other data array, right?

    Im considering declaring a new characteristic in order to write the second array for the buttons, to my device. So here is what I know, the SampleGattAttributes.java defines my Device, Services and Characteristics like so:
    Code (Text):
    2. public class SampleGattAttributes {
    3.     private static HashMap<String, String> attributes = new HashMap();
    4.     //Our device config UUID string???
    5.     public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
    6.     //Our device UUID string???
    7.     public static String HM_10_CONF = "0000ffe0-0000-1000-8000-00805f9b34fb";
    9.     //Our characteristic UUID string
    10.     public static String HM_RX_TX = "0000ffe1-0000-1000-8000-00805f9b34fb";
    12.     static {
    13.         // Sample Services.
    14.         attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM 10 Serial");
    15.         attributes.put("00001800-0000-1000-8000-00805f9b34fb", "Device Information Service");
    17.         // Sample Characteristics.
    18.         attributes.put(HM_RX_TX,"RX/TX data");
    19.         attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
    20.     }
    22.     public static String lookup(String uuid, String defaultName) {
    23.         String name = attributes.get(uuid);
    24.         return name == null ? defaultName : name;
    25.     }
    26. }
    Im unclear as to what all the UUIDs are for. I know I should have one for the BLE module, one for a Service and one for a characteristic. I see that the Charactersitic UUID is static coded. But Im not sure what the other 2 statically declared UUIDs are. Then the code creates 2 service UUIDs and 2 characteristic UUIDs.

    Q2. Are the 2 UUIDs for services completely unrelated, or are they in pairs for a reason?
    Q3. What would I need to do to create another characteristic to communicate the buttons array since the seeks bar array is moving data via HM_RX_TX.


Share This Page