File tree Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Expand file tree Collapse file tree 2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -683,6 +683,43 @@ void BLECharacteristic::setValue(std::string value) {
683
683
setValue ((uint8_t *)(value.data ()), value.length ());
684
684
} // setValue
685
685
686
+ void BLECharacteristic::setValue (uint16_t & data16) {
687
+ uint8_t temp[2 ];
688
+ temp[0 ]=data16;
689
+ temp[1 ]=data16>>8 ;
690
+ setValue (temp, 2 );
691
+ } // setValue
692
+
693
+ void BLECharacteristic::setValue (uint32_t & data32) {
694
+ uint8_t temp[4 ];
695
+ temp[0 ]=data32;
696
+ temp[1 ]=data32>>8 ;
697
+ temp[2 ]=data32>>16 ;
698
+ temp[3 ]=data32>>24 ;
699
+ setValue (temp, 4 );
700
+ } // setValue
701
+
702
+ void BLECharacteristic::setValue (int & data32) {
703
+ uint8_t temp[4 ];
704
+ temp[0 ]=data32;
705
+ temp[1 ]=data32>>8 ;
706
+ temp[2 ]=data32>>16 ;
707
+ temp[3 ]=data32>>24 ;
708
+ setValue (temp, 4 );
709
+ } // setValue
710
+
711
+ void BLECharacteristic::setValue (float & data32) {
712
+ uint8_t temp[4 ];
713
+ *((float *)temp) = data32;
714
+ setValue (temp, 4 );
715
+ } // setValue
716
+
717
+ void BLECharacteristic::setValue (double & data64) {
718
+ uint8_t temp[8 ];
719
+ *((double *)temp) = data64;
720
+ setValue (temp, 8 );
721
+ } // setValue
722
+
686
723
687
724
/* *
688
725
* @brief Set the Write No Response property value.
Original file line number Diff line number Diff line change @@ -75,6 +75,11 @@ class BLECharacteristic {
75
75
void setReadProperty (bool value);
76
76
void setValue (uint8_t * data, size_t size);
77
77
void setValue (std::string value);
78
+ void setValue (uint16_t & data16);
79
+ void setValue (uint32_t & data32);
80
+ void setValue (int & data32);
81
+ void setValue (float & data32);
82
+ void setValue (double & data64);
78
83
void setWriteProperty (bool value);
79
84
void setWriteNoResponseProperty (bool value);
80
85
std::string toString ();
You can’t perform that action at this time.
0 commit comments