I’ve got my Blynk app talking to my Adafruit Bluefruit. I can trigger back and forth with virtual write. But I cannot get a webhook to return data. It doesn’t make sense to me that the output virtual pin of the webhook is also the trigger pin ? So if I a webhook is set to V0, then If I write to V0 it will trigger the webhook and set the output of the http request back to V0 ? If this is how it’s supposed to work it doesn’t work for me. The webhook is firing but the response is not getting stored anywhere.
Here is my code that should print out the response but param.asStr() always comes back as 0 or 1 which is what the button in the App is setting V0 to be.
BLYNK_WRITE(V0)
{
Serial.print("blynk_write v0");
String i = param.asStr();
Serial.println(i);
}
Also strange thing is that the Android app will fire the webhook but the iphone app does not. Still cannot get any data back. The data is plaintext and looks like this : NE 51 11g14. Web server is showing 200 response in the log.
@tavdog please edit your post, using the pencil icon at the bottom, and add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Why not?
Triggering an action by writing to a function, and returning the response is the standard way of using parameterised function calls. This is no different.
If you make the same API call via Postman or something similar, what does it return?
It’s not an API call at all actually. it’s just a txt file on my webserver and it returns a line of text such as “NE 51 11g14”
the url is http://wildc.net/wind/kanaha
The whole point of using the webhook widget is to get this data sent back to my hardware via BlueTooth. The widget documentation clearly states that you can get data back with the widget by using the get method. Are you suggesting that because the data is raw text and not json that Blynk is ignoring the returned data ?
It shouldn’t matter. The webhook is fired via the Blynk App in any case. The url is defined in the Blynk Webhook widget. The documentation even mentions the ability of using https even if your hardware can’t support it because the actual http client is the Blynk app running on the phone.
From the Webhook Get Example code
// You can perform HTTPS requests even if your hardware alone can't handle SSL
// Blynk can also fetch much bigger messages,
// if hardware has enough RAM (set BLYNK_MAX_READBYTES to 4096)
//Blynk.virtualWrite(V0, "https://api.sunrise-sunset.org/json?lat=50.4495484&lng=30.5253873&date=2016-10-01");
}
So I tried mostly identical code with an ESP32 board over wifi and the webhook triggers and returns the data as it is supposed to. Back on the Bluetooth board everything works except for the return of the data from the webhook. So I suppose this is an issue with Bluetooth support in the Blynk app/firmware.
As you’ve discovered, the Webhook call is made from the server, not the app.
There is some functionality where the phone acts as a bridge between the BT network and the server, provided the phone has an internet connection which allows it to communicate with the server, but it appears from your tests that Webhooks aren’t part of that functionality.
Personally, I never use Bluetooth for my IoT home automation projects, as I have no use for its functionality and the limitations of using Blynk over BT are too great.
Hopefully BT support will be dropped from the next version of Blynk.
Why did you mark this as Solved ? The issue is not solved until they fix this bug in the Bluetooth functionality ? Hopefully they will fix this bug in the next release and not just throw out BT altogether just because you don’t use bluetooth in your projects.
It’s not a bug, it’s a limitation of the architecture. The app will never act as a server and I’d doubt very much whether it will ever be developed to a point where Webhook calls can be made from the device running the app.
Blynk development is primarily driven by the requirements of corporate (paying) customers and that is driving the look, feel and functionality of the new version of Blynk. The new version is very different to the current version, with much of the functionality and setup done via a web portal, and I do’t see how Bluetooth can fit into this, or how it could be used practically in a corporate environment.
There is lots of functionality within Blynk that I don’t use, and I don’t advocate it’s removal, but BT is different.