title: Understanding the GATT protocol in BLE
body: <p>I have recently started to learn developing a mircocontroller-based device which will have BLE module. The device is supposed to send analog reading fetched from sensor to an android application that I am going to develop.<br>
  For what i have studied about the way GATT works is:</p>
  
  <ol>
  <li>The microntroller-based device will be GATT server.</li>
  <li>The android application will be GATT client.</li>
  <li>As seen from communication point of view, the microntroller-based device is Slave and the android application is Master.</li>
  </ol>
  
  <p>Questions:</p>
  
  <ol>
  <li>How do I decide the number of attributes that I need to define in order to receive command from GATT Client and send the response (which is going to be a float value)? Do I need to have two distinct attributes: One for Android to send commands and one for the microncontroller-based device to send data to android? Or I can use a single attribute?</li>
  <li>GATT appears to be an event-driven system.<br>
  2.1: What events will be generated when android  sends a command to microcontroller-based device: (Client to Server) ?<br>
  2.2: Will an event be generated when the data is written on the attribute which is going to be read by Android application: (Server to Client) ?</li>
  <li>The android application (GATT Client) should use read/write commands to communicate with the microncontroller-based device (GATT Server). And, the GATT Server should use Notify/Indicate to pass the data to the GATT Client. Is my understanding correct?</li>
  </ol>
  
  <p>I am using <a href="https://www.bluegiga.com/en-US/products/bluetooth-4.0-modules/ble112-bluetooth--smart-module/">this BlueGiga BLE112 Module</a> for development.</p>
  
  <p>The gatt.xml file that I so far have written is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" ?&gt;
  &lt;configuration&gt;
  &lt;!-- 1800: org.bluetooth.service.generic_access --&gt;
  &lt;service uuid="1800" id="generic_access"&gt;
    &lt;description&gt;Generic Access&lt;/description&gt;
    &lt;!-- 2A00: org.bluetooth.characteristic.gap.device_name --&gt;
      &lt;characteristic uuid="2A00" id="c_device_name"&gt;
        &lt;description&gt;Device Name&lt;/description&gt;
        &lt;properties read="true" const="true" /&gt;
        &lt;value&gt;MyBLEDev&lt;/value&gt;
      &lt;/characteristic&gt;
    &lt;!-- 2A01: org.bluetooth.characteristic.gap.appearance --&gt;
      &lt;characteristic uuid="2A01" id="c_appearance"&gt;
        &lt;description&gt;Appearance&lt;/description&gt;
        &lt;properties read="true" const="true" /&gt;
        &lt;value type="hex"&gt;0300&lt;/value&gt;
      &lt;/characteristic&gt;
    &lt;/service&gt;
  
    &lt;!-- custom service --&gt;
    &lt;service uuid="624e957f-cb42-4cd6-bacc-84aeb898f69b" advertise="true"&gt;
      &lt;description&gt;Custom Device Service&lt;/description&gt;
  
      &lt;!-- custom write-only characteristic for Client to send commands to fetch reading --&gt;
      &lt;characteristic uuid="a57892fe-4f58-97d4-a5245-78a4125d3e6" id="c_cmd_TxReading"&gt;
        &lt;description&gt;Request for Reading&lt;/description&gt;
        &lt;properties write="true" /&gt;
        &lt;value length="4" /&gt;
      &lt;/characteristic&gt;
  
      &lt;characteristic uuid="8fde302a-56ac-b289-65ed-a577ed66b89c" id="c_reading"&gt;
        &lt;description&gt;Measurement&lt;/description&gt;
        &lt;properties read="true" write="true" /&gt;
        &lt;value length="4" type="float32" /&gt;
      &lt;/characteristic&gt;
  &lt;/service&gt;
  </code></pre>
  
  <p></p>