-
Notifications
You must be signed in to change notification settings - Fork 67
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
bluetooth mapper #13
bluetooth mapper #13
Conversation
Welcome @ttlv! It looks like this is your first PR to kubeedge/mappers-go 🎉 |
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.
Do we need to delete the old version of bluetooth mapper?
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.
Many thanks for making this change. It's OK overall but some minor comments.
pkg/ble/device/twindata.go
Outdated
// If this Characteristic suports notifications and there's a CCCD | ||
// Then subscribe to it | ||
if (c.Property&ble.CharNotify) != 0 && c.CCCD != nil { | ||
if err := td.BluetoothClient.Client.Subscribe(c, false, td.notificationHandler()); err != nil { |
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.
Not clear why there's a subscription. This function will be called periodically. If the period is small, then there will be lots of subscribing and publishing.
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.
well,because bluetooth support two method to fetch data,one is read and another is notify,thers is no clearly defination in crd,so I don't know it's read or notify.
pkg/ble/device/twindata.go
Outdated
c := u.(*ble.Characteristic) | ||
// read data actively | ||
if (c.Property & ble.CharRead) != 0 { | ||
b, err := td.BluetoothClient.Client.ReadCharacteristic(c) |
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.
It's better to pack it to a read function that aligned with write.
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.
/lgtm, it had been fixed
pkg/ble/device/twindata.go
Outdated
|
||
// Run timer function. | ||
func (td *TwinData) Run() { | ||
uuid := ble.MustParse(td.BluetoothVisitorConfig.CharacteristicUUID) |
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.
It's better to move the repeated finding out of the function "Run" to the function "initTwin /Data".
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.
/lgtm, it had been fixed
pkg/ble/device/twindata.go
Outdated
} | ||
|
||
// ConvertReadData is the function responsible to convert the data read from the device into meaningful data | ||
// If currently logic of Convert data is not suitbale for your deive,you can change ConvertReadData function manually |
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.
space after ",", and "." at the end.
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.
/lgtm, it had been fixed
Yeap,the code of old version of bluetooth mapper is diffiult to read and what's more it can not run,so I suggest that it's better to delete.
thanks for your review |
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 refinement.
I'm confused about the ble & bluetooth. I thought if the mapper is for Bluetooth low energy device, then unify the function & variable name to "ble". Otherwise, unify them to bl/bluetooth.
pkg/ble/Makefile
Outdated
SHELL = /bin/bash | ||
|
||
build: | ||
@GOOS=linux CGO_ENABLED=0 GOARCH=arm go build -o ble-go |
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 arm platform should be notified to the user.
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.
/lgtm, it had been fixed
pkg/ble/configmap/type.go
Outdated
|
||
package configmap | ||
|
||
// ModbusVisitorConfig is the modbus register configuration. |
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.
Refine 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.
/lgtm, it had been fixed
pkg/ble/configmap/type.go
Outdated
@@ -0,0 +1,41 @@ | |||
/* | |||
Copyright 2020 The KubeEdge Authors. |
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.
Refine the year. Same about other files.
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.
/lgtm, it had been fixed
pkg/ble/device/device.go
Outdated
} | ||
} | ||
|
||
// initModbus initialize modbus client |
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.
Remove all "modbus".
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.
/lgtm, it had been fixed
} | ||
timer := mappercommon.Timer{Function: twinData.Run, Duration: collectCycle, Times: 0} | ||
// If this Characteristic suports notifications and there's a CCCD | ||
// Then subscribe to it, the notifications operation is different from reading operation, notifications will keep looping when connected |
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.
Correct the capital and small letter.
imer->timer
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.
/lgtm, it had been fixed
@@ -0,0 +1,66 @@ | |||
package driver |
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.
Copyright.
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.
/lgtm, it had been fixed
pkg/ble/driver/client.go
Outdated
Addr string | ||
} | ||
|
||
// OPCUAClient is the client structure. |
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.
BluetoothClient
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.
/lgtm, it had been fixed
In fact, Bluetooth(BT) and BLE are different and the old mapper for bluetooth just for ble.ble includes GATT,ATT HCI and so on, BLE is used mostly in IOT devices because of low energy.so we should name it as BLE and not as bluetooth。WDYT @fisherxu @sailorvii |
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.
Address the remaining issue and pass. /approve.
BTW, please merge the commits.
|
||
package configmap | ||
|
||
// BLEVisitorConfig is the BLE register configuration. |
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.
Refine the name.
} | ||
} | ||
|
||
// initBLE initialize ble client |
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.
Refine the function name either comment or function.
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sailorvii The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@ttlv @sailorvii Thanks for the great work! And it's best to add |
it's the refactor version of bluetooth mapper