Copyright © https://mongoose-os.com

Mongoose OS Forum

frame

about esp8266 use mongoose os

Can mongoose os implement the transport of MP3 files? What functions can be used to achieve? How to implement, if there is an example of reference, that is the best. Or does mongoose OS not support? I need an answer.

Comments

  • SergeySergey Dublin, Ireland

    Are you using C or JavaScript?

  • liuliu china

    @Sergey I use JavaScript .Do you have an example of this code that I can refer to?

  • SergeySergey Dublin, Ireland
    edited May 13

    First, you need to clarify what do you mean by "transport mp3 files". Please, ask your questions in a way they could be answered.

  • liuliu china

    @Sergey When esp8266 uses Mongoose OS, in AP mode, the mobile phone connects to the WiFi hotspot emitted by ESP8266, and the mobile terminal sends MP3 file to ESP8266, and then ESP8266 sends it to MCU

  • SergeySergey Dublin, Ireland

    Understood, thank you.

    If mp3 file can fit on flash, you can upload it via HTTP, see https://forum.mongoose-os.com/index.php?p=/discussion/comment/2434/#Comment_2434

  • liuliu china

    @Sergey thank you. But I don't want to use the command line input command to implement this function, but to do the file transfer through the code.

  • SergeySergey Dublin, Ireland

    @liu , you do not need to use that command line tool.

    That command line tool demonstrates how to use file upload via HTTP, and do it programmatically in any language.
    Just fire a POST request, similar to the one curl does.

    Is it more clear now?

  • liuliu china

    @Sergey My understanding is that the command line tells me the HTTP upload principle, but the specific code implementation, or the specific parameters are what? Upload, for example, in post mode. I still have a question about where my uploaded files are stored in ESP8266, and I'm trying to write the code.
    var xhr = new XMLHttpRequest();
    var url = " http://192.168.1.13/upload";//Is the URL correct?
    xhr.open("POST", url, true);
    xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");//Is right?
    if (xhr.readyState == 4 && xhr.status == 200)
    {
    alert("success !");
    }
    else
    {
    console.log(xhr.readyState + xhr.status);
    }
    var file = @ajax.js;// Confused and confused
    xhr.send( file );

  • SergeySergey Dublin, Ireland

    You're doing it wrong :)

    Search Internet for a simple HTTP upload form. No JS. just a file control, and a button.
    Set "action" form attribute to the http://192.168.1.13/upload.
    Choose file and press the button.

  • liuliu china

    @Sergey you said that is html upload?such as:
    form action="http://192.168.1.13/upload" method="post" enctype="multipart/form-data">





    I have a question. What's" http://192.168.1.13/upload " in mongoose os? Is this the only upload address? Still be able to customize? Where can I see the development documentation in this area?

  • liuliu china
    edited May 18

    @Sergey you said that is html upload?such as:

    <form action="http://192.168.1.13/upload" method="post" enctype="multipart/form-data">
    <label for="file">Filename:</label>
    <input type="file" name="file" id="file" />
    <br />
    <input type="submit" name="submit" value="Submit" />
    

    I have a question. What's" http://192.168.1.13/upload " in mongoose os? Is this the only upload address? Still be able to customize? Where can I see the development documentation in this area?

  • SergeySergey Dublin, Ireland

    @liu, you are asking extremely basic questions. I am afraid I cannot afford teaching basic stuff.

    Mongoose OS runs a web server, which has an /upload endpoint for uploading files.
    You can upload using a simple HTML form, or using curl utility, or programmatically by constructing a valid HTTP POST request.
    Please search Internet on how HTTP uploading works, and how to make a simple HTML form.
    Your HTML example is almost correct.

  • liuliu china

    @Sergey thank you ,Can you tell me where the uploaded files are stored?

  • SergeySergey Dublin, Ireland

    The file name is passed as a parameter of the multipart POST request.
    When browser does it, I believe an original file name is used.

  • liuliu china

    @Sergey ,thank you ,I use the most basic HTTP upload method, upload files, I can see through command MOS LS I uploaded the file on the ESP8266, but Console logs shows:
    Mg_file_upload_handl, 0x3fff8e64, Not, allowed, to, upload
    What is the reason for this?
    Finally, I have one more question: can mongoose OS send files from ESP8266 to MCU?

  • SergeySergey Dublin, Ireland

    What do you mean by send files from ESP8266 to MCU ? ESP8266 is an MCU.
    Do you mean, another MCU connected to ESP8266 via some interface, e.g. UART or I2C?
    If so, the answer is yes. How ? Just use e.g. UART API to send data, and read it on the other side.

  • liuliu china

    @Sergey thank you , "send files from ESP8266 to MCU" mean that is another MCU connected to ESP8266 via some interface.
    Can you give me a UART instance about ESP8266? Thank you very much for your guidance! happy weekend! :)

  • imranimmu133imranimmu133 Coimbatore

    I need to send a code from Arduino by Arduino IDE code. So what code does i need to upload in Mongoose OS(ESP8266)? is it compatible? is it receive it?

Sign In or Register to comment.