Skip to content

Commit 3cb7236

Browse files
committed
added BLECharacteristic notify32/indicate32(float)
1 parent 2a34e2a commit 3cb7236

File tree

4 files changed

+25
-10
lines changed

4 files changed

+25
-10
lines changed

libraries/Bluefruit52Lib/examples/Peripheral/bluefruit_playground/bluefruit_playground.ino

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,6 @@ uint16_t measure_color(uint8_t* buf, uint16_t bufsize)
150150
return sizeof(rgb);
151151
}
152152

153-
154-
155153
void gesture_enable_callback(uint16_t conn_hdl, bool enabled)
156154
{
157155
(void) conn_hdl;

libraries/Bluefruit52Lib/src/BLECharacteristic.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -751,6 +751,11 @@ bool BLECharacteristic::notify32(uint16_t conn_hdl, int num)
751751
return notify(conn_hdl, (uint8_t*) &num, sizeof(num));
752752
}
753753

754+
bool BLECharacteristic::notify32(uint16_t conn_hdl, float num)
755+
{
756+
return notify(conn_hdl, (uint8_t*) &num, sizeof(num));
757+
}
758+
754759
//--------------------------------------------------------------------+
755760
// Notify with single connection
756761
//--------------------------------------------------------------------+
@@ -784,6 +789,10 @@ bool BLECharacteristic::notify32(int num)
784789
return notify32(BLE_CONN_HANDLE_INVALID, num);
785790
}
786791

792+
bool BLECharacteristic::notify32(float num)
793+
{
794+
return notify32(BLE_CONN_HANDLE_INVALID, num);
795+
}
787796

788797
/*------------------------------------------------------------------*/
789798
/* INDICATE multiple connections
@@ -874,6 +883,11 @@ bool BLECharacteristic::indicate32(uint16_t conn_hdl, int num)
874883
return indicate32(conn_hdl, (uint32_t) num);
875884
}
876885

886+
bool BLECharacteristic::indicate32(uint16_t conn_hdl, float num)
887+
{
888+
return indicate(conn_hdl, (uint8_t*) &num, sizeof(num));
889+
}
890+
877891
/*------------------------------------------------------------------*/
878892
/* INDICATE single connections
879893
*------------------------------------------------------------------*/
@@ -906,3 +920,8 @@ bool BLECharacteristic::indicate32(int num)
906920
{
907921
return indicate32(BLE_CONN_HANDLE_INVALID, num);
908922
}
923+
924+
bool BLECharacteristic::indicate32(float num)
925+
{
926+
return indicate32(BLE_CONN_HANDLE_INVALID, num);
927+
}

libraries/Bluefruit52Lib/src/BLECharacteristic.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ class BLECharacteristic
134134
bool notify16 (uint16_t num);
135135
bool notify32 (uint32_t num);
136136
bool notify32 (int num);
137+
bool notify32 (float fnum);
137138

138139
/*------------- Notify multiple connections -------------*/
139140
// bool notify (uint16_t conn_hdl);
@@ -144,6 +145,7 @@ class BLECharacteristic
144145
bool notify16 (uint16_t conn_hdl, uint16_t num);
145146
bool notify32 (uint16_t conn_hdl, uint32_t num);
146147
bool notify32 (uint16_t conn_hdl, int num);
148+
bool notify32 (uint16_t conn_hdl, float num);
147149

148150
/*------------- Indicate -------------*/
149151
bool indicateEnabled(void);
@@ -156,6 +158,7 @@ class BLECharacteristic
156158
bool indicate16 (uint16_t num);
157159
bool indicate32 (uint32_t num);
158160
bool indicate32 (int num);
161+
bool indicate32 (float num);
159162

160163
/*------------- Indicate multiple connections -------------*/
161164
bool indicate (uint16_t conn_hdl, const void* data, uint16_t len);
@@ -165,6 +168,7 @@ class BLECharacteristic
165168
bool indicate16 (uint16_t conn_hdl, uint16_t num);
166169
bool indicate32 (uint16_t conn_hdl, uint32_t num);
167170
bool indicate32 (uint16_t conn_hdl, int num);
171+
bool indicate32 (uint16_t conn_hdl, float num);
168172

169173
/*------------- Internal Functions -------------*/
170174
virtual void _eventHandler(ble_evt_t* event);

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,6 @@
4141
#define CFG_BLE_TX_POWER_LEVEL 0
4242
#endif
4343

44-
#ifdef USB_PRODUCT
45-
#define CFG_DEFAULT_NAME USB_PRODUCT
46-
#else
47-
#define CFG_DEFAULT_NAME "Feather nRF52832"
48-
#endif
49-
5044
#ifndef CFG_BLE_TASK_STACKSIZE
5145
#define CFG_BLE_TASK_STACKSIZE (256*5)
5246
#endif
@@ -195,7 +189,7 @@ void AdafruitBluefruit::configServiceChanged(bool changed)
195189
_sd_cfg.service_changed = (changed ? 1 : 0);
196190
}
197191

198-
void AdafruitBluefruit::configUuid128Count(uint8_t uuid128_max)
192+
void AdafruitBluefruit::configUuid128Count(uint8_t uuid128_max)
199193
{
200194
_sd_cfg.uuid128_max = uuid128_max;
201195
}
@@ -460,7 +454,7 @@ bool AdafruitBluefruit::begin(uint8_t prph_count, uint8_t central_count)
460454

461455
// Default device name
462456
ble_gap_conn_sec_mode_t sec_mode = BLE_SECMODE_OPEN;
463-
VERIFY_STATUS(sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) CFG_DEFAULT_NAME, strlen(CFG_DEFAULT_NAME)), false);
457+
VERIFY_STATUS(sd_ble_gap_device_name_set(&sec_mode, (uint8_t const *) USB_PRODUCT, strlen(USB_PRODUCT)), false);
464458

465459
// Init Central role
466460
if (_central_count) Central.begin();

0 commit comments

Comments
 (0)