回答編集履歴

1

追記

2020/12/15 23:38

投稿

ozwk
ozwk

スコア13512

test CHANGED
@@ -7,3 +7,51 @@
7
7
 
8
8
 
9
9
  ポインタではなくそのまま渡すのでは?
10
+
11
+
12
+
13
+ ---
14
+
15
+
16
+
17
+ 適当なことを言うもんじゃないですね。
18
+
19
+ ESP32のArduinoライブラリのコードを見てみます。(リファレンスより先に見つけられたので)
20
+
21
+
22
+
23
+ [arduino-esp32/BLECharacteristic.h at master · espressif/arduino-esp32](https://github.com/espressif/arduino-esp32/blob/master/libraries/BLE/src/BLECharacteristic.h)
24
+
25
+
26
+
27
+
28
+
29
+ ```C++
30
+
31
+ void setValue(uint8_t* data, size_t size);
32
+
33
+ void setValue(std::string value);
34
+
35
+ void setValue(uint16_t& data16);
36
+
37
+ void setValue(uint32_t& data32);
38
+
39
+ void setValue(int& data32);
40
+
41
+ void setValue(float& data32);
42
+
43
+ void setValue(double& data64);
44
+
45
+ ```
46
+
47
+
48
+
49
+ `pCharacteristic->setValue("Number -> Even");`の場合は`const char*`が型変換されて
50
+
51
+ `void setValue(std::string value);`
52
+
53
+ が使われます
54
+
55
+ 一方、`String`の場合は`std::string`への暗黙の変換をしてくれないので
56
+
57
+ `std::string`、ないしは`char*`への変換を明示的に書く必要があります