Recently, I began to study the development of a device based on mircocontroller, which will have a BLE module. The device should send the analog reading received from the sensor to the Android application that I am going to develop.
What I learned about how GATT works:
- The microcontroller-based device will be a GATT server.
- The Android app will be a GATT client.
- As can be seen from the point of view of communication, the device based on the micro-controller is subordinate, and the Android application is the master.
Questions:
- How do I determine the number of attributes that I need to determine in order to receive a command from the GATT client and send a response (which will be a float value)? Do I need to have two different attributes: one for Android for sending commands and one for a device based on a microcontroller for sending data to Android? Or can I use one attribute?
- GATT seems to be event driven.
2.1. What events will be generated when android sends a command to a device based on a microcontroller: (Client to Server)?
2.2: Will an event be generated when the data is written in the attribute that will be read by the Android application: (from server to client)? - The android application (GATT client) must use read / write commands to communicate with the microcontroller-based device (GATT Server). In addition, the GATT server must use Notify / Indicate to transmit data to the GATT client. Do I understand correctly?
I am using this BlueGiga BLE112 module for development.
The gatt.xml file I have written so far:
<?xml version="1.0" encoding="UTF-8" ?> <configuration> <service uuid="1800" id="generic_access"> <description>Generic Access</description> <characteristic uuid="2A00" id="c_device_name"> <description>Device Name</description> <properties read="true" const="true" /> <value>MyBLEDev</value> </characteristic> <characteristic uuid="2A01" id="c_appearance"> <description>Appearance</description> <properties read="true" const="true" /> <value type="hex">0300</value> </characteristic> </service> <service uuid="624e957f-cb42-4cd6-bacc-84aeb898f69b" advertise="true"> <description>Custom Device Service</description> <characteristic uuid="a57892fe-4f58-97d4-a5245-78a4125d3e6" id="c_cmd_TxReading"> <description>Request for Reading</description> <properties write="true" /> <value length="4" /> </characteristic> <characteristic uuid="8fde302a-56ac-b289-65ed-a577ed66b89c" id="c_reading"> <description>Measurement</description> <properties read="true" write="true" /> <value length="4" type="float32" /> </characteristic> </service>
user2045557
source share