icinn
October 2, 2021, 4:30am
1
Hello All, Can anyone help me,please! my code error like this:
exit status 1
no matching function for call to 'BLEStringCharacteristic::read(arduino::String)'
and my code is like this
else if(result.classification[7].value > 0.70)
{
String data = "Terdeteksi Takut";
Serial.println(data);
if(central.connected()) serviceOutput.read(String(data));
takut();
}
What type of data does the read() function take ?
It seems that it is not a String
Please post your full sketch so that the context of the problem can be seen
I think the places where you use "String data" like this:
{
String data = "Terdeteksi Sedih";
Serial.println(data);
if (central.connected()) serviceOutput.read(String (data), 16);
sedih();
}
Should be:
{
Serial.println( "Terdeteksi Sedih");
if (central.connected()) serviceOutput.read( "Terdeteksi Sedih", 16);
sedih();
}
or maybe:
{
char data[] = "Terdeteksi Sedih";
Serial.println(data);
if (central.connected()) serviceOutput.read(data, 16);
sedih();
}
icinn
October 3, 2021, 9:55am
5
oke thanks @johnwasser , i will trying it
icinn
October 3, 2021, 11:56am
6
I have tried but still like this, can you help me,please
gcjr
October 3, 2021, 12:15pm
7
BLEService service("42e48f10-e4e8-4c4e-b96e-b61cafdeb2f7");
BLEStringCharacteristic serviceOutput("9A48ECBA-2E92-082F-C079-9E75AAE428B1", BLERead | BLENotify ,100 );
instead of "serviceOutput" should it be "service"?
That says that the .read() function you are calling doesn't take any arguments. I think you are calling the wrong function if you are trying to pass it arguments. Go back to the example you are following and check you code.
I think you should be using serviceOutput.value()
String BLEStringCharacteristic::value(void)
{
String str;
int length = BLECharacteristic::valueLength();
const uint8_t* val = BLECharacteristic::value();
str.reserve(length);
for (int i = 0; i < length; i++) {
str += (char)val[i];
}
return str;
}
icinn
October 4, 2021, 4:39am
10
is there any provision in making the characteristics? or the name, because I tried to make any name and it didn't work, while when I made the name the code could be run, and I also saw how it was written on the internet and someone made serviceOutput
icinn
October 4, 2021, 4:41am
11
oke i will check my code, looks like I was wrong in the characteristics. thanks @johnwasser
icinn
October 4, 2021, 4:45am
12
Thanks @cattledog . but , guess where is this i add it in my code? can you help me,please ? I'm a little clueless about this syntax.
I suggest you write a simple test sketch where you set up a String characteristic for a service and write and read between a peripheral and central.
You may get some feel for the syntax from this posting
https://forum.arduino.cc/t/ble-code-to-take-string-input-from-another-bluetooth-enabled-deice/643877/2
icinn
October 4, 2021, 5:38am
14
oke thanks @cattledog i will trying.
icinn
October 4, 2021, 6:33am
15
Thanks all @UKHeliBob @cattledog @johnwasser @gcjr , i can run my code and it can be read on nRF Connect. I created a UUID service and its characteristics like this Get Started with Arduino Nano 33 BLE - OKdo . and I changed my code to be like this:
else if(result.classification[1].value > 0.70){
Serial.print( "Terdeteksi Marah");
if(central.connected()) greetingCharacteristic.setValue("Terdeteksi Marah");
marah();
I have permission to delete my code because I am in the process of completing research so that my final project is not detected by copies from the internet
system
Closed
April 2, 2022, 6:33am
16
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.