mirror of
https://github.com/tinygo-org/drivers.git
synced 2026-08-13 03:13:41 +00:00
espnet: WIP support for on-chip WiFi on an ESP32C3
Work in progress. Does not work yet.
Some notes:
- This requires some changes to TinyGo, look at the espnet branch.
- The next step is probably defining all the functions in
g_wifi_osi_funcs (see espnet.c). Right now it hangs in
esp_wifi_init_internal, probably a NULL pointer dereference.
- This is only for the ESP32-C3. This will require some work to work
on other chips from Espressif.
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package espnet
|
||||
|
||||
/*
|
||||
#cgo CFLAGS: -DCONFIG_IDF_TARGET_ESP32C3
|
||||
#cgo CFLAGS: -Iinclude
|
||||
#cgo CFLAGS: -Iesp-idf/components/esp_common/include
|
||||
#cgo CFLAGS: -Iesp-idf/components/esp_event/include
|
||||
#cgo CFLAGS: -Iesp-idf/components/esp_netif/include
|
||||
#cgo CFLAGS: -Iesp-idf/components/esp_wifi/include
|
||||
|
||||
#cgo LDFLAGS: -Lesp-idf/components/esp_wifi/lib/esp32c3 -lnet80211 -lpp -lphy -lmesh -lcore
|
||||
#cgo LDFLAGS: -Tesp-idf/components/esp_rom/esp32c3/ld/esp32c3.rom.ld
|
||||
|
||||
#include "esp_private/wifi.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "espnet.h"
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type ESPWiFi struct {
|
||||
}
|
||||
|
||||
var WiFi = &ESPWiFi{}
|
||||
|
||||
type Config struct {
|
||||
}
|
||||
|
||||
var internalConfig = C.wifi_init_config_t{
|
||||
osi_funcs: &C.g_wifi_osi_funcs,
|
||||
}
|
||||
|
||||
func (wifi ESPWiFi) Configure(config Config) error {
|
||||
return makeError(C.esp_wifi_init_internal(&internalConfig))
|
||||
}
|
||||
|
||||
func (wifi ESPWiFi) AccessPointMAC() ([6]byte, error) {
|
||||
var mac [6]byte
|
||||
errCode := C.esp_wifi_get_mac(C.ESP_IF_WIFI_AP, &mac[0])
|
||||
return mac, makeError(errCode)
|
||||
}
|
||||
Reference in New Issue
Block a user