I plan to send/publish datas (which collected from Arduino) to a MQTT broker. The MQTT library I used is knolleary's PubSubClient. It works well so far with few brokers I've tested like Mosquitto test broker, IBM IoT Platform, and ActiveMQ. My Arduino can publish datas successfully to those brokers.
But the actual broker in the end that I have to connect is needed Oauth authorization, which means an authorized password has to be provided within the connection. I have written a java program at my local computer which can generate the authorized password and connect to that designated broker.
Now I just hard code the generated password to my Arduino sketch, which came out to be a very long string... despite hard code, the random generated password is still that big size... (about 332 characters)
So I got two questions here.
If one very long string is declared, why the serial output will show some unreadable characters like this:
Below is the long string (about 332 characters) and print code.
String password = "QXV0aG9yaXphdGlvbjogT0F1dGggb2F1dGhfY29uc3VtZXJfa2V5PSJlbGluMjAxNS5Qcm9qZWN0MSIsIG9hdXRoX3NpZ25hdHVyZV9tZXRob2Q9IkhNQUMtU0hBMSIsIG9hdXRoX3NpZ25hdHVyZT0iSlZCSnEwJTJCdGJYZE1rcFJZenVIeEJkT1VDcW8lM0QiLCBvYXV0aF90aW1lc3RhbXA9IjE0MzgwNzExNDYiLCBvYXV0aF9ub25jZT0iMTQzODA3MTE0NiIsIG9hdXRoX3ZlcnNpb249IjEuMCI7Q2xpZW50LVZlcnNpb246IFN0YWdlQlE="; Serial.println(password);
I guess the root cause of #1 may be that serial output is restricted from Arduino's RAM size. In my case, I use Arduino UNO REV3which only has 2KB RAM. I checked PROGMEM which declares the string as a const string. But I cannot deal with const string, it must be a string that can be modified. So, how can I handle a very long string without const declaration?