it compiles at the very least. Starter code for buffering accelerator values before sending them off.

Dependencies:   BLE_API i2c-serial-conflict nRF51822

Fork of accel_to_blenano_i2c by Cortney Padua

Committer:
znew711
Date:
Mon May 01 04:30:39 2017 +0000
Revision:
10:602c516971ec
it compiles at least

Who changed what in which revision?

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