Skip to content
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

Merged
merged 13 commits into from
Apr 13, 2021
Merged

bluetooth mapper #13

merged 13 commits into from
Apr 13, 2021

Conversation

ttlv
Copy link
Member

@ttlv ttlv commented Apr 8, 2021

it's the refactor version of bluetooth mapper

@kubeedge-bot
Copy link
Collaborator

Welcome @ttlv! It looks like this is your first PR to kubeedge/mappers-go 🎉

@kubeedge-bot kubeedge-bot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Apr 8, 2021
@kubeedge-bot kubeedge-bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Apr 8, 2021
Copy link
Member

@fisherxu fisherxu left a 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?

Copy link
Collaborator

@sailorvii sailorvii left a 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.

// 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 {
Copy link
Collaborator

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.

Copy link
Member Author

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.

c := u.(*ble.Characteristic)
// read data actively
if (c.Property & ble.CharRead) != 0 {
b, err := td.BluetoothClient.Client.ReadCharacteristic(c)
Copy link
Collaborator

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.

Copy link
Member Author

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


// Run timer function.
func (td *TwinData) Run() {
uuid := ble.MustParse(td.BluetoothVisitorConfig.CharacteristicUUID)
Copy link
Collaborator

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".

Copy link
Member Author

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

}

// 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
Copy link
Collaborator

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.

Copy link
Member Author

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

@ttlv
Copy link
Member Author

ttlv commented Apr 8, 2021

Do we need to delete the old version of bluetooth mapper?

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.

Many thanks for making this change. It's OK overall but some minor comments.

thanks for your review

Copy link
Collaborator

@sailorvii sailorvii left a 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
Copy link
Collaborator

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.

Copy link
Member Author

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


package configmap

// ModbusVisitorConfig is the modbus register configuration.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Refine the name.

Copy link
Member Author

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,41 @@
/*
Copyright 2020 The KubeEdge Authors.
Copy link
Collaborator

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.

Copy link
Member Author

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

}
}

// initModbus initialize modbus client
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove all "modbus".

Copy link
Member Author

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
Copy link
Collaborator

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

Copy link
Member Author

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
Copy link
Collaborator

Choose a reason for hiding this comment

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

Copyright.

Copy link
Member Author

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

Addr string
}

// OPCUAClient is the client structure.
Copy link
Collaborator

Choose a reason for hiding this comment

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

BluetoothClient

Copy link
Member Author

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

@ttlv
Copy link
Member Author

ttlv commented Apr 12, 2021

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.

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

Copy link
Collaborator

@sailorvii sailorvii left a 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.
Copy link
Collaborator

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
Copy link
Collaborator

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.

@kubeedge-bot kubeedge-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 13, 2021
@kubeedge-bot
Copy link
Collaborator

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@kubeedge-bot kubeedge-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 13, 2021
@kubeedge-bot kubeedge-bot merged commit 6307a3d into kubeedge:main Apr 13, 2021
@fisherxu
Copy link
Member

@ttlv @sailorvii Thanks for the great work! And it's best to add /lgtm and /approve label after all comments are addressed. @sailorvii :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants