-
Notifications
You must be signed in to change notification settings - Fork 171
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more details for CC2650 demo #49
base: master
Are you sure you want to change the base?
Conversation
@@ -59,9 +59,15 @@ This section contains instructions on how to make use of bluetooth mapper of Kub | |||
git clone https://github.com/kubeedge/examples.git $GOPATH/src/github.com/kubeedge/examples | |||
``` | |||
|
|||
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.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
@majoyz: PR needs rebase. 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. |
I tried the CC2650 demo these days and add some details.