Skip to content

Commit

Permalink
fix: resolved the all of the latest comments made by Anthony
Browse files Browse the repository at this point in the history
Signed-off-by: Marc-philippe Fuller <marc-philippe.fuller@intel.com>
  • Loading branch information
marcpfuller committed Jan 5, 2022
1 parent 97b43de commit 07c5e43
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,6 @@ This service has the functionality to probe the local network in an effort to di
This discovery also happens at a regular interval and can be configured via [EdgeX Consul][consul_discovery]
for existing installations, and [configuration.toml][config_toml] for default values.

> consul_discovery: http://localhost:8500/ui/dc1/kv/edgex/devices/2.0/device-rfid-llrp/Device/Discovery/
>

The additional discovery configuration can be modified via the `[AppCustom]` section of the [configuration.toml][config_toml] file.

>_**Note:** Please read the [Notes on configuration.toml](#Notes-on-configurationtoml) for things to be
Expand Down Expand Up @@ -197,6 +194,7 @@ aware of when modifying this file._
[provision_watcher]: cmd/res/provision_watchers
[impinj_watcher]: cmd/res/provision_watchers/impinj.provision.watcher.json
[generic_watcher]: cmd/res/provision_watchers/llrp.provision.watcher.json
[consul_discovery]: http://localhost:8500/ui/dc1/kv/edgex/devices/2.0/device-rfid-llrp/Device/Discovery/
## Device Profiles, Custom LLRP Messages, and Service Limitations
For some use cases, you may want or need to supply your own `deviceProfile`,
Expand Down
1 change: 0 additions & 1 deletion cmd/res/profiles/llrp.impinj.profile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,3 @@ deviceCommands:
resourceOperations:
- { deviceResource: "AccessSpecID" }
- { deviceResource: "Action", defaultValue: "Delete" }

20 changes: 10 additions & 10 deletions internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (d *Driver) Initialize(lc logger.LoggingClient, asyncCh chan<- *dsModels.As
if err != nil {
d.lc.Error("Unsupported protocol mapping.",
"error", err,
"protocols", fmt.Sprintf("%+v", device.Protocols),
"protocols", fmt.Sprintf("%v", device.Protocols),
"deviceName", device.Name)
continue
}
Expand All @@ -198,15 +198,15 @@ func (d *Driver) updateWritableConfig(rawWritableConfig interface{}) {
d.configMu.Unlock()

if updated.DiscoverySubnets != oldSubnets || updated.ScanPort != oldScanPort {
d.lc.Info("discover configuration has changed! Discovery will be triggered momentarily.")
d.lc.Info("Discover configuration has changed! Discovery will be triggered momentarily.")
d.debouncedDiscover()
}
}

// HandleReadCommands triggers a protocol Read operation for the specified device.
func (d *Driver) HandleReadCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest) ([]*dsModels.CommandValue, error) {
d.lc.Debug(fmt.Sprintf("LLRP-Driver.HandleReadCommands: "+
"device: %s protocols: %+v reqs: %+v", devName, p, reqs))
"device: %s protocols: %v reqs: %+v", devName, p, reqs))

results, err := d.handleReadCommands(devName, p, reqs)
if err != nil {
Expand Down Expand Up @@ -275,7 +275,7 @@ func (d *Driver) handleReadCommands(devName string, p protocolMap, reqs []dsMode
// command.
func (d *Driver) HandleWriteCommands(devName string, p protocolMap, reqs []dsModels.CommandRequest, params []*dsModels.CommandValue) error {
d.lc.Debug(fmt.Sprintf("LLRP-Driver.HandleWriteCommands: "+
"device: %s protocols: %+v reqs: %+v", devName, p, reqs))
"device: %s protocols: %v reqs: %+v", devName, p, reqs))

// kinda surprised EdgeX doesn't do this automatically.
err := d.handleWriteCommands(devName, p, reqs, params)
Expand Down Expand Up @@ -569,7 +569,7 @@ func (d *Driver) Stop(force bool) error {
// associated with this Device Service is added,
// so this assumes the device is already registered with EdgeX.
func (d *Driver) AddDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) error {
d.lc.Debug(fmt.Sprintf("Adding new device: %s protocols: %+v adminState: %+v",
d.lc.Debug(fmt.Sprintf("Adding new device: %s protocols: %v adminState: %+v",
deviceName, protocols, adminState))
_, _, err := d.getDevice(deviceName, protocols)
if err != nil {
Expand All @@ -588,13 +588,13 @@ func (d *Driver) AddDevice(deviceName string, protocols protocolMap, adminState
// update the address, and attempt to reconnect at the new address and port.
// If the address is the same, nothing happens.
func (d *Driver) UpdateDevice(deviceName string, protocols protocolMap, adminState contract.AdminState) (err error) {
d.lc.Debug(fmt.Sprintf("Updating device: %s protocols: %+v adminState: %+v",
d.lc.Debug(fmt.Sprintf("Updating device: %s protocols: %v adminState: %v",
deviceName, protocols, adminState))
defer func() {
if err != nil {
d.lc.Error("Failed to update device.",
"error", err, "deviceName", deviceName,
"protocolMap", fmt.Sprintf("%+v", protocols))
"protocolMap", fmt.Sprintf("%v", protocols))
}
}()

Expand Down Expand Up @@ -623,7 +623,7 @@ func (d *Driver) UpdateDevice(deviceName string, protocols protocolMap, adminSta
// RemoveDevice is a callback function that is invoked
// when a Device associated with this Device Service is removed
func (d *Driver) RemoveDevice(deviceName string, p protocolMap) error {
d.lc.Debug(fmt.Sprintf("Removing device: %s protocols: %+v", deviceName, p))
d.lc.Debug(fmt.Sprintf("Removing device: %s protocols: %v", deviceName, p))

ctx, cancel := context.WithTimeout(context.Background(), shutdownGrace)
defer cancel()
Expand Down Expand Up @@ -772,7 +772,7 @@ func (d *Driver) addProvisionWatchers() error {
// Every subsequent call to this function before that timer elapses resets the timer to
// discoverDebounceDuration. Once the timer finally elapses, the Discover function is called.
func (d *Driver) debouncedDiscover() {
d.lc.Debug(fmt.Sprintf("trigger debounced discovery in %+v", discoverDebounceDuration))
d.lc.Debug(fmt.Sprintf("trigger debounced discovery in %v", discoverDebounceDuration))

// everything in this function is mutex-locked and is safe to access asynchronously
d.debounceMu.Lock()
Expand Down Expand Up @@ -854,7 +854,7 @@ func (d *Driver) discover(ctx context.Context) {
d.lc.Warn("Discover process has been cancelled!", "ctxErr", ctx.Err())
}

d.lc.Info(fmt.Sprintf("Discovered %d new devices in %+v.", len(result), time.Now().Sub(t1)))
d.lc.Info(fmt.Sprintf("Discovered %d new devices in %v.", len(result), time.Now().Sub(t1)))
// pass the discovered devices to the EdgeX SDK to be passed through to the provision watchers
d.deviceCh <- result
}

0 comments on commit 07c5e43

Please sign in to comment.