// This function is used by Blynk to send data
size_t BlynkStreamWrite(const void* buf, size_t len)
{
return Serial.write((byte*)buf, len);
}
so it uses a loop and Serial.write(val)?
I’m trying to get an Arduino UnoWifi to work using the generic setup template, but Wifi.write((byte*)buf,len) won’t compile, the library only understands Wifi.write(val). So, tried to rewrite to a for next loop but I get compile errors.
It has to do with dereferencing the const void* pointer to ‘byte’ type but it’s beyond me, I tried everything I could think of
When I wrote the two stream functions like below, it finally compiled. But it won’t connect and I don’t know how to debug other then with a few LED’s…
// This function is used by Blynk to receive data
size_t BlynkStreamRead(void* buf, size_t len)
{
return client.readBytes((byte*)buf, len);
}
// This function is used by Blynk to send data
size_t BlynkStreamWrite(const void* buf, size_t len)
{
uint8_t* byte_buff = (uint8_t*) buf; //Legally cast void to byte
size_t n = 0;
while (len–) { // client.write can only send one byte at a time
if (client.write(*byte_buff++)) n++;
else break;
}
return n;
}
Got debugging going via wifi. It seems to send the auth key, but other than that I get something like:
0[128350] Sent 0/37
[128371] <[02|00|01|00]
What does it mean?
I tried putty to make a telnet connection to blynk-cloud.com
On port 22 I get a response from the os (ubuntu)
On port 8442 nothing, just exits putty
I installed the telnet client in my windows 10 environment. Wouldn’t connect either on port 8442…
Exact same problem.
BUT, I can ping blynk-cloud.com just fine. I get address 46.101.143.225, turnaround 27ms so plenty fast.
Is the blynk server out?
You have to return the amount of bytes written from BlynkStreamWrite.
it looks like client.write(*byte_buff++) return 0, maybe you can just ignore the value…
In the mean time I installed a local blynk server only to find out that the User_defined_connection template (which is USB based) doesn’t support a local server…
Aargh, I’m an idiot. The USB sketch needs a (serial port?) service on the pc side. Completely forgot about that. I can access a console (webpage and telnet) on the uno wirelessly and perhaps modify your PC script to get to the streams. More problems…
What I have is a basic wifi connection on my uno-wifi and now I need to fix myself up some kind of client that uses that. I have been looking at your arduino templates (the .h files), but that is way over my head. Any advise that you can give me? Which of your templates comes closest?