These are chat archives for SmingHub/Sming

21st
Sep 2017
slaff
@slaff
Sep 21 2017 08:07
@R3cycl0r I would recommend you to continue reading our Wiki. Excerpt from there
Confirm Environment

Make sure the MinGW make.exe is the only one in the path. This will correct most "make: *** No rule to make target" problems.

# should only show one make
where make.exe
C:\Tools\mingw64\msys\1.0\bin\make.exe
R3cycl0r
@R3cycl0r
Sep 21 2017 08:37
I'm already trying to continue from the wiki but I continue to have incoherences, at the path C:\Tools\mingw64 I don't have the folder 'msys' ..? what?
Sorry man for all of this problems :\
slaff
@slaff
Sep 21 2017 08:38
Open the command prompt as Admin.
Check if you have the c:\tools folder
R3cycl0r
@R3cycl0r
Sep 21 2017 08:40
yes, till C:\Tools\mingw64 is ok
command already as admin
slaff
@slaff
Sep 21 2017 08:42
Ok. May be you will have to reinstall MingW package.
Let me check the exact package name ....
Type, as admin
choco install -y --force mingw-get
And tell me when you are ready...
slaff
@slaff
Sep 21 2017 08:49
Once you are ready make sure to delete completely the c:\tool\sming directory. And the reinstall sming with the command below:
choco install -y --force sming
R3cycl0r
@R3cycl0r
Sep 21 2017 08:50
at the end of mingw reinstall, here the log LOG
the is only 1 row in red 'Cannot find path '''C:\tools\MinGW\var\lib\mingw-get\data\defaults.xml' because it does not exist.'''
the folder msys still doesn't exist
slaff
@slaff
Sep 21 2017 08:52
Ok, remove completely the c:\tools\mingw64 directory. And then run choco install -y --force mingw-get
R3cycl0r
@R3cycl0r
Sep 21 2017 08:56

done, here the log

now still doesn't exist the whole folder mingw64

slaff
@slaff
Sep 21 2017 09:03
That is fine. Now make sure to delete completely the c:\tool\sming directory. And then reinstall sming with the command below:
choco install -y --force sming
R3cycl0r
@R3cycl0r
Sep 21 2017 09:54
Errors, 0/2 installed
cmd log
slaff
@slaff
Sep 21 2017 11:50
Downloading eclipse-cpp 64 bit
  from 'https://bintray.com/artifact/download/kireevco/generic/eclipse-cpp-luna-SR2-win32-x86_64.zip'
Progress: 1% - Saving 2 MB of 165.61 MB
Download of eclipse-cpp-luna-SR2-win32-x86_64.zip (165.61 MB) completed.
Error - hashes do not match. Actual value was 'C04DE0BE968663D5A4A0A4693DC7F597'.
ERROR: Checksum for 'C:\Users\Fabrizio & Dario\AppData\Local\Temp\chocolatey\eclipse-cpp\4.4.2.20150413\eclipse-cpp-luna-SR2-win32-x86_64.zip'
Check how big is the downloaded file (C:\Users\Fabrizio & Dario\AppData\Local\Temp\chocolatey\eclipse-cpp\4.4.2.20150413\eclipse-cpp-luna-SR2-win32-x86_64.zip )
slaff
@slaff
Sep 21 2017 12:02
@R3cycl0r I moved the dependency from the sming package to sming.examples. This way only if you install sming.examples it will require you to install Eclipse.
R3cycl0r
@R3cycl0r
Sep 21 2017 12:14
the downloaded file is 2MB
so what you suggest to do now?
bbourdel
@bbourdel
Sep 21 2017 12:57

Hello Sming community,
I've spend a whole week on this problem : how to send "big" files (beetween 200kBytes to 1MBytes) form SPIFF to an online webserver in https.
This is what I've found, where I am now and what I still have to solve to have this working successfully.

Firstly, use HTTP (unsecure) :

  • First try : Use Sming Http/TCP client to send this file in a FileStream class : that doesn't work at all : in fact, during the HTTP / TCP chain, the FileStream is totally loaded in a MemoryStream : so 1MB is loaded in RAM : -> Exception Causes (blablabla)
  • Second try : still use the Sming Http/TCP chain but change the MemoryStream by an FileStream (the FileStream need to start by the HTTP headers : POST /server.php 1.1 \r\n blablabla). Unfortunatly : doesn't work to. I don't really know why. After loaded the first thousands bytes in the TCP sending queue, the rest is never never loaded.
  • Third try : use the espconn.h library : success. I convert the file in an FileStream class, the I upload it to the server by paquet of 4096 bytes. I can even use Base64 conversion to fit internet standard ;-) Each time a paquet is sent (espconn_sent callback), I sent the next one using (espconn_send).

So i'm happy with this espconn but as I explain above, I need HTTPS (secure) connection: I still have two option:

  • Try to use the Sming Http/TCP chain + encryption : i'm afraid I can't, I already failed in unsecure connection ...
  • Try to use espconn_secure_blablabla : doesn't seem so different from what I've done above but .... I don't know how to run espconn_secure on SMING. Only unsecure API is available.

So, that's my question :

  • Has someone already tried (and succeed) in big file uplaod (from SPIFF to online server) in secure mode (or even unsecure) ? (I really search on Internet for this, but found anything)
  • Is it possible to run espconnn_secure API on SMING ? And eventually how ?

I'd love to share with you on this technical issue.
Thanks a lot,

Ben'

slaff
@slaff
Sep 21 2017 13:10

the downloaded file is 2MB

@R3cycl0r Obviously I cannot fix your Internet connection... What I did though is to move the eclipse-cpp package to be dependant on sming.examples and not on sming. So no if you upgrade sming may be you will get further
choco upgrade -y sming

Has someone already tried (and succeed) in big file uplaod (from SPIFF to online server) in secure mode (or even unsecure) ?

@bbourdel Should be possible. If you have an application with your attempts then please, share it with us and we can take a look.

bbourdel
@bbourdel
Sep 21 2017 13:42

@slaff
Here my h code : http://collabedit.com/6npr5
Here my cpp code : http://collabedit.com/9pb54

The entry function is upload(cb) that takes a callback function cb that is called when the "big" files is online.

I don't know if you have enought info ?
bbourdel
@bbourdel
Sep 21 2017 13:54
Just add few comment to explain my code.
slaff
@slaff
Sep 21 2017 14:21
@bbourdel something like this comes to my mind:
```
    HttpHeaders headers;
headers["Content-Type"]  = "application/octet-stream";

FileStream file("data.txt");

client->send(
        client->request("http://domain.com/data.txt")
        ->setMethod(HTTP_PUT)
        ->setHeaders(headers)
        ->setBody(&file)
);
```
And if you want HTTPS just change the protocol in the URL from http to https. Make sure also that you had compiled SMING with ENABLE_SSL=1
bbourdel
@bbourdel
Sep 21 2017 14:55

@slaff Thanks for you idea. But, it doesn't work. As explain bellow, the all filestream is copied in a MemoryStream (so loaded in RAM) in TCPClient.cpp function : here precisly :

bool TcpClient::send(const char* data, uint16_t len, bool forceCloseAfterSent /* = false*/)
{
    if (state != eTCS_Connecting && state != eTCS_Connected) return false;

    if (stream == NULL)
        stream = new MemoryDataStream();

    if (stream->write((const uint8_t*)data, len) != len) {
        debug_e("ERROR: Unable to store %d bytes in output stream", len);
        return false;
    }

    debugf("Storing %d bytes in stream", len);

    asyncTotalLen += len;
    asyncCloseAfterSent = forceCloseAfterSent;

    return true;
}

And in HTTPConnection.cpp : here :

bool HttpConnection::send(IDataSourceStream* inputStream, bool forceCloseAfterSent /* = false*/)
{
    if(inputStream->length() != -1) {
        // send the data as one big blob
        do {
            int len = 256;
            char data[len];
            len = inputStream->readMemoryBlock(data, len);
            TcpClient::send(data, len);
            inputStream->seek(max(len, 0));
        } while(!inputStream->isFinished());

        return true;
    }

    // Send the data in chunked-encoding

    do {
        int len = 256;
        char data[len];
        len = inputStream->readMemoryBlock(data, len);

        // send the data in chunks...
        sendString(String(len)+ "\r\n");
        TcpClient::send(data, len);
        sendString("\n\r");
        inputStream->seek(max(len, 0));
    } while(!inputStream->isFinished());

    sendString("0\r\n\r\n", forceCloseAfterSent);

    return true;
}

So as the RAM is limited to few 10KB, the program crash.

For me, the only way is to rewrite the all HTTP/TCP tunnel in Sming (I've tried, a lot, found some stuff but failed in deep tcp part), or, easilier, find a way to use espconn_secure in Sming.