北海道情報専門学校 ライフハック研究所のエンベデッドUSBチーム松葉和仁により開発されたUSBSecのmbedに使用するソースコード by 和仁

Dependencies:   SDFileSystem MusicEngine

Fork of mbed-os-example-ble-LED by mbed-os-examples

北海道情報専門学校 ライフハック研究所 エンベデッドUSB USBSec用mbedプログラム

松葉和仁

Committer:
kazu0o2
Date:
Wed Feb 08 03:00:32 2017 +0000
Revision:
37:dcb097426442
Parent:
14:be4e43ce1578
term debug console

Who changed what in which revision?

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