AmedeeBulle / pyrak811

RAK811 Python 3 library for Raspberry Pi
Apache License 2.0
49 stars 24 forks source link

Support for RAK3172 #28

Open kamran890 opened 2 years ago

kamran890 commented 2 years ago

@AmedeeBulle Thanks for this great work.

RAK811 is no longer recommended by RAK811 for new design. https://store.rakwireless.com/products/rak811-lpwan-module?variant=39942880952518

I am wondering if this lib can be enhanced to support alternate module i.e RAK3172.

RAK3172 AT commands:

https://docs.rakwireless.com/Product-Categories/WisDuo/RAK3172-Module/AT-Command-Manual/#introduction

Suggestion:

Add a common config file which can contain configuration for different AT commands based on lora modules.

E.g.

    rak811_config = {
        "RESPONSE_OK": "OK ",
        "RESPONSE_ERROR": "ERROR:",
        "RESPONSE_EVENT": "at+recv=",
        "AT_COMMAND_PREFIX": "at",
    }
    rak3172_config = {
        "RESPONSE_OK": "OK",
        "RESPONSE_ERROR": "+CME ERROR:",
        "RESPONSE_EVENT": "+EVT:",
        "AT_COMMAND_PREFIX": "AT",
    }

If you can guide me an efficient way to add this feature in the lib, I would be excited to contribute code.

Thoughts?

AmedeeBulle commented 2 years ago

I doubt it can be that simple -- my experience with the RAK modules firmware is that the behavior strongly differs from a version to another (the devil is in the details...).

I already paid the price trying to re-use components of this library when moving from the V2 to the V3 firmware, as result the V3 implementation is sub-optimal.

Although the RAK811 V3 works well, a separate implementation would have been better, in particular by recognizing the message types at lower level (in the read loop) and maybe using separate buffers (or queues)... I am reluctant to make these kind of changes in this library as it will most probably break the RAK811 V2 implementation (there are still a lot of V2 modules in the field, and firmware update is not straightforward)

(Side note: I haven't seen any RAK3172 (p)HAT yet...)

kamran890 commented 2 years ago

Alright! a separate implementation could be better.

I have tried the lib with RAK4631, by making common config file, it's working pretty well. Seems RAK4631 and RAK3172 have same AT commands. I will also test it with RAK3172.

Ref to RAK3172 HAT, I am thinking to develop it.