This series of articles will explain how to use The Tactigon’s integrated sensors and communication interfaces to create a simple gesture controller.
In this article we’re going to learn how to use simple Tactigon’s functions to send accelerometer data and quaternions over Bluetooth Low Energy (BLE from now on).
We’ll look at, in details, to:
- Used Libraries
- UUID and Characteristic
- Final Considerations
This example uses few essential libraries:
First three libraries, have been analyzed on first part of this series, we now discover tactigon_BLE.h library.
This library is dedicated to integrated BLE module. It provides few types needed to create a communication between two devices.
T_BLE is BLE Manager (bleManager instance in this example), it handles UUID, Characteristics and their buffer. In next examples we’ll see other methods of this class, handling connection and its status.
UUID is the universally unique identification, which, associated with a characteristic, allows to identify it by external devices.
T_BLE_Characteristic is the characteristic class. It needs an UUID and length in bytes of the payload it will transmit.
In the setup function we created an uuid with the uuid.set() method.
The UUID needs to be unique at application level.
The String “7ac71000-503d-4920-b000-acc000000001″ used is unique since we use only this in our sketch.
We set the Characteristic (bleChar instance) with the bleManager.addNewChar() method, which instantiate a new Characteristic object by providing an UUID and the data length in byte (14 in this example).
An unsigned char array (also 14 bytes size) is used as buffer for the characteristic.
With memcpy we prepare this buffer, filling with sensors data.
memcpy(&buffData, &qData.q0, 2);
This execution of memcpy copies the memory area pointed by qData.q0, 2 bytes long, in the memory area pointed by buffData. It’a a binary operation, so data type is not relevant.
Same applies for other Quaternions and Accelerometer data in this example.