-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Main header doesn't include MemoryStream.hpp #4
Comments
Hi @skyhisi,
@skyhisi, do you really use this class in your project? Best Regards, |
Hi Benoit, My use case is to build up a string in memory with Something like: MemoryStream stream(512);
stream.print(F("temperature="));
stream.print(temperature);
stream.print(F(",humidity="));
stream.print(humidity);
// ...
char buf[64];
while ((len = buffer.readBytes(buf, sizeof(buf))) != 0)
{
client.write((uint8_t*)buf, len);
} If there's a better way of doing this, let me know. |
Did you mean If so, you probably want to use WriteBufferingClient bufferingClient(client, 64);
bufferingClient.print(F("temperature="));
bufferingClient.print(temperature);
bufferingClient.print(F(",humidity="));
bufferingClient.print(humidity);
bufferingClient.flush(); |
Yes, sorry I did mean In this case, I'm not sure I can use the normal buffering classes, as I need to get the size of the complete buffer (I'm using My actual code is closer to this: PubSubClient mqttClient(/*...*/);
void upload()
{
// ...
MemoryStream influxLine(512);
influxLine.print(F("weather "));
influxLine.print(F("temperature="));
influxLine.print(temperature);
//...
if (!mqttClient.beginPublish(TOPIC_PREFIX "/influx", influxLine.available(), true))
{
LOG("Failed to begin publish Influx update");
goto exit;
}
while ((len = influxLine.readBytes(buf, 64)) != 0)
{
mqttClient.write((uint8_t*)buf, len);
}
if (!mqttClient.endPublish())
{
LOG("Failed to end publish Influx update");
goto exit;
}
// ... Is there a better way to do this? |
I would probably use I think you're right: this class seems to be useful outside of my unit tests. |
|
The main header file doesn't include
MemoryStream.hpp
.Fix:
The text was updated successfully, but these errors were encountered: