gasagna / A76XX

Arduino library for the A76XX family of SIMCOM cellular modules, with native MQTT(S), HTTP(S), etc, clients!
MIT License
8 stars 3 forks source link

issue with mosquitto.pem in example MqttEncryptedUnauthenticated.ino #6

Closed aquila1968 closed 2 months ago

aquila1968 commented 2 months ago

Hi David,

I was testing with a SIM7600E-H,4G LTE cat 4 modem and found an issue in the MqttEncryptedUnauthenticated.ino example.

In the example the name of the Mosquito CA Cert is defined as: #define MOSQUITTO_CA_CERTNAME "mosquitto.pem"

It took quite some time to find the reason why the example did not work.

The command to set the server root CA of the first SSL context should be: AT+CSSLCFG=”cacert”,0,”mosquitto.pem”

But when you use the example the command send to the module was: AT+CSSLCFG=”cacert”,0,mosquitto.pem And it does not produce an error! Just a normal "OK"

So whithout quotes.

When changing the setCert command in the code to: if (mqtt.setCaCert("\"mosquitto.pem\"") == false) solves the problem. Just simply escaping the quotes.

I test only the MQTT related examples and the SaveCertificates example but it all looks good until now.

I will test with a SIM7670G as well.

I was surprised as well about the performance of the SIM7600E-H,4G LTE cat 4. It seems very useful for my project were I have burst of event data (10 hz).

Do you have any plans on extending the library? i.e. with GNSS?

Thanks for your excellent work and kind regards,

Adriaan

gasagna commented 2 months ago

Hi Adriaan,

I think the fix is easy, just adding extra quotes in configSSLCacert should work.

Can you check if updating the function configSSLCacert like so

    // CSSLCFG cacert
    int8_t configSSLCacert(uint8_t ssl_ctx_index, const char* ca_file) {
        _serial.sendCMD("AT+CSSLCFG=\"cacert\",", ssl_ctx_index, ",\"", ca_file, "\"");
        A76XX_RESPONSE_PROCESS(_serial.waitResponse());
    }

does the job? if so, I will accept a pull request.

For the GNSS functionality, i so have implemented most of things, and I have an unpublished branch that does pretty much what's needed. I need to get back to it, but i have struggled to get good gps signal on my devices in my flat, so I have not been able to test stuff well enough. I could push the branch to github and set the GPS feature to be "experimental" for people to try it out.

aquila1968 commented 2 months ago

Yes that would be a valid solution. I will test it tomorrow and let you know. If there is a way I would like to test the GNSS functionality and provide you feedback.

gasagna commented 2 months ago

OK thanks.

I will push the GNSS branch and let you know, so you can test a couple of sketches i have.

gasagna commented 2 months ago

closed by #7

gasagna commented 1 month ago

Hi @aquila1968, the new branch "gnss" is ready for you to look at. You could start with the GNSS example sketch.

There are also some other changes, including less String allocations, that is have made, so I would appreciate a lot if you also tested the branch with other examples, or with your own code.

Many thanks!