tinygo-org / drivers

TinyGo drivers for sensors, displays, wireless adaptors, and other devices that use I2C, SPI, GPIO, ADC, and UART interfaces.
https://tinygo.org
BSD 3-Clause "New" or "Revised" License
585 stars 180 forks source link

LoRa WAN US915 Support #603

Closed mirackara closed 8 months ago

mirackara commented 9 months ago

Adds a driver for us 915 protocol to the lora WAN drivers.

iamemilio commented 9 months ago

https://github.com/mirackara/drivers/pull/1

iamemilio commented 9 months ago

@deadprogram should be good to go now, sorry I didn't get to test it. I got food poisoning 💀

iamemilio commented 9 months ago

Note that because this re-structures the implementation of this driver, it will be breaking for https://github.com/tinygo-org/drivers/pull/535

deadprogram commented 9 months ago

Here is an example where changing to Channel interface using functions instead of struct with values is a problem: https://github.com/hybridgroup/tinyglobo/blob/main/main.go#L25-L28

deadprogram commented 9 months ago

The most straightforward solution to the TinyGlobo example within how this PR works, would be to provide SetXXX() functions for each of the values.

Example:

func (c *ChannelAU) SetFrequency(freq uint32)  error { 
    c.frequency = freq
    return nil
}

There is some duplication of code, but it would allow for validation to be added at some point.

What do you think @mirackara @iamemilio ?

iamemilio commented 8 months ago

I like that. It feels like a much safer way to handle this data structure.

deadprogram commented 8 months ago

@iamemilio can you add to this PR please? :smile_cat:

deadprogram commented 8 months ago

Forgot to mention that I tested this in EU868 and it still works. As long as the US915 region is working, then I suggest we merge and then can do some additional refactoring from there.

deadprogram commented 8 months ago

Commits picked up in #611 so now closing this PR. Thank you very much everyone!