mcumgrsvc

package module
v0.0.0-...-14c9496 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 31 Imported by: 0

README

MCU Management Service
######################

Overview
########
``mcumgr-svc`` implements a `go-kit <https://github.com/go-kit/kit>`_ based microservice which
prvoides RESTful APIs to conduct firmware update of MCU over the serial port. The frontend of
the service is a `Hawkbit <https://www.eclipse.org/hawkbit/>`_ compliant FOTA client which
polls and launches FOTA processes by RESTful APIs a ``Hawkbit FOTA Server`` offers to retrive
an FOTA deployment. The serial backend of the service has ``upload`` and ``reset`` methods of
`mcumgr <https://github.com/apache/mynewt-mcumgr>`_ implemented to update a serial connected
device which runs `mcuboot <https://github.com/jonathanyhliang/mcuboot>`_ bootloader in serial
recovery mode, and make the device boot into application code once the update was successful.

Building and Running
####################

The primary use of ``mcumgr-svc`` is run with `hawkbit-svc <https://github.com/jonathanyhliang/hawkbit-fota>`_
and `slcan-svc <https://github.com/jonathanyhliang/slcan-svc>`_. Refer to
`demo-svc <https://github.com/jonathanyhliang/demo-svc>`_ for the full picture of how things work.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBackendPortOpen  = errors.New("Backend: port open error")
	ErrBackendPortClose = errors.New("Backend: port close error")
	ErrBackendPortFlush = errors.New("Backend: port flush error")
	ErrBackendPort      = errors.New("Backend: invalid port setting")
	ErrBackendImage     = errors.New("Backend: invalid image")
	ErrBackendReset     = errors.New("Backend: failed to reset")
)

Functions

This section is empty.

Types

type Backend

type Backend interface {
	Handler(port string, baud int, url string) error
	UploadImage(f []byte) error
	Reset()
	GetStatus() (exec, result string)
}

func NewMCUMgrBackend

func NewMCUMgrBackend() Backend

type Endpoints

type Endpoints struct {
	GetControllerEndpoint          endpoint.Endpoint
	PutConfigDataEndpoint          endpoint.Endpoint
	GetDeployBaseEndpoint          endpoint.Endpoint
	PostDeployBaseFeedbackEndpoint endpoint.Endpoint
	GetDownloadHttpEndpoint        endpoint.Endpoint
}

func (Endpoints) GetController

func (e Endpoints) GetController(ctx context.Context, bid string) (hawkbit.Controller, error)

func (Endpoints) GetDeployBase

func (e Endpoints) GetDeployBase(ctx context.Context, bid, acid string) (hawkbit.DeploymentBase, error)

func (Endpoints) GetDownloadHttp

func (e Endpoints) GetDownloadHttp(ctx context.Context, bid, ver string) []byte

func (Endpoints) PostDeployBaseFeedback

func (e Endpoints) PostDeployBaseFeedback(ctx context.Context, bid string, fb hawkbit.DeploymentBaseFeedback) error

func (Endpoints) PutConfigData

func (e Endpoints) PutConfigData(ctx context.Context, bid string, cfg hawkbit.ConfigData) error

type IService

type IService interface {
	GetController(ctx context.Context, bid string) (hawkbit.Controller, error)
	PutConfigData(ctx context.Context, bid string, cfg hawkbit.ConfigData) error
	GetDeployBase(ctx context.Context, bid, acid string) (hawkbit.DeploymentBase, error)
	PostDeployBaseFeedback(ctx context.Context, bid string, fb hawkbit.DeploymentBaseFeedback) error
	GetDownloadHttp(ctx context.Context, bid, ver string) []byte
}

func NewHTTPClient

func NewHTTPClient(instance string, otTracer stdopentracing.Tracer, logger log.Logger) (IService, error)

NewHTTPClient returns an AddService backed by an HTTP server living at the remote instance. We expect instance to come from a service discovery system, so likely of the form "host:port". We bake-in certain middlewares, implementing the client library pattern.

type Middleware

type Middleware func(IService) IService

Middleware describes a service (as opposed to endpoint) middleware.

func LoggingMiddleware

func LoggingMiddleware(logger log.Logger) Middleware

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL