Close

And a little further

A project log for Chirppp, Serial over LORA

Use LORA via GPIO and a full-duplex serial emulator for serial a connection intended for extended range use.

dominic-demarcoDominic DeMarco 06/29/2017 at 02:480 Comments

Worked a little more on the radio driver code today. I created the scaffolding for configuring the radio. I spent a while trying to figure out how exactly I'd do it. A true object oriented method would be an incredible amount of code and be truly tedious for the user, as it would assume the user had no access to the radio's datasheet. Everything required to use it would have to be visible in the doc generated from the rust code.

However I didn't want a hack solution either, assuming that I would be the only one using this and it'd be good enough for me.

I decided on a happy medium. I'm going to make it relatively object oriented. The actual configuration will indeed be an object itself, but to change a portion of the config I will create a function for the configuration object that will take in a literal and use pattern matching to figure out what to do.

For example, in the end the code will look something like this

let radio_config = RadioConfig::new();
RadioConfig.speed("9600");

to set the speed of the UART connection to 9600 baud, instead of knowing that they have to make bits 7,6,5 of the 4th character of the command string '001'.

This way I won't want to pull my hair out if I come back to the project a little while later, or if someone else decides to build a copy of my project when they're done.

Discussions