Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of BLE_API by
Revision 142:42f038a81ea7, committed 2014-11-21
- Comitter:
- rgrover1
- Date:
- Fri Nov 21 09:23:24 2014 +0000
- Parent:
- 141:bbc85b4fbdb7
- Child:
- 143:8bdf577b1598
- Commit message:
- Synchronized with git rev 42345159
Author: Rohit Grover
Minor re-organization of member functions and their access privileges.
Make most APIs private, and accessible only to BLEDevice.
Add a private copy constructor and assignment operator.
Changed in this revision
| public/Gap.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/public/Gap.h Fri Nov 21 09:23:24 2014 +0000
+++ b/public/Gap.h Fri Nov 21 09:23:24 2014 +0000
@@ -74,7 +74,12 @@
return (durationInMillis * 1000) / UNIT_1_25_MS;
}
-public:
+ typedef void (*EventCallback_t)(void);
+ typedef void (*ConnectionEventCallback_t)(Handle_t, addr_type_t peerAddrType, const address_t peerAddr, const ConnectionParams_t *);
+ typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t);
+
+ friend class BLEDevice;
+private:
/* These functions must be defined in the sub-class */
virtual ble_error_t setAddress(addr_type_t type, const address_t address) = 0;
virtual ble_error_t getAddress(addr_type_t *typeP, address_t address) = 0;
@@ -91,23 +96,22 @@
virtual ble_error_t setAppearance(uint16_t appearance) = 0;
virtual ble_error_t getAppearance(uint16_t *appearanceP) = 0;
- typedef void (*EventCallback_t)(void);
- typedef void (*ConnectionEventCallback_t)(Handle_t, addr_type_t peerAddrType, const address_t peerAddr, const ConnectionParams_t *);
- typedef void (*DisconnectionEventCallback_t)(Handle_t, DisconnectionReason_t);
+private:
+ /* Event callback handlers */
+ void setOnTimeout(EventCallback_t callback) {onTimeout = callback;}
+ void setOnConnection(ConnectionEventCallback_t callback) {onConnection = callback;}
+ void setOnDisconnection(DisconnectionEventCallback_t callback) {onDisconnection = callback;}
- /* Event callback handlers */
- void setOnTimeout(EventCallback_t callback) {
- onTimeout = callback;
+ GapState_t getState(void) const {
+ return state;
}
- void setOnConnection(ConnectionEventCallback_t callback) {
- onConnection = callback;
+protected:
+ Gap() : state(), onTimeout(NULL), onConnection(NULL), onDisconnection(NULL) {
+ /* empty */
}
- void setOnDisconnection(DisconnectionEventCallback_t callback) {
- onDisconnection = callback;
- }
-
+public:
void processConnectionEvent(Handle_t handle, addr_type_t type, const address_t addr, const ConnectionParams_t *params) {
state.connected = 1;
if (onConnection) {
@@ -133,15 +137,6 @@
}
}
- GapState_t getState(void) const {
- return state;
- }
-
-protected:
- Gap() : state(), onTimeout(NULL), onConnection(NULL), onDisconnection(NULL) {
- /* empty */
- }
-
protected:
GapState_t state;
@@ -149,6 +144,11 @@
EventCallback_t onTimeout;
ConnectionEventCallback_t onConnection;
DisconnectionEventCallback_t onDisconnection;
+
+private:
+ /* disallow copy and assginment */
+ Gap(const Gap &);
+ Gap& operator=(const Gap &);
};
#endif // ifndef __GAP_H__
\ No newline at end of file
