File tree 4 files changed +20
-51
lines changed
4 files changed +20
-51
lines changed Original file line number Diff line number Diff line change @@ -59,6 +59,16 @@ class BLEDevice
59
59
*/
60
60
BLEDevice (const BLEDevice* bledevice);
61
61
BLEDevice (const BLEDevice& bledevice);
62
+ /* *
63
+ * @brief The BLE device constructure
64
+ *
65
+ * @param[in] bleaddress BLE device address
66
+ *
67
+ * @return none
68
+ *
69
+ * @note none
70
+ */
71
+ BLEDevice (const bt_addr_le_t * bleaddress);
62
72
virtual ~BLEDevice ();
63
73
64
74
@@ -653,16 +663,6 @@ class BLEDevice
653
663
void setAddress (const bt_addr_le_t & addr);
654
664
655
665
void setAdvertiseData (const uint8_t * adv_data, uint8_t len);
656
- /* *
657
- * @brief The BLE device constructure
658
- *
659
- * @param[in] bleaddress BLE device address
660
- *
661
- * @return none
662
- *
663
- * @note none
664
- */
665
- BLEDevice (const bt_addr_le_t * bleaddress);
666
666
private:
667
667
void preCheckProfile ();
668
668
Original file line number Diff line number Diff line change @@ -55,67 +55,37 @@ BLEPeripheral::~BLEPeripheral(void)
55
55
56
56
void BLEPeripheral::setAdvertisedServiceUuid (const char * advertisedServiceUuid)
57
57
{
58
- if (!_initCalled) {
59
- init ();
60
- }
61
-
62
58
BLE.setAdvertisedServiceUuid (advertisedServiceUuid);
63
59
}
60
+
64
61
void BLEPeripheral::setLocalName (const char * localName)
65
62
{
66
- if (!_initCalled) {
67
- init ();
68
- }
69
-
70
63
BLE.setLocalName (localName);
71
64
}
72
65
73
-
74
66
void BLEPeripheral::setDeviceName (const char *deviceName)
75
67
{
76
- if (!_initCalled) {
77
- init ();
78
- }
79
-
80
68
BLE.setDeviceName (deviceName);
81
69
}
82
70
83
71
void BLEPeripheral::setAppearance (const unsigned short appearance)
84
72
{
85
- if (!_initCalled) {
86
- init ();
87
- }
88
-
89
73
BLE.setAppearance (appearance);
90
74
}
91
75
92
76
void BLEPeripheral::setConnectionInterval (const unsigned short minConnInterval, const unsigned short maxConnInterval)
93
77
{
94
- if (!_initCalled) {
95
- init ();
96
- }
97
-
98
78
BLE.setConnectionInterval (minConnInterval, maxConnInterval);
99
79
}
100
80
101
81
void BLEPeripheral::addAttribute (BLEService& service)
102
82
{
103
- if (!_initCalled)
104
- {
105
- init ();
106
- }
107
-
108
83
BLE.addService (service);
109
84
_lastService = &service;
110
85
}
111
86
112
87
void BLEPeripheral::addAttribute (BLECharacteristic& characteristic)
113
88
{
114
- if (!_initCalled)
115
- {
116
- init ();
117
- }
118
-
119
89
if (_lastService)
120
90
{
121
91
_lastService->addCharacteristic (characteristic);
@@ -125,11 +95,6 @@ void BLEPeripheral::addAttribute(BLECharacteristic& characteristic)
125
95
126
96
void BLEPeripheral::addAttribute (BLEDescriptor& descriptor)
127
97
{
128
- if (!_initCalled)
129
- {
130
- init ();
131
- }
132
-
133
98
if (_lastCharacteristic)
134
99
{
135
100
_lastCharacteristic->addDescriptor (descriptor);
Original file line number Diff line number Diff line change @@ -97,11 +97,11 @@ BLEDeviceManager::~BLEDeviceManager()
97
97
98
98
bool BLEDeviceManager::begin (BLEDevice *device)
99
99
{
100
- if (NULL == _local_ble && false == *device )
100
+ if (NULL == _local_ble)
101
101
{
102
102
_local_ble = device;
103
- _local_ble->setAddress (_local_bda);
104
103
bt_le_set_mac_address (_local_bda);
104
+
105
105
// Set device name
106
106
setDeviceName ();
107
107
_state = BLE_PERIPH_STATE_READY;
@@ -133,7 +133,8 @@ void BLEDeviceManager::poll()
133
133
}
134
134
135
135
void BLEDeviceManager::end ()
136
- {}
136
+ {
137
+ }
137
138
138
139
bool BLEDeviceManager::connected (const BLEDevice *device) const
139
140
{
@@ -287,7 +288,10 @@ void BLEDeviceManager::setDeviceName(const char* deviceName)
287
288
if (len > BLE_MAX_DEVICE_NAME)
288
289
len = BLE_MAX_DEVICE_NAME;
289
290
memcpy (_device_name, deviceName, len);
290
- setDeviceName ();
291
+ if (NULL != _local_ble)
292
+ {
293
+ setDeviceName ();
294
+ }
291
295
}
292
296
}
293
297
Original file line number Diff line number Diff line change 25
25
#include " BLECallbacks.h"
26
26
#include " BLEUtils.h"
27
27
28
- BLEDevice BLE;
28
+ BLEDevice BLE (BLEUtils::bleGetLoalAddress()) ;
29
29
30
30
BLEProfileManager* BLEProfileManager::_instance = NULL ;
31
31
You can’t perform that action at this time.
0 commit comments