@lupyuen you might want to use the
x, ok := y.(type)
if !ok {
return fmt.Errorf("type assertion failed for: %v", x)
}
style of type assertions. by using the form with two return values you can prevent panics and instead return an error if you have malformed input data.
Cleaned up the CBOR Decoding ... In our #Grafana Data Source for #TheThingsNetwork
https://github.com/lupyuen/the-things-network-datasource/blob/main/pkg/plugin/message.go#L131-L189
How our #Grafana Data Source decodes CBOR Payloads from #TheThingsNetwork
https://github.com/lupyuen/the-things-network-datasource/blob/main/pkg/plugin/message.go#L100-L116
Remember that #LoRa Messages are super tiny ... We shall encode Sensor Data in CBOR ... And our #Grafana Data Source needs to decode the CBOR Payload
https://lupyuen.github.io/articles/ttn#fair-use-of-the-things-network
#Grafana Log shows our #TheThingsNetwork Data Source has extracted the Message Payload correctly yay!
https://github.com/lupyuen/the-things-network-datasource#grafana-log
Here's how our #Grafana Data Source extracts the Message Payload from #TheThingsNetwork MQTT ... Pardon my ghastly GoLang 🙏
https://github.com/lupyuen/the-things-network-datasource/blob/main/pkg/plugin/message.go#L43-L154
#TheThingsNetwork MQTT Messages are really complex ... Our #Grafana Data Source shall extract the Base64 Payload that's deep inside the message
https://github.com/lupyuen/the-things-network-datasource#mqtt-log
We'll take this brand new #Grafana Data Source for MQTT ... And mod it for the MQTT Server at #TheThingsNetwork
Why connect #Grafana to #TheThingsNetwork? So that we can instantly visualise the Sensor Data transmitted by IoT Devices
Confessions of a Michelin Guide Inspector
https://www.luxeat.com/blog/confessions-of-a-michelin-inspector/
Let's build a #Grafana Data Source for #TheThingsNetwork! (MQTT)
Here's how we transmit Sensor Data from #PineDio Stack BL604 #RISCV Board to #TheThingsNetwork, the public LoRa network
@TikToc Python's Pattern Matching looks similar to Rust: https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html
@lupyuen -- Why is this being done? It wasn't needed. One could use if-elsif-else structures or dictionaries. What language is Python being converted into?
Sorry, I'm venting here. 😞
@lupyuen Did you share this?
Circle-driven programming https://www.youtube.com/watch?v=1OcAUhe3E1E
Structural Pattern Matching in Python 3.10
IoT Techie and Educator / Apache NuttX PMC