Skip to content

Conversation

@majoyz
Copy link

@majoyz majoyz commented Jun 11, 2020

I tried the CC2650 demo these days and add some details.

```

3. Create the CC2650 SensorTag device model and device instance.
3. Create the CC2650 SensorTag device model and device instance. Please change the device model name "CC2650-sensortag" to the name your node get. You can use `hcitool lescan` to get the name.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Some little questions, why do we need change the device-model name? and what's the hcitool?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. Some little questions, why do we need change the device-model name? and what's the hcitool?

The hcitool is a bluetooth tool on Linux, hcitool lescan can get the low energy bluetooth devices around the node and their name. It might has a length limit on some Linux version, on my node, the name is cut to "CC2650 Sen". The bluetooth mapper identify a device by this name.

Copy link
Author

@majoyz majoyz Jun 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code to get the name is here:

func (b *BLEConfig) Load() error {
	readConfigFile := ReadConfigFile{}
	readConfigMap := DeviceProfile{}
	err := readConfigFile.ReadFromConfigFile()
	if err != nil {
		return errors.New("Error while reading from configuration file " + err.Error())
	}
	err = readConfigMap.ReadFromConfigMap()
	if err != nil {
		return errors.New("Error while reading from config map " + err.Error())
	}
	b.Mqtt = readConfigFile.Mqtt
	b.Scheduler = readConfigFile.Scheduler
	b.Watcher = readConfigFile.Watcher
	// Assign device information obtained from config file
	for _, device := range readConfigMap.DeviceInstances {
		if strings.EqualFold(device.Model, readConfigFile.DeviceModelName) {
			b.Device.ID = device.ID
			b.Device.Name = device.Model
		}
	}

The device's name is from the device model name in the configmap.
The code to compare name is here:

func onPeripheralDiscovered(p gatt.Peripheral, a *gatt.Advertisement, rssi int) {
	if strings.EqualFold(a.LocalName, strings.Replace(deviceName, "-", " ", -1)) {
		klog.Infof("Device: %s found !!!! Stop Scanning for devices", deviceName)
		// Stop scanning once we've got the peripheral we're looking for.
		p.Device().StopScanning()
		klog.Infof("Connecting to %s", deviceName)
		p.Device().Connect(p)
	}
}

The a.LocalName is the name scaned.

@kubeedge-bot kubeedge-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 14, 2021
@kubeedge-bot
Copy link
Collaborator

@majoyz: PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants