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
@@ -654,16 +664,6 @@ class BLEDevice
654
664
void setAddress (const bt_addr_le_t & addr);
655
665
656
666
void setAdvertiseData (const uint8_t * adv_data, uint8_t len);
657
- /* *
658
- * @brief The BLE device constructure
659
- *
660
- * @param[in] bleaddress BLE device address
661
- *
662
- * @return none
663
- *
664
- * @note none
665
- */
666
- BLEDevice (const bt_addr_le_t * bleaddress);
667
667
private:
668
668
void preCheckProfile ();
669
669
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 @@ -98,11 +98,11 @@ BLEDeviceManager::~BLEDeviceManager()
98
98
99
99
bool BLEDeviceManager::begin (BLEDevice *device)
100
100
{
101
- if (NULL == _local_ble && false == *device )
101
+ if (NULL == _local_ble)
102
102
{
103
103
_local_ble = device;
104
- _local_ble->setAddress (_local_bda);
105
104
bt_le_set_mac_address (_local_bda);
105
+
106
106
// Set device name
107
107
setDeviceName ();
108
108
_state = BLE_PERIPH_STATE_READY;
@@ -134,7 +134,8 @@ void BLEDeviceManager::poll()
134
134
}
135
135
136
136
void BLEDeviceManager::end ()
137
- {}
137
+ {
138
+ }
138
139
139
140
bool BLEDeviceManager::connected (const BLEDevice *device) const
140
141
{
@@ -288,7 +289,10 @@ void BLEDeviceManager::setDeviceName(const char* deviceName)
288
289
if (len > BLE_MAX_DEVICE_NAME)
289
290
len = BLE_MAX_DEVICE_NAME;
290
291
memcpy (_device_name, deviceName, len);
291
- setDeviceName ();
292
+ if (NULL != _local_ble)
293
+ {
294
+ setDeviceName ();
295
+ }
292
296
}
293
297
}
294
298
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