[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [paho-dev] mqtt.embedded-c/MQTTPacket/ samples and src/MQTTPacket.c
|
> But in pub0sub1.c, the timeout value for reading is set to 1 second.
Can't
> you increase that timeout value to sufficiently long that the reads will
> complete?
Hi Ian,
yes, I could, but that would mean that function call would block (at
transport_getdata()) until the expected amount of data arrives, or the
timeout occurs. Even though the sample would work on my Linux now, this
is embedded code and non-RTOS users (like me) would swear at this code
when run on bare metal.
MQTT packet reader assumes the required amount of data is present for
the needed processing (ID, packet length, etc), and that is not true for
at least one of the supported transports: TCP (are there any others?)
My usual approach for small messages over TCP is an intermediate buffer
to collect the data. 256 bytes should not be overkill for a system
having a TCP/IP stack with TCP, and the approach should be less
cumbersome than peeking if the underlying stack doesn't have this
capability right away. Anyway, peeking can be added later if needed.
I can do the mods if you agree (and can wait for me)
Best regards