Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetupFOTA ¶
func SetupFOTA(config Parameters, receiver *apn.RxTxReceiver, datastore storage.DataStore, firmwareStore storage.FirmwareImageStore) error
SetupFOTA sets up the simple FOTA endpoint
Types ¶
type LwM2MHandler ¶
type LwM2MHandler struct {
// contains filtered or unexported fields
}
LwM2MHandler takes care of all the nitty gritty bits wrt LwM2M registration and clients.
func NewLwM2MHandler ¶
func NewLwM2MHandler(coapServer *apn.RxTxReceiver, store storage.DataStore, config Parameters) *LwM2MHandler
NewLwM2MHandler creates a new LwM2M server. The server itselfs piggybacks on top of an existing CoAP server
func (*LwM2MHandler) RegistrationHandler ¶
func (s *LwM2MHandler) RegistrationHandler() apn.CoAPHandler
RegistrationHandler is the registration handler for the LwM2M FOTA process. When a device registers the version is checked by querying the /3/0 resource. If the device has an outdated version the /5/0/1 resource is set to point to the firmware download endpoint and the state of the device download is observed. Once completed a reboot command is issued to the device.
type Parameters ¶
type Parameters struct {
// FirmwareEndpoint is the endpoint for the firmware resource. This is used
// both by the LwM2M FOTA and the simple FOTA processes.
FirmwareEndpoint string `param:"desc=CoAP firmware endpoint;default=coap://172.16.15.14:5683/fw"`
//LWM2MTimeout is the timeout for LwM2M requests. It is set quite high since
// the devices can be slow to respond. The network latency can be as high
// as 5 seconds.
LWM2MTimeout time.Duration `param:"desc=LwM2M request timeout;default=30s"`
// DownloadTmeout is the timeout for a firmware download.
// 30 minutes is a rough guess (it was 5 but it's way to short, downloading
// an image for nRf91 took 14 minutes. 30 minutes might be more like it)
// This is radically different from regular
// CoAP responses towards the devices since they are writing to flash
// and will generally be very busy at this point.
// N2 offloads is *really* slow and might be upwards of 30-40 minutes.
// Bumping to 1h.
DownloadTimeout time.Duration `param:"desc=Firmware download timeout;default=60m"`
// LWM2MPollInterval is the polling interval for the firmware state during
// the download. The default is 30s which is about the regular observe
// intervals found in Zephyr. Decrease to speed up checks (but more polling
// uses more power), lower to make the checks slower. A download over a
// slow NB-IoT link might be 4800bps or less, depending on the configuration
// of the module. uBlox N2 uses a 9600 baud UART to send and receive data
// and the data is encoded as hex digits which makes the link act like a
// 2400 baud modem. Fortunately this link is quicker for nRF91 (more like
// a few hundred kbps but a firmware download can still be measured in minutes
// not seconds.)
LWM2MPollInterval time.Duration `param:"desc=Polling interval for firmware state during download;default=30s"`
}
Parameters is the config parameters for the FOTA endpoints. This includes both LwM2M and simple FOTA.
func (*Parameters) GetFirmwareHostPortPath ¶
func (p *Parameters) GetFirmwareHostPortPath() (string, int, string, error)
GetFirmwareHostPortPath splits the firmware endpoint into its separate components
type Report ¶
type Report struct {
FirmwareVersion string
ManufacturerName string
SerialNumber string
ModelNumber string
}
Report is the request body of the simple FOTA procedure
func (*Report) UnmarshalBinary ¶
UnmarshalBinary decodes a report payload.
type SimpleFOTAResponse ¶
SimpleFOTAResponse is the response for the simple FOTA procedure. It is sent to the device as a response to the client. The host, port and path is sent as separate fields just to make it simpler to decode. The path is separated by slashes.
func (*SimpleFOTAResponse) MarshalBinary ¶
func (r *SimpleFOTAResponse) MarshalBinary() ([]byte, error)
MarshalBinary encodes the response into a byte buffer that is sent to the client. The content is TLV encoded.