-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
0c24ea7
commit 5234b47
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
// Package esp32 exists for the sole purpose of exposing the esp32 as a micro-rdk configuration in app.viam.com | ||
// The ESP32 is supported by the micro-rdk only (https://github.com/viamrobotics/micro-rdk) | ||
package esp32 | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/pkg/errors" | ||
|
||
"go.viam.com/rdk/components/board" | ||
"go.viam.com/rdk/logging" | ||
"go.viam.com/rdk/resource" | ||
) | ||
|
||
var ( | ||
espModel = resource.DefaultModelFamily.WithModel("esp32") | ||
errUnsupported = errors.New("The ESP32 board is not supported in the RDK. " + | ||
"Please use with the micro-rdk (https://github.com/viamrobotics/micro-rdk).") | ||
) | ||
|
||
type digitalInterruptConfig struct { | ||
Pin int `json:"pin"` | ||
} | ||
|
||
type analogConfig struct { | ||
Name string `json:"name"` | ||
Pin int `json:"pin"` | ||
} | ||
|
||
type i2CConfig struct { | ||
Name string `json:"name"` | ||
Bus string `json:"bus"` | ||
DataPin int `json:"data_pin,omitempty"` | ||
ClockPin int `json:"clock_pin,omitempty"` | ||
BaudRate int `json:"baudrate_hz,omitempty"` | ||
Timeout int `json:"timeout_ns,omitempty"` | ||
} | ||
|
||
// Config mirrors the config structure in (https://github.com/viamrobotics/micro-rdk/blob/main/micro-rdk/src/esp32/board.rs). | ||
type Config struct { | ||
Pins []int `json:"pins,omitempty"` | ||
DigitalInterrupts []digitalInterruptConfig `json:"digital_interrupts,omitempty"` | ||
Analogs []analogConfig `json:"analogs,omitempty"` | ||
I2Cs []i2CConfig `json:"i2cs,omitempty"` | ||
} | ||
|
||
func init() { | ||
resource.RegisterComponent( | ||
board.API, | ||
espModel, | ||
resource.Registration[board.Board, *Config]{ | ||
Constructor: newEsp32Board, | ||
}) | ||
} | ||
|
||
// Validate for esp32 will always return an unsupported error. | ||
func (conf *Config) Validate(path string) ([]string, error) { | ||
return []string{}, errUnsupported | ||
} | ||
|
||
func newEsp32Board( | ||
ctx context.Context, | ||
deps resource.Dependencies, | ||
conf resource.Config, | ||
logger logging.Logger, | ||
) (board.Board, error) { | ||
return nil, errUnsupported | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters