Knight Rider PIO sample for teckBASIC, konashi.js

Dependencies:   BLE_API_Native_IRC mbed

Fork of BLE_konashi_PIO_test by Michio Ono

konashi.js mbed HRM1017でもナイトライダー!: http://jsdo.it/micutil/g1Hn

サンプル動画: https://www.youtube.com/watch?v=HSLdzS3sGLw

techBASICサンプル: https://www.dropbox.com/s/c1k25jlen7x3vqo/KnightRider.txt

Committer:
micono
Date:
Sun Jul 27 00:02:25 2014 +0000
Revision:
2:6a3257fffa8c
Parent:
0:8c643bfe55b7
PIO sample for teckBASIC, konashi.js

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jksoft 0:8c643bfe55b7 1 /* mbed Microcontroller Library
jksoft 0:8c643bfe55b7 2 * Copyright (c) 2006-2013 ARM Limited
jksoft 0:8c643bfe55b7 3 *
jksoft 0:8c643bfe55b7 4 * Licensed under the Apache License, Version 2.0 (the "License");
jksoft 0:8c643bfe55b7 5 * you may not use this file except in compliance with the License.
jksoft 0:8c643bfe55b7 6 * You may obtain a copy of the License at
jksoft 0:8c643bfe55b7 7 *
jksoft 0:8c643bfe55b7 8 * http://www.apache.org/licenses/LICENSE-2.0
jksoft 0:8c643bfe55b7 9 *
jksoft 0:8c643bfe55b7 10 * Unless required by applicable law or agreed to in writing, software
jksoft 0:8c643bfe55b7 11 * distributed under the License is distributed on an "AS IS" BASIS,
jksoft 0:8c643bfe55b7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
jksoft 0:8c643bfe55b7 13 * See the License for the specific language governing permissions and
jksoft 0:8c643bfe55b7 14 * limitations under the License.
jksoft 0:8c643bfe55b7 15 */
jksoft 0:8c643bfe55b7 16
jksoft 0:8c643bfe55b7 17 #ifndef __NRF51822_GATT_SERVER_H__
jksoft 0:8c643bfe55b7 18 #define __NRF51822_GATT_SERVER_H__
jksoft 0:8c643bfe55b7 19
jksoft 0:8c643bfe55b7 20 #include "mbed.h"
jksoft 0:8c643bfe55b7 21 #include "blecommon.h"
jksoft 0:8c643bfe55b7 22 #include "ble.h" /* nordic ble */
jksoft 0:8c643bfe55b7 23 #include "GattService.h"
jksoft 0:8c643bfe55b7 24 #include "hw/GattServer.h"
jksoft 0:8c643bfe55b7 25
jksoft 0:8c643bfe55b7 26 #define BLE_TOTAL_CHARACTERISTICS 10
jksoft 0:8c643bfe55b7 27
jksoft 0:8c643bfe55b7 28 /**************************************************************************/
jksoft 0:8c643bfe55b7 29 /*!
jksoft 0:8c643bfe55b7 30 \brief
jksoft 0:8c643bfe55b7 31
jksoft 0:8c643bfe55b7 32 */
jksoft 0:8c643bfe55b7 33 /**************************************************************************/
jksoft 0:8c643bfe55b7 34 class nRF51GattServer : public GattServer
jksoft 0:8c643bfe55b7 35 {
jksoft 0:8c643bfe55b7 36 public:
jksoft 0:8c643bfe55b7 37 static nRF51GattServer& getInstance()
jksoft 0:8c643bfe55b7 38 {
jksoft 0:8c643bfe55b7 39 static nRF51GattServer m_instance;
jksoft 0:8c643bfe55b7 40 return m_instance;
jksoft 0:8c643bfe55b7 41 }
jksoft 0:8c643bfe55b7 42
jksoft 0:8c643bfe55b7 43 /* Functions that must be implemented from GattServer */
jksoft 0:8c643bfe55b7 44 virtual ble_error_t addService(GattService &);
jksoft 0:8c643bfe55b7 45 virtual ble_error_t readValue(uint16_t, uint8_t[], uint16_t);
jksoft 0:8c643bfe55b7 46 virtual ble_error_t updateValue(uint16_t, uint8_t[], uint16_t);
jksoft 0:8c643bfe55b7 47
jksoft 0:8c643bfe55b7 48 /* nRF51 Functions */
jksoft 0:8c643bfe55b7 49 void eventCallback(void);
jksoft 0:8c643bfe55b7 50 void hwCallback(ble_evt_t * p_ble_evt);
jksoft 0:8c643bfe55b7 51
jksoft 0:8c643bfe55b7 52 uint16_t m_connectionHandle; // TODO move to private
jksoft 0:8c643bfe55b7 53
jksoft 0:8c643bfe55b7 54 private:
jksoft 0:8c643bfe55b7 55 GattCharacteristic* p_characteristics[BLE_TOTAL_CHARACTERISTICS];
jksoft 0:8c643bfe55b7 56 ble_gatts_char_handles_t nrfCharacteristicHandles[BLE_TOTAL_CHARACTERISTICS];
jksoft 0:8c643bfe55b7 57
jksoft 0:8c643bfe55b7 58 nRF51GattServer() { serviceCount = 0; characteristicCount = 0; m_connectionHandle = BLE_CONN_HANDLE_INVALID; };
jksoft 0:8c643bfe55b7 59
jksoft 0:8c643bfe55b7 60 nRF51GattServer(nRF51GattServer const&);
jksoft 0:8c643bfe55b7 61 void operator=(nRF51GattServer const&);
jksoft 0:8c643bfe55b7 62 };
jksoft 0:8c643bfe55b7 63
jksoft 0:8c643bfe55b7 64 #endif