How to send raw data as payload with MQTT on Nestjs

Viewed 34

I want to send just raw data to the broker but the string is sent as string with quotations.

i.e. the message I want to sent is: ti=0F:0000000000&id=E8EB1BE99345 but what is sent is: "ti=0F:0000000000&id=E8EB1BE99345"

How can I achieve that?

I have declared serializer in the mqtt client like below,

@Module({
  imports: [
    ClientsModule.register([
      {
        name: 'MQTT_CLIENT',
        transport: Transport.MQTT,
        options: {
          url: 'mqtt://XX.XXX.XXX.XXX:1883',
          clientId: 'my-client-id',
          serializer: {
            serialize: (value: any) => value.data,
          },
        },
      },
    ]),
    ConfigModule.forRoot(),
  ],
  controllers: [AppController],
})
export class AppModule {}

You can see here that the ACKs are sent with the quotations, and they should be sent like above, without them:

enter image description here

0 Answers
Related