Question about HTTPS support Freematics ONE+ Model B

Discussion about software developed by Freematics, including Freematics Builder and Freematics Emulator GUI
Post Reply
ipindado
Posts: 6
Joined: Tue Aug 08, 2023 6:43 am

Question about HTTPS support Freematics ONE+ Model B

Post by ipindado »

Hi...

I've recently started to develop with a Freematics ONE+ Model B and Freematics OBD-II Emulator.

I have started with telelogger sketch and I was able to build the project and to upload it to the device, start monitor, etc, but for some reason I am not able to send data to the server.

I've tried both GET and POST methods with our testbed which is running on cloud over HTTPS...

I changed config settings to match our server configuration (host, method,...) and updated the client to match the server path, but I am getting a

"No HTTP Response error"

Is it HTTPS protocol supported? Is it required to perform some kind of additional settings?

Code: Select all

CPU:160MHz FLASH:16MB
IRAM:342KB
DEVICE ID:UCFLVA28
TYPE:14
MEMS:ICM-42627
ACC BIAS:-0.17/-0.07/-0.97
GNSS:OK
OBD:NO
[ 10335][E][sd_diskio.cpp:802] sdcard_mount(): f_mount failed: (13) There is no valid FAT volume
NO SD CARD
[CELL] Activating...
CELL:SIM7070G
IMEI:65456053720601
[CELL] Searching...
APN:orangeworld
Operator:simyo
[CELL] IP:10.46.70.34
[BUF] 3 samples | 30 bytes | 1/32
LOGIN(xxx.xxx.xxx:443)...
[BUF] 9 samples | 90 bytes | 3/32
[CELL] In service
RSSI:-81dBm
0:18982,24:374,20:0;0;0,82:45*E7
[BUF] 13 samples | 128 bytes | 4/32
No HTTP response
....
[CELL] Activating...
[BUF] 66 samples | 648 bytes | 20/32
CELL:SIM7070G
IMEI:65456053720601
[CELL] Searching...
APN:orangeworld
Operator:simyo
[CELL] IP:10.53.112.41
[BUF] 3 samples | 30 bytes | 1/32
LOGIN(xxx.xxx.xxx:443)...
[BUF] 9 samples | 90 bytes | 3/32
[CELL] In service
RSSI:-81dBm
0:16982,24:380,20:-0.41;0.69;-0.22,82:45*FE
[BUF] 13 samples | 128 bytes | 4/32
No HTTP response
Timeouts: OBD:0 Network:1
0:25631,24:380,20:-0.18;0.06;-0.39,82:45*F8
[BUF] 16 samples | 158 bytes | 5/32
No HTTP response
Timeouts: OBD:0 Network:2
[BUF] 22 samples | 218 bytes | 7/32
RSSI:-79dBm
0:34280,24:374,20:-0.55;0.57;-0.31,82:45*FA
[BUF] 26 samples | 256 bytes | 8/32
Thanks and best regards.
ipindado
Posts: 6
Joined: Tue Aug 08, 2023 6:43 am

Re: Question about HTTPS support Freematics ONE+ Model B

Post by ipindado »

I reply myself...

So considering the telelogger demo it seems that although the config supports HTTPS configuration, when setting the protocol and the port, the actual library FreematicsNetwork.cpp does not initialize correctly the SIM7070 component when opening the connection.... It sends a regular HTTP request to the HTTPS port...

Just for the records, this works for me...

Here....

Code: Select all

bool CellHTTP::open(const char* host, uint16_t port)
{
  if (m_type == CELL_SIM7070) {
    sendCommand("AT+CNACT=0,1\r");
    sendCommand("AT+CACID=0\r");

    sprintf(m_buffer, "AT+SHCONF=\"URL\",\"http://%s:%u\"\r", host, port);
    if (!sendCommand(m_buffer)) {
      return false;
    }
    sendCommand("AT+SHCONF=\"HEADERLEN\",256\r");
    sendCommand("AT+SHCONF=\"BODYLEN\",1024\r");
    sendCommand("AT+SHCONN\r", HTTP_CONN_TIMEOUT);
    ...
I updated the code for the SSL initialization of the SIM7070 module.

Code: Select all

bool CellHTTP::open(const char* host, uint16_t port)
{
  if (m_type == CELL_SIM7070) {    
    sendCommand("AT+CNACT=0,1\r");
    sendCommand("AT+CACID=0\r");
    const char *protocol = (port == 443) ? "https" : "http"; // Technically it can be other port number so another param should be required in the method for the protocol
    if (port == 443) {      
      sendCommand("AT+SHSSL=1,\"\"\r");    // This setting makes the client to trust in the server certificate
      sendCommand("AT+CSSLCFG=\"ignorertctime\",1,1\r");    
      sendCommand("AT+CSSLCFG=\"SSLVERSION\",1,3\r");
      char comandSNI[100];
      sprintf(comandSNI, "AT+CSSLCFG=\"sni\",1,\"%s\"\r", host);
      sendCommand(comandSNI);
    }
    sprintf(m_buffer, "AT+SHCONF=\"URL\",\"%s://%s:%d\"\r", protocol, host, port); // URL should include the protocol based on the settings
I made it dependant of the port number just for testing purposes, but it can be improved...

I took as reference: https://gist.github.com/baconcheese113/ ... 6fa031aed2 for the modem initialization.

Best regards..
stanley
Site Admin
Posts: 1039
Joined: Sat Mar 01, 2014 3:15 am

Re: Question about HTTPS support Freematics ONE+ Model B

Post by stanley »

Thanks for sharing this. I will include this code snippet in the code base if you don't mind.
ipindado
Posts: 6
Joined: Tue Aug 08, 2023 6:43 am

Re: Question about HTTPS support Freematics ONE+ Model B

Post by ipindado »

sure...
cuhnkedrik
Posts: 1
Joined: Fri Oct 20, 2023 12:19 pm

Re: Question about HTTPS support Freematics ONE+ Model B

Post by cuhnkedrik »

Your contribution is greatly appreciated. With your permission, I'd like to add this line of code to the repository.
demurejunkie
Posts: 2
Joined: Fri May 03, 2024 12:12 pm

Re: Question about HTTPS support Freematics ONE+ Model B

Post by demurejunkie »

cuhnkedrik wrote: Fri Oct 20, 2023 12:20 pm Your contribution is greatly appreciated. With your permission, I'd like to addcoreball this line of code to the repository.
I found this line of code in the repository. Thank you for saving.
Post Reply