Smartphone app control stepper motors via bluetooth low energy(BLE) on stm32F401RE x IHM02A1 x IDB05A1 V2 .

Dependencies:   BLE_API X_NUCLEO_IDB0XA1 X_NUCLEO_IHM02A1 mbed

Fork of BLE_LED_IDB0XA1_demo by NEHSROBOT

Committer:
apalmieri
Date:
Thu Jan 07 16:31:02 2016 +0000
Revision:
0:aae2d6c2a9eb
A simple demo driving an LED through a BLE service

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apalmieri 0:aae2d6c2a9eb 1 /* mbed Microcontroller Library
apalmieri 0:aae2d6c2a9eb 2 * Copyright (c) 2006-2013 ARM Limited
apalmieri 0:aae2d6c2a9eb 3 *
apalmieri 0:aae2d6c2a9eb 4 * Licensed under the Apache License, Version 2.0 (the "License");
apalmieri 0:aae2d6c2a9eb 5 * you may not use this file except in compliance with the License.
apalmieri 0:aae2d6c2a9eb 6 * You may obtain a copy of the License at
apalmieri 0:aae2d6c2a9eb 7 *
apalmieri 0:aae2d6c2a9eb 8 * http://www.apache.org/licenses/LICENSE-2.0
apalmieri 0:aae2d6c2a9eb 9 *
apalmieri 0:aae2d6c2a9eb 10 * Unless required by applicable law or agreed to in writing, software
apalmieri 0:aae2d6c2a9eb 11 * distributed under the License is distributed on an "AS IS" BASIS,
apalmieri 0:aae2d6c2a9eb 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
apalmieri 0:aae2d6c2a9eb 13 * See the License for the specific language governing permissions and
apalmieri 0:aae2d6c2a9eb 14 * limitations under the License.
apalmieri 0:aae2d6c2a9eb 15 */
apalmieri 0:aae2d6c2a9eb 16
apalmieri 0:aae2d6c2a9eb 17 #ifndef __BLE_LED_SERVICE_H__
apalmieri 0:aae2d6c2a9eb 18 #define __BLE_LED_SERVICE_H__
apalmieri 0:aae2d6c2a9eb 19
apalmieri 0:aae2d6c2a9eb 20 class LEDService {
apalmieri 0:aae2d6c2a9eb 21 public:
apalmieri 0:aae2d6c2a9eb 22 const static uint16_t LED_SERVICE_UUID = 0xA000;
apalmieri 0:aae2d6c2a9eb 23 const static uint16_t LED_STATE_CHARACTERISTIC_UUID = 0xA001;
apalmieri 0:aae2d6c2a9eb 24
apalmieri 0:aae2d6c2a9eb 25 LEDService(BLEDevice &_ble, bool initialValueForLEDCharacteristic) :
apalmieri 0:aae2d6c2a9eb 26 ble(_ble), ledState(LED_STATE_CHARACTERISTIC_UUID, &initialValueForLEDCharacteristic)
apalmieri 0:aae2d6c2a9eb 27 {
apalmieri 0:aae2d6c2a9eb 28 GattCharacteristic *charTable[] = {&ledState};
apalmieri 0:aae2d6c2a9eb 29 GattService ledService(LED_SERVICE_UUID, charTable, sizeof(charTable) / sizeof(GattCharacteristic *));
apalmieri 0:aae2d6c2a9eb 30 ble.addService(ledService);
apalmieri 0:aae2d6c2a9eb 31 }
apalmieri 0:aae2d6c2a9eb 32
apalmieri 0:aae2d6c2a9eb 33 GattAttribute::Handle_t getValueHandle() const {
apalmieri 0:aae2d6c2a9eb 34 return ledState.getValueHandle();
apalmieri 0:aae2d6c2a9eb 35 }
apalmieri 0:aae2d6c2a9eb 36
apalmieri 0:aae2d6c2a9eb 37 private:
apalmieri 0:aae2d6c2a9eb 38 BLEDevice &ble;
apalmieri 0:aae2d6c2a9eb 39 ReadWriteGattCharacteristic<bool> ledState;
apalmieri 0:aae2d6c2a9eb 40 };
apalmieri 0:aae2d6c2a9eb 41
apalmieri 0:aae2d6c2a9eb 42 #endif /* #ifndef __BLE_LED_SERVICE_H__ */