1

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.

Xsmael
  • 3,624
  • 7
  • 44
  • 60

2 Answers2

3

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.
Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
ximingr
  • 101
  • 3
  • Thanks alot for your answer! it helped me alot. now I can successfully upload the audio file, however I noticed it takes way too much time, is there a way to stream some audio content throught the SIM800C when someone calls because my audio files are dynamically generated and then played to the caller, but if i need to upload it before playing, the caller wil wait for 1min at least before hearing anything! – Xsmael Jul 08 '19 at 14:20
  • 1
    You are happy, I am happy. I do not know about the streaming or audio. So this is more like a question for me, the 5K AMR file, can it be split into smaller ones and play one by one? If yes, then playing can be started just after the first fragment is uploaded. During its playing, the others can be uploaded. I never used such a modem, this might be too silly – ximingr Jul 11 '19 at 14:17
  • haha, well thought out! but am afraid it won't work, cause in practice i've noticed that uploading takes more time than playing so it could have gaps at some points. Nevertheless i am tempter to try it just to see! – Xsmael Jul 12 '19 at 16:50
1

By using @ximingr's answer I came up with this code which works fine.

var fs= require("fs");
let serialportgsm  = require('serialport-gsm');
let modem = serialportgsm.Modem();
let serialport = serialportgsm.serialport;

serialportgsm .list((err, result) => {
    // console.log(result);
})

let options = {
    baudRate: 115200,
    dataBits: 8,
    stopBits: 1,
    parity: 'none',
    rtscts: false,
    xon: false,
    xoff: false,
    xany: false,
    autoDeleteOnReceive: true,
    enableConcatenation: true,
    incomingCallIndication: true,
    incomingSMSIndication: true,
    pin: '',
    customInitCommand: '',
    logger: console
}
 
modem.open('COM11', options);

modem.on('open', data => {
    modem.initializeModem(function(p) {

        fs.readFile('tts2.amr', function(err,amr_data) {
            if(!err) {
                let fsize= fs.statSync('tts2.amr').size;
                modem.executeCommand('AT+FSCREATE=C:\\User\\tts2.amr',(result) => { log.debug(result); });
                modem.executeCommand('AT+FSWRITE=C:\\User\\tts2.amr,0,'+fsize+',100',(result) => { 
                modem.port.write(amr_data);
                });
             });
            }
        });     
    });
});
Roberto Caboni
  • 7,252
  • 10
  • 25
  • 39
Xsmael
  • 3,624
  • 7
  • 44
  • 60