Library for Using BLE as Stream Object

Dependents:   bel-example-pentabarf

Committer:
twixx
Date:
Wed Jan 03 15:07:11 2018 +0000
Revision:
0:062c87342d61
added Ble Serial

Who changed what in which revision?

UserRevisionLine numberNew contents of line
twixx 0:062c87342d61 1 /* mbed Microcontroller Library
twixx 0:062c87342d61 2 * Copyright (c) 2006-2013 ARM Limited
twixx 0:062c87342d61 3 *
twixx 0:062c87342d61 4 * Licensed under the Apache License, Version 2.0 (the "License");
twixx 0:062c87342d61 5 * you may not use this file except in compliance with the License.
twixx 0:062c87342d61 6 * You may obtain a copy of the License at
twixx 0:062c87342d61 7 *
twixx 0:062c87342d61 8 * http://www.apache.org/licenses/LICENSE-2.0
twixx 0:062c87342d61 9 *
twixx 0:062c87342d61 10 * Unless required by applicable law or agreed to in writing, software
twixx 0:062c87342d61 11 * distributed under the License is distributed on an "AS IS" BASIS,
twixx 0:062c87342d61 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
twixx 0:062c87342d61 13 * See the License for the specific language governing permissions and
twixx 0:062c87342d61 14 * limitations under the License.
twixx 0:062c87342d61 15 */
twixx 0:062c87342d61 16 #ifndef MBED_BLESERIAL_H
twixx 0:062c87342d61 17 #define MBED_BLESERIAL_H
twixx 0:062c87342d61 18
twixx 0:062c87342d61 19 #include "platform/platform.h"
twixx 0:062c87342d61 20
twixx 0:062c87342d61 21 //#if defined (DEVICE_SERIAL) || defined(DOXYGEN_ONLY)
twixx 0:062c87342d61 22
twixx 0:062c87342d61 23 #include "Stream.h"
twixx 0:062c87342d61 24 #include "UARTService.h"
twixx 0:062c87342d61 25 #include "platform/NonCopyable.h"
twixx 0:062c87342d61 26
twixx 0:062c87342d61 27 namespace mbed {
twixx 0:062c87342d61 28
twixx 0:062c87342d61 29 class BleSerial : public Stream, private NonCopyable<BleSerial> {
twixx 0:062c87342d61 30
twixx 0:062c87342d61 31 public:
twixx 0:062c87342d61 32 //using UARTService::write;
twixx 0:062c87342d61 33 //using Stream::read override;
twixx 0:062c87342d61 34 virtual ssize_t write(const void* buffer, size_t length);
twixx 0:062c87342d61 35
twixx 0:062c87342d61 36 BleSerial(BLE &_ble);
twixx 0:062c87342d61 37
twixx 0:062c87342d61 38 uint16_t getTXCHandle();
twixx 0:062c87342d61 39 uint16_t getRXCHandle();
twixx 0:062c87342d61 40
twixx 0:062c87342d61 41 //bool readable();
twixx 0:062c87342d61 42 //writeable: return (bool) BLE_UART_SERVICE_MAX_DATA_LEN - sendBufferIndex;
twixx 0:062c87342d61 43
twixx 0:062c87342d61 44 protected:
twixx 0:062c87342d61 45 //using UARTService::_getc;
twixx 0:062c87342d61 46 //using UARTService::_putc;
twixx 0:062c87342d61 47 virtual int _putc(int c);
twixx 0:062c87342d61 48 virtual int _getc();
twixx 0:062c87342d61 49 private:
twixx 0:062c87342d61 50 UARTService *bleUart;
twixx 0:062c87342d61 51 };
twixx 0:062c87342d61 52
twixx 0:062c87342d61 53 } // namespace mbed
twixx 0:062c87342d61 54
twixx 0:062c87342d61 55 #endif
twixx 0:062c87342d61 56
twixx 0:062c87342d61 57 //#endif