source: azure_iot_hub_f767zi/trunk/asp_baseplatform/gdic/ble_shield2.1/BLECharacteristic.h@ 457

Last change on this file since 457 was 457, checked in by coas-nagasima, 4 years ago

ファイルを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-chdr;charset=UTF-8
File size: 6.0 KB
Line 
1/*
2 * TOPPERS BASE PLATFORM MIDDLEWARE
3 *
4 * Copyright (C) 2017-2018 by TOPPERS PROJECT
5 * Educational Working Group.
6 *
7 * 上記著作権者は,以下の(1)~(4)の条件を満たす場合に限り,本ソフトウェ
8 * ア(本ソフトウェアを改変したものを含む.以下同じ)を使用・複製・改
9 * 変・再配布(以下,利用と呼ぶ)することを無償で許諾する.
10 * (1) 本ソフトウェアをソースコードの形で利用する場合には,上記の著作
11 * 権表示,この利用条件および下記の無保証規定が,そのままの形でソー
12 * スコード中に含まれていること.
13 * (2) 本ソフトウェアを,ライブラリ形式など,他のソフトウェア開発に使
14 * 用できる形で再配布する場合には,再配布に伴うドキュメント(利用
15 * 者マニュアルなど)に,上記の著作権表示,この利用条件および下記
16 * の無保証規定を掲載すること.
17 * (3) 本ソフトウェアを,機器に組み込むなど,他のソフトウェア開発に使
18 * 用できない形で再配布する場合には,次のいずれかの条件を満たすこ
19 * と.
20 * (a) 再配布に伴うドキュメント(利用者マニュアルなど)に,上記の著
21 * 作権表示,この利用条件および下記の無保証規定を掲載すること.
22 * (b) 再配布の形態を,別に定める方法によって,TOPPERSプロジェクトに
23 * 報告すること.
24 * (4) 本ソフトウェアの利用により直接的または間接的に生じるいかなる損
25 * 害からも,上記著作権者およびTOPPERSプロジェクトを免責すること.
26 * また,本ソフトウェアのユーザまたはエンドユーザからのいかなる理
27 * 由に基づく請求からも,上記著作権者およびTOPPERSプロジェクトを
28 * 免責すること.
29 *
30 * 本ソフトウェアは,無保証で提供されているものである.上記著作権者お
31 * よびTOPPERSプロジェクトは,本ソフトウェアに関して,特定の使用目的
32 * に対する適合性も含めて,いかなる保証も行わない.また,本ソフトウェ
33 * アの利用により直接的または間接的に生じたいかなる損害に関しても,そ
34 * の責任を負わない.
35 *
36 * @(#) $Id$
37 */
38
39/*
40The MIT License (MIT)
41
42Copyright (c) 2014 Sandeep Mistry
43
44Permission is hereby granted, free of charge, to any person obtaining a copy
45of this software and associated documentation files (the "Software"), to deal
46in the Software without restriction, including without limitation the rights
47to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48copies of the Software, and to permit persons to whom the Software is
49furnished to do so, subject to the following conditions:
50
51The above copyright notice and this permission notice shall be included in all
52copies or substantial portions of the Software.
53
54THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60SOFTWARE.
61*/
62
63#ifndef _BLE_CHARACTERISTIC_H_
64#define _BLE_CHARACTERISTIC_H_
65
66#ifdef __cplusplus
67 extern "C" {
68#endif
69
70#include "BLEAttribute.h"
71
72enum BLECharacteristicEvent {
73 BLEWritten = 0,
74 BLESubscribed = 1,
75 BLEUnsubscribed = 2
76};
77
78typedef struct _BLECharacteristic BLECharacteristic;
79typedef void (*BLECharacteristicEventHandler)(BLECentral* central, BLECharacteristic *pcharc);
80
81struct _BLECharacteristic{
82 BLEAttribute _attr;
83 unsigned char _properties;
84 unsigned char _valueSize;
85 unsigned char* _value;
86 unsigned char _valueLength;
87 bool_t _fixedLength;
88
89 bool_t _notify;
90 bool_t _written;
91 bool_t _subscribed;
92
93 void* _pblePeripheral;
94 bool_t (*characteristicValueChanged)(nRF8001* nRF8001, BLECharacteristic *pcharc);
95 bool_t (*canNotifyCharacteristic)(nRF8001* nRF8001, BLECharacteristic *pcharc);
96 bool_t (*canIndicateCharacteristic)(nRF8001* nRF8001, BLECharacteristic *pcharc);
97
98 BLECharacteristicEventHandler _eventHandlers[3];
99};
100
101#define BLECharacteristic_getproperties(c) (c)->_properties
102#define BLECharacteristic_getvalueSize(c) (c)->_valueSize
103#define BLECharacteristic_getvalue(c) (c)->_value
104#define BLECharacteristic_getvalueLength(c) (c)->_valueLength
105#define BLECharacteristic_getfixedLength(c) (c)->_fixedLength
106#define BLECharacteristic_getsubscribed(c) (c)->_subscribed
107
108
109extern void BLEService_setup(BLEService* pserv, const char *uuid);
110extern void BLECharacteristic_setup(BLECharacteristic* pcharc, const char *uuid, unsigned char properties, unsigned char *value, unsigned char len);
111extern bool_t BLECharacteristic_setValue1(BLECharacteristic *pcharc, const unsigned char value[], unsigned char length);
112extern bool_t BLECharacteristic_setValue2(BLECharacteristic *pcharc, const char* value);
113extern bool_t BLECharacteristic_notified(BLECharacteristic *pcharc);
114extern bool_t BLECharacteristic_written(BLECharacteristic *pcharc);
115extern void BLECharacteristic_setValue(BLECharacteristic *pcharc, BLECentral* central, const unsigned char value[], unsigned char length);
116extern void BLECharacteristic_setSubscribed(BLECharacteristic *pcharc, BLECentral* central, bool_t subscribed);
117extern bool_t BLECharacteristic_canNotify(BLECharacteristic *pcharc);
118extern bool_t BLECharacteristic_canIndicate(BLECharacteristic *pcharc);
119extern void BLECharacteristic_setEventHandler(BLECharacteristic *pcharc, uint8_t event, void *eventHandler);
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif /* _BLE_CHARACTERISTIC_H_ */
Note: See TracBrowser for help on using the repository browser.