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
599 stars 188 forks source link

Want to change the wifi example from const to var. #455

Closed sago35 closed 1 year ago

sago35 commented 2 years ago

The current code is as follows

// access point info
const ssid = ""
const password = ""

SSID settings, etc., require direct modification of the code. Changing directly increases the possibility of accidental git push.

So I suggest that it be the following The following form can be rewritten by adding another file.

It can also be rewritten using ldflags. (tinygo flash -target wioterminal -ldflags '-X "main.ssid=YOUR_SSID"')

// You can override the setting with the init() in another source code.
// func init() {
//    ssid = "your-ssid"
//    password = "your-password"
// }

var (
    // access point info
    ssid string
    pass string
)

So, I would like to rewrite examples. What do you think?

sago35 commented 2 years ago
$ git grep -i "const ssid"
examples/espat/espconsole/main.go:23:const ssid = "YOURSSID"
examples/espat/esphub/main.go:21:const ssid = "YOURSSID"
examples/espat/espstation/main.go:18:const ssid = "YOURSSID"
examples/espat/mqttclient/main.go:24:const ssid = "YOURSSID"
examples/espat/mqttsub/main.go:25:const ssid = "YOURSSID"
examples/espat/tcpclient/main.go:18:const ssid = "YOURSSID"
examples/wifinina/connect/main.go:13:const ssid = ""
examples/wifinina/http-get/main.go:28:const ssid = ""
examples/wifinina/mqttclient/main.go:25:const ssid = ""
examples/wifinina/mqttsub/main.go:25:const ssid = ""
examples/wifinina/ntpclient/main.go:18:const ssid = ""
examples/wifinina/tcpclient/main.go:21:const ssid = ""
examples/wifinina/tlsclient/main.go:22:const ssid = ""
examples/wifinina/udpstation/main.go:19:const ssid = ""
examples/wifinina/webclient/main.go:19:const ssid = ""
deadprogram commented 1 year ago

Very good idea!

aykevl commented 1 year ago

Seems like a good idea!

deadprogram commented 1 year ago

This has now been released, so closing. Thank you!