Skip to content

Commit 75c9dfc

Browse files
committed
BLE: Add Cordio port.
It allows mbed users to enable BLE on targets with an external BLE module.
1 parent aa0b5d5 commit 75c9dfc

File tree

105 files changed

+14274
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+14274
-0
lines changed
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2017-2017 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#ifndef CORDIO_BLE_H_
18+
#define CORDIO_BLE_H_
19+
20+
#include "ble/BLE.h"
21+
#include "ble/blecommon.h"
22+
#include "ble/BLEInstanceBase.h"
23+
24+
#include "CordioHCIDriver.h"
25+
#include "CordioGap.h"
26+
#include "CordioGattServer.h"
27+
#include "CordioSecurityManager.h"
28+
#include "CordioPalAttClient.h"
29+
#include "ble/pal/AttClientToGattClientAdapter.h"
30+
#include "ble/generic/GenericGattClient.h"
31+
32+
namespace ble {
33+
namespace vendor {
34+
namespace cordio {
35+
36+
/**
37+
* @see BLEInstanceBase
38+
*/
39+
class BLE : public ::BLEInstanceBase {
40+
/**
41+
* Construction with an HCI driver.
42+
*/
43+
BLE(CordioHCIDriver& hci_driver);
44+
45+
/**
46+
* Destructor
47+
*/
48+
virtual ~BLE();
49+
50+
public:
51+
52+
/**
53+
* Access to the singleton containing the implementation of BLEInstanceBase
54+
* for the Cordio stack.
55+
*/
56+
static BLE& deviceInstance();
57+
58+
/**
59+
* @see BLEInstanceBase::init
60+
*/
61+
virtual ble_error_t init(
62+
::BLE::InstanceID_t instanceID,
63+
FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> initCallback
64+
);
65+
66+
/**
67+
* @see BLEInstanceBase::hasInitialized
68+
*/
69+
virtual bool hasInitialized() const;
70+
71+
/**
72+
* @see BLEInstanceBase::shutdown
73+
*/
74+
virtual ble_error_t shutdown();
75+
76+
/**
77+
* @see BLEInstanceBase::getVersion
78+
*/
79+
virtual const char *getVersion();
80+
81+
/**
82+
* @see BLEInstanceBase::getGap
83+
*/
84+
virtual Gap& getGap();
85+
86+
/**
87+
* @see BLEInstanceBase::getGap
88+
*/
89+
virtual const Gap& getGap() const;
90+
91+
/**
92+
* @see BLEInstanceBase::getGattServer
93+
*/
94+
virtual GattServer &getGattServer();
95+
96+
/**
97+
* @see BLEInstanceBase::getGattServer
98+
*/
99+
virtual const GattServer &getGattServer() const;
100+
101+
/**
102+
* @see BLEInstanceBase::getGattClient
103+
*/
104+
virtual ::GattClient &getGattClient();
105+
106+
/**
107+
* @see BLEInstanceBase::getSecurityManager
108+
*/
109+
virtual SecurityManager &getSecurityManager();
110+
111+
/**
112+
* @see BLEInstanceBase::getSecurityManager
113+
*/
114+
virtual const SecurityManager &getSecurityManager() const;
115+
116+
/**
117+
* @see BLEInstanceBase::waitForEvent
118+
*/
119+
virtual void waitForEvent();
120+
121+
/**
122+
* @see BLEInstanceBase::processEvents
123+
*/
124+
virtual void processEvents();
125+
126+
private:
127+
static void stack_handler(wsfEventMask_t event, wsfMsgHdr_t* msg);
128+
static void device_manager_cb(dmEvt_t* dm_event);
129+
static void connection_handler(dmEvt_t* dm_event);
130+
static void timeoutCallback();
131+
132+
void stack_setup();
133+
void start_stack_reset();
134+
void callDispatcher();
135+
136+
static CordioHCIDriver* _hci_driver;
137+
static FunctionPointerWithContext< ::BLE::InitializationCompleteCallbackContext*> _init_callback;
138+
139+
enum {
140+
NOT_INITIALIZED,
141+
INITIALIZING,
142+
INITIALIZED
143+
} initialization_status;
144+
145+
::BLE::InstanceID_t instanceID;
146+
};
147+
148+
} // namespace cordio
149+
} // namespace vendor
150+
} // namespace ble
151+
152+
153+
#endif /* CORDIO_BLE_H_ */

0 commit comments

Comments
 (0)