paho.mqtt.c
paho.mqtt.c copied to clipboard
fix: MQTTPacket.c read&write Int/Int4 error
MQTTPacket.c read&write Int/Int4 error readInt writeInt readInt4 writeInt4
eg: writeInt4(0xFFFFFFFF)
Signed-off-by: lijinggang [email protected]
Looks like there's a problem: https://github.com/eclipse/paho.mqtt.c/issues/1372
Looks like there's a problem: #1372 my problem, readInt realy means readInt16 ? Or readUInt16 ?
Looks like there's a problem: #1372 my problem, readInt realy means readInt16 ? Or readUInt16 ?
int readInt(char** pptr) {
char *ptr = *pptr;
uint16_t val = ((((uint16_t)ptr[0]) << 8) | (uint8_t)ptr[1]);
*pptr += 2;
return val;
}
Looks like there's a problem: #1372 my problem, readInt realy means readInt16 ? Or readUInt16 ?
int readInt(char** pptr) { char *ptr = *pptr; uint16_t val = ((((uint16_t)ptr[0]) << 8) | (uint8_t)ptr[1]); *pptr += 2; return val; }
suggest:
- change Integer type to what it's extra is. readInt will be readUInt16,
- using Intege type from <stdint.h> , link uint16_t , uint32_t
- char* should change to uint8_t or typedef byte_t