Search code examples
file-uploadfilepathgsmat-commandsim800

SIM800C GSM AT COMMAND How to upload .amr audio file programmatically


I am desperatly trying to upload some audio file to the internal memory of a SIM800C, so far this is what I've been able to do, but the uploaded file seems void, and doesnt play any sound. But with AT+FSLS=C:\\ I can see the file is there.

Here are the AT commands I am using:

AT+FSCREATE=tts2.amr 
AT+FSWRITE=tts2.amr,0,5030,10 
AT+FSLS=C:\\

I made a nodeJS program to do the job, but I am openned to any other language that works on linux.

  modem.executeCommand('AT+FSCREATE=tts2.amr',(result) => { log.debug(result); });
        modem.executeCommand('AT+FSWRITE=tts2.amr,0,5030,10',(result) => { log.debug(result); });
        modem.executeCommand('AT+FSLS=C:\\',(result) => { log.debug(result); });

In case you were wondering I've already seen this post which helped neither the OP nor me.

I've also seen this post but it doesnt suit to me, because it uses a tool (AmrFile Download.exe) to do the job manually, I need to do it programmatically. I thought if that tool could do it so can I, there must be a way, but have not yet found...

What really bugs me is how is the file located from my computer, and its content read before even loading it. I've kept the audio file tts2.amr in the same directory than the nodejs script since the AT commands shows me no way to specify a path for the source file it only considers the destination, so I've no clue how to do it, and I feel it doesnt work like that.

UPDATE:


From the docs:

enter image description here enter image description here

Here they have mentionned a data parameter for reading operation, so you can have the read data. But for write operation there is no such thing, so I'm pretty much confused.


Solution

  • I think the post you mentioned is right. In App note, page 13, there is also an example.

    So in your program, suppose you have a local file ~/tts0.amr with size 5030 bytes, (tts2.amr is the file name inside modem)

    1. read file ~/tts0.amr to memeory variable, like amr_data for example;
    2. send AT+FSWRITE=tts2.amr,0,5030,10 to modem, waiting for > instead of OK;
    3. write amr_data to modem, just like the step above;
    4. if the size matching, modem shall return OK now.