Documentation ¶
Overview ¶
Package fiwarecrawlerlib provides utility functions for regularly crawling data and creating configuration groups and devices for a FIWARE IoT-Agent UL (Ultralight).
The main functionalities include configuring a crawler with scheduling, handling MQTT communication, and managing FIWARE service groups and devices. It is designed to simplify the integration of IoT devices with FIWARE IoT Agents using Ultralight protocol for data communication.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Crontab string `env:"CRONTAB,required=true"` IotAHost string `env:"IOTA_HOST,required=true"` IotAPort int `env:"IOTA_PORT,required=true"` Service string `env:"SERVICE,required=true"` ServicePath string `env:"SERVICE_PATH,required=true"` ApiKey i.Apikey `env:"API_KEY,required=true"` Resource i.Resource `env:"RESOURCE,default=/iot/d"` DeviceId i.DeciveId `env:"DEVICE_ID, required=true"` EntityType string `env:"ENTITY_TYPE, required=true"` LogLevel string `env:"LOG_LEVEL,default=DEBUG"` MqttBroker string `env:"MQTT_BROKER,default=mosquitto"` MqttPort int `env:"MQTT_PORT,default=1883"` ClientId string `env:"CLIENT_ID,required=true"` Username string `env:"USERNAME,required=false"` Password string `env:"PASSWORD,required=false"` }
Config represents the configuration parameters for the fiwarecrawlerlib package. It is populated using environment variables.
type Crawler ¶
Crawler represents the main structure for the fiwarecrawlerlib package, encapsulating the configuration, FIWARE IoT-Agent, FiwareService, and the cron scheduler.
func New ¶
func New() *Crawler
New creates a new Crawler instance and initializes it with the configuration parameters from environment variables. Return a pointer to the Crawler instance
func (*Crawler) NewConfigGroup ¶
func (c *Crawler) NewConfigGroup() *i.ConfigGroup
NewConfigGroup creates a new ConfigGroup instance based on the configuration. It returns a pointer to the newly created ConfigGroup.
func (*Crawler) NewDevice ¶
NewDevice creates a new Device instance based on the configuration. It returns a pointer to the newly created Device.
func (*Crawler) PublishMqtt ¶
PublishMqtt publishes data to an MQTT broker based on the configuration parameters. data items will be joind to a ul payload, nested struct will be parsed to json.
func (*Crawler) StartJob ¶
func (c *Crawler) StartJob(jobFunc interface{})
StartJob takes a function jobFunc, adds it to the cron scheduler and starts it blocking.
func (*Crawler) UpsertConfigGroup ¶
func (c *Crawler) UpsertConfigGroup(cg i.ConfigGroup)
UpsertConfigGroup ensures the existence of a service group in the FIWARE IoT-Agent. It takes a ConfigGroup sg as input and returns no values.
func (*Crawler) UpsertDevice ¶
UpsertDevice ensures the existence of a device in the FIWARE IoT-Agent. It takes a Device d as input and returns no values.