Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Add support for E220-900T22S(JP) Lora module#535

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
akif999 wants to merge1 commit intotinygo-org:dev
base:dev
Choose a base branch
Loading
fromakif999:e220

Conversation

@akif999
Copy link
Contributor

I added driver for E220-900T22S(JP) Lora module (UART interface).

@akif999
Copy link
ContributorAuthor

@sago35 Can you do a review?

The result of the response to the indication that you have not yet confirmed is described below.

@deadprogram
Copy link
Member

Hello@akif999 if you implement this interface, then this device should be able to work with the LoRaWAN package just like the other LoRa radios:https://github.com/tinygo-org/drivers/blob/dev/lora/radio.go

What do you think?

@akif999
Copy link
ContributorAuthor

Hello@deadprogram I get it. I think it is desirable to follow the interface you presented. So I will update my implementation.

I'm thinking of updating the implementation and moving forward with this pull request.

@deadprogram
Copy link
Member

Sounds good@akif999 please let everyone here know how we can help!

akif999 reacted with thumbs up emoji

Copy link
Contributor

@soypatsoypat left a comment

Choose a reason for hiding this comment

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

quick drive-by comments

Comment on lines +24 to +39
bytes *[]byte,
) error {
// byte [8] is read only
if len(*bytes) < E220RegisterLength-1 {
return fmt.Errorf("length of bytes must be greater than or equal to %d: got=%d", E220RegisterLength-1, (*bytes))
}
(*bytes)[0] = byte((c.ModuleAddr & 0xFF00) >> 8)
(*bytes)[1] = byte((c.ModuleAddr & 0x00FF) >> 0)
(*bytes)[2] = byte(((c.UartSerialPortRate & 0x07) << 5) | (c.AirDataRate & 0x1F))
reserved := byte(0b000)
(*bytes)[3] = byte(((c.SubPacket & 0x03) << 6) | ((c.RssiAmbient & 0x01) << 5) | ((reserved & 0x07) << 2) | (c.TransmitPower & 0x03))
(*bytes)[4] = byte(c.Channel)
reserved = byte(0b000)
(*bytes)[5] = byte(((c.RssiByte & 0x01) << 7) | ((c.TransmitMethod & 0x01) << 6) | ((reserved & 0x07) << 3) | (c.WorCycleSetting & 0x07))
(*bytes)[6] = byte((c.EncryptionKey & 0xFF00) >> 8)
(*bytes)[7] = byte((c.EncryptionKey & 0x00FF) >> 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

No need to pass in a pointer to a slice. A slice is already composed of a pointer to the underlying array. So you can change(*bytes)[0] = byte(...) to ``bytes[0] = byte(...) andparamsToBytes(bytes *[]byte)` to `paramsToBytes(bytes []byte)` and you'll get same behaviour.

Also one tends not to break function signatures with newlines in Go, especially if its a sufficiently small function signature.

akif999 reacted with thumbs up emoji
Comment on lines +24 to +31
TargetUARTBaud1200kbps = 1200
TargetUARTBaud2400kbps = 2400
TargetUARTBaud4800kbps = 4800
TargetUARTBaud9600kbps = 9600
TargetUARTBaud19200kbps = 19200
TargetUARTBaud38400kbps = 38400
TargetUARTBaud57600kbps = 57600
TargetUARTBaud115200kbps = 115200
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this add any value? It seems like a round about way to sayBaudRate1200 is equal to1200. MAybe this should be aBaud type instead and these be reduced toBaud1200.

akif999 reacted with thumbs up emoji
Comment on lines +110 to +125
switch mode {
case Mode0:
d.m1.Low()
d.m0.Low()
case Mode1:
d.m1.Low()
d.m0.High()
case Mode2:
d.m1.High()
d.m0.Low()
case Mode3:
d.m1.High()
d.m0.High()
default:
return fmt.Errorf("Invalid mode: %d", mode)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this could be reduced tod.m0.Set(mode&1 != 0); d.m1.Set((mode>>1)&1 != 0) and a error check if mode is greater than 3

akif999 reacted with thumbs up emoji
// WriteConfig writes configuration values to E220
func (d *Device) WriteConfig(cfg Config) error {

cfg.Validate()
Copy link
Contributor

Choose a reason for hiding this comment

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

Validate should return anerror type itself. check out theerrors.Join(errSlice...) function which does pretty much what you are doing below.

akif999 reacted with thumbs up emoji
@iamemilioiamemilio mentioned this pull requestSep 29, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@soypatsoypatsoypat left review comments

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@akif999@deadprogram@soypat

[8]ページ先頭

©2009-2025 Movatter.jp