send files from fs to server?
Thanks Sergey but I'm trying to send a sound file(Wav) and I don't know how to convert a wav to string or any other format on Mongoose, I saw some notes on File Parsing on mongoose os's Docs but it is not there anymore on the website
A sound file over MQTT?
That's creative How big it is?
Well, don't parse or convert. Try to send file contents verbatim, exactly as I have shown. Let me know how did that work.
It's not working
please use mos tool , publish your code like described here https://mongoose-os.com/blog/code-snippets-sharing-with-mongoose-os/
let's get it working.
I'm just sending a wav file to mqtt server but I'm getting this error on iot console when I test it
Mqtt connection lost. Reconnect. Error code: 5. AMQJS0005E Internal error. Error Message: AMQJS0009E Malformed UTF data:80 -42 ., Stack trace: Error: AMQJS0009E Malformed UTF data:80 -42 . at i (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:1705) at x._getPayloadString (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:28974) at x.get payloadString [as payloadString] (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:29745) at v.a.client.onMessageArrived (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_Prod_588d4b4c7755f60a6c188d58e9f241a77d1e5623.gz.js:21:3714) at v._receiveMessage (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:20053) at v._receivePublish (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:19592) at v._handleMessage (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:17169) at v._on_socket_message (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:15393) at WebSocket. (https://d2vrh8t1ao8du6.cloudfront.net/js/iot_mindep_Prod_1dae13060e2aa550bec466f4db732fcdce17b2c5.gz.js:16:2811)
There are two problems.
First, spooling the whole into RAM would not work. The file is too big.
Second, binary file data may have non-UTF8 symbols.
Therefore, sending logic must break file data into pieces and encode each piece before sending, by e.g. base64 or hex encoding.
Are those points clear?
I am getting following errors when I try to put the files
For text file(2kb)
Context deadline exceeded
For wav file(70kb)
2)Handle is invalid
However, the files appear in the system but they are incomplete. I couldn't tell that with the wav file but realized that when I try to put the base64 header file.The file appeared in the system but was incomplete
(https://ibb.co/hnuuqk "error screenshot")
That's weird! At least that small text file should be fine.
What if you copy a really tiny text file, like few bytes long?
Small text file is getting copied but with the same error message
Are you using the latest mos and the latest firmware?
Yes, downloaded the latest firmware couple of days ago
I updated the mos and firmware again just to be sure
This time it loads up the complete files which are < 5kb.
Error still persists with the files > 5kb
hm. how much free space do you have on the fs?
mos call Sys.GetInfo
I have 13 kb free fs
In the image base64.h is of size 2kb and codex.txt is 2kb
But this gave me an idea! I will free up the fs and give it one more try
Thanks Sergey for your quick and helpful responses!
13 kb is too low.
That could be the reason for your failures.