Bluetooth LE Service & Characteristic Design

Discussion in 'Embedded Systems and Microcontrollers' started by quique123, Apr 14, 2016.

  1. quique123

    Thread Starter Member

    May 15, 2015
    34
    2
    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):
    1.  
    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);
    13.  
    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):
    1. 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):
    1. public class SampleGattAttributes {
    2.     private static HashMap<String, String> attributes = new HashMap();
    3.     //Our device config UUID string???
    4.     public static String CLIENT_CHARACTERISTIC_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
    5.     //Our device UUID string???
    6.     public static String HM_10_CONF = "0000ffe0-0000-1000-8000-00805f9b34fb";
    7.  
    8.     //Our characteristic UUID string
    9.     public static String HM_RX_TX = "0000ffe1-0000-1000-8000-00805f9b34fb";
    10.  
    11.     static {
    12.         // Sample Services.
    13.         attributes.put("0000ffe0-0000-1000-8000-00805f9b34fb", "HM 10 Serial");
    14.         attributes.put("00001800-0000-1000-8000-00805f9b34fb", "Device Information Service");
    15.  
    16.         // Sample Characteristics.
    17.         attributes.put(HM_RX_TX,"RX/TX data");
    18.         attributes.put("00002a29-0000-1000-8000-00805f9b34fb", "Manufacturer Name String");
    19.     }
    20.  
    21.     public static String lookup(String uuid, String defaultName) {
    22.         String name = attributes.get(uuid);
    23.         return name == null ? defaultName : name;
    24.     }
    25. }
    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.

    Q1. What are the CLIENT_CHARACTERISTIC_CONFIG & HM_10_CONF 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.
     
Loading...