react-native-mqtt icon indicating copy to clipboard operation
react-native-mqtt copied to clipboard

Invalid QOS when publishing data

Open pavb74 opened this issue 9 years ago • 0 comments

I want to publish data with QOS=1 because my messaging service (RabbitMQ) doesn't support QOS=2. The QOS parameter is not correctly parsed and the QOS is always set to 2 whatever the value put in parameter.

It seems to come from the publish method of Mqtt.m and the conversion of the QOS attribute from Number to MQTTQosLevel. When I add a pre conversion to an unsigned int it works.

// Before

  • (void) publish:(NSString *) topic data:(NSData *)data qos:(NSNumber *)qos retain:(BOOL) retain { [self.manager sendData:data topic:topic qos:(MQTTQosLevel)qos retain:retain]; //[data dataUsingEncoding:NSUTF8StringEncoding] }

// After

  • (void) publish:(NSString *) topic data:(NSData *)data qos:(NSNumber *)qos retain:(BOOL) retain { [self.manager sendData:data topic:topic qos:(MQTTQosLevel)[qos unsignedIntValue] retain:retain]; //[data dataUsingEncoding:NSUTF8StringEncoding] }

Is it possible to re-integrate this fix please?

Thanks

PA

pavb74 avatar Aug 26 '16 08:08 pavb74