Copyright ©

Mongoose OS Forum


How to convert int to string?

I need to prepare a request string for Thingspeak MQTT API. The content of the published message needs to follow old Thingspeak GET request rules:
I want to fill the numeric part with values returned from mJS calls - for example,, or ESP32.temp() - those calls return FFI-ed int's.
Implicit conversion fails with error, ESP32.temp().toString() also does not work.
So I have no idea how to achieve this in the JS code. The only way that I see now is to create new C FFI functions that returns "char*" results - so I could make the conversion in the C using sprintf() or friends.
Is there something that I am missing? Maybe this could be achieved in some JS API lib, liks "string_utils.js" - but I am not that good at JS to create one myself.


Sign In or Register to comment.