'User_defined_connection' template: change stream write to for loop of single value

Does anyone know how to rewrite this:

// 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 :frowning:

I think, in this case you can send data byte-by-byte in a loop… but there’s high chance it won’t “just work”. You should try…

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;
}

Is it somewhere documented what exactly Blynk.connect() does? Is it in readable ASCII?

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?

Any help sure appreciated!

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…

O.k, thanks, I can check that.

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…

Fixed the streamwrite like you said. Sent 0/37 gone from debug log. Instead I get a ‘Login timeout’

<[02|00|01|00] This looks suspicious. Any idea if this has to do with receive?

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?