Conversation
| ``` | ||
|
|
||
| 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. |
There was a problem hiding this comment.
Thanks for the fix. Some little questions, why do we need change the device-model name? and what's the hcitool?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
|
@majoyz: PR needs rebase. DetailsInstructions 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. |
I tried the CC2650 demo these days and add some details.