Bluetooth Le Gatt Example To Link Alongside Arduino/Genuino 101

Posted on

This post service present how to locomote the Android Bluetooth Le Gatt illustration Code to link alongside Arduino/Genuino 101.

The Arduino/Genuino 101 board contains the Intel® Curie™ Module. The 101 adds Bluetooth Low Energy capabilities together with has an on-board 6-axis accelerometer/gyroscope, providing exciting opportunities for edifice creative projects inward the connected world. More data virtually the technical specifications together with documentation tin destination hold upward flora on the Arduino/Genuino 101 master copy page.

In Arduino/Genuino 101 board, programme alongside example:
> File > Examples > CurieBLE > CallbackLED


This illustration setup Arduino/Genuino 101 equally Bluetooth LE device (named “LEDCB”) alongside service alongside UUID “19B10000-E8F2-537E-4F6C-D104768A1214” and create switch feature allowing remote device to read together with write, alongside UUID “19B10001-E8F2-537E-4F6C-D104768A1214”. We involve the UUIDs inward time to come examples.

So I re-create hither for time to come reference:

/*   Copyright (c) 2015 Intel Corporation. All rights reserved.    This library is gratis software; you lot tin destination redistribute it and/or   alteration it nether the damage of the GNU Lesser General Public   License equally published past times the Free Software Foundation; either   version 2.1 of the License, or (at your option) whatever later on version.    This library is distributed inward the promise that it volition hold upward useful,   only WITHOUT ANY WARRANTY; without fifty-fifty the implied warranty of   MERCHANTABILITY or FITNESS FOR Influenza A virus subtype H5N1 PARTICULAR PURPOSE. See the GNU   Lesser General Public License for to a greater extent than details.    You should accept received a re-create of the GNU Lesser General Public   License along alongside this library; if not, write to the Free Software   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-   1301 USA */   #include <CurieBLE.h>  const int ledPin = 13; // gear upward ledPin to utilization on-board LED BLEPeripheral blePeripheral; // exercise peripheral illustration  BLEService ledService("19B10000-E8F2-537E-4F6C-D104768A1214"); // exercise service  // exercise switch feature together with permit remote device to read together with write BLECharCharacteristic switchChar("19B10001-E8F2-537E-4F6C-D104768A1214", BLERead | BLEWrite);  void setup() {   Serial.begin(9600);   pinMode(ledPin, OUTPUT); // utilization the LED on pivot xiii equally an output    // gear upward the local shout peripheral advertises   blePeripheral.setLocalName("LEDCB");   // gear upward the UUID for the service this peripheral advertises   blePeripheral.setAdvertisedServiceUuid(ledService.uuid());    // add together service together with feature   blePeripheral.addAttribute(ledService);   blePeripheral.addAttribute(switchChar);    // assign effect handlers for connected, disconnected to peripheral   blePeripheral.setEventHandler(BLEConnected, blePeripheralConnectHandler);   blePeripheral.setEventHandler(BLEDisconnected, blePeripheralDisconnectHandler);    // assign effect handlers for feature   switchChar.setEventHandler(BLEWritten, switchCharacteristicWritten); // gear upward an initial value for the feature   switchChar.setValue(0);    // advertise the service   blePeripheral.begin();   Serial.println(("Bluetooth device active, waiting for connections...")); }  void loop() {   // poll peripheral   blePeripheral.poll(); }  void blePeripheralConnectHandler(BLECentral& central) {   // key connected effect handler   Serial.print("Connected event, central: ");   Serial.println(central.address()); }  void blePeripheralDisconnectHandler(BLECentral& central) {   // key disconnected effect handler   Serial.print("Disconnected event, central: ");   Serial.println(central.address()); }  void switchCharacteristicWritten(BLECentral& central, BLECharacteristic& characteristic) {   // key wrote novel value to characteristic, update LED   Serial.print("Characteristic event, written: ");    if (switchChar.value()) {     Serial.println("LED on");     digitalWrite(ledPin, HIGH);   } else {     Serial.println("LED off");     digitalWrite(ledPin, LOW);   } } 

In Android side, charge alongside illustration code of Bluetooth Le Gatt:


How it run:


This demo haven’t present whatever existent purpose indeed. In coming posts, I volition TRY to implement my ain illustration app (with re-using component division of the Bluetooth Le Gatt example) to command together with read nation from Genuino 101. Currently, I don’t know how much I can.