Skip to content

Commit

Permalink
Removed 'rollover' (ref. uhppoted/uhppote-cli#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
twystd committed Dec 15, 2021
1 parent d186259 commit 3628244
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
1. Retyped UHPPOTE.BindAddress as types.BindAddr
2. Retyped UHPPOTE.BroadcastAddress as types.BroadcastAddr
3. Retyped UHPPOTE.ListenAddress as types.ListenAddr
4. Removed rollover (ref. https://github.com/uhppoted/uhppote-cli/issues/7)

### v0.7.1

Expand Down
7 changes: 3 additions & 4 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

### IN PROGRESS

- [x] Remove _rollover_
- [ ] Set first card

- [x] Retype UHPPOTE.BindAddress as types.BindAddr
- [x] Retype UHPPOTE.BroadcastAddress as types.BroadcastAddr
- [x] Retype UHPPOTE.ListenAddress as types.ListenAddr
- [ ] See if there's anything worth taking from CloudFlare blog post on UDP:
https://blog.cloudflare.com/everything-you-ever-wanted-to-know-about-udp-sockets-but-were-afraid-to-ask-part-1/

## TODO

Expand Down
13 changes: 1 addition & 12 deletions uhppote/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,15 @@ type Device struct {
Name string
DeviceID uint32
Address *net.UDPAddr
Rollover uint32
Doors []string
TimeZone *time.Location
}

func NewDevice(name string, serialNumber uint32, address *net.UDPAddr, rollover uint32, doors []string) *Device {
func NewDevice(name string, serialNumber uint32, address *net.UDPAddr, doors []string) *Device {
return &Device{
Name: name,
DeviceID: serialNumber,
Address: address,
Rollover: rollover,
Doors: doors,
TimeZone: time.Local,
}
Expand All @@ -30,7 +28,6 @@ func (d Device) Clone() Device {
Name: d.Name,
DeviceID: d.DeviceID,
Address: nil,
Rollover: d.Rollover,
Doors: make([]string, len(d.Doors)),
TimeZone: d.TimeZone,
}
Expand All @@ -55,11 +52,3 @@ func (d *Device) ID() uint32 {

return 0
}

func (d *Device) RolloverAt() uint32 {
if d != nil {
return d.Rollover
}

return 100000
}
30 changes: 12 additions & 18 deletions uhppote/uhppote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,13 @@ func TestSequentialRequests(t *testing.T) {
broadcastAddr: resolve("127.0.0.1:60000", t),
devices: map[uint32]Device{
423187757: Device{
Address: resolve("127.0.0.1:65001", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65001", t),
Doors: []string{},
},

757781324: Device{
Address: resolve("127.0.0.1:65002", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65002", t),
Doors: []string{},
},
},
driver: &udp{
Expand Down Expand Up @@ -176,15 +174,13 @@ func TestConcurrentRequestsWithUnboundPort(t *testing.T) {
broadcastAddr: bind,
devices: map[uint32]Device{
423187757: Device{
Address: resolve("127.0.0.1:65001", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65001", t),
Doors: []string{},
},

757781324: Device{
Address: resolve("127.0.0.1:65002", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65002", t),
Doors: []string{},
},
},
driver: &udp{
Expand Down Expand Up @@ -265,15 +261,13 @@ func TestConcurrentRequestsWithBoundPort(t *testing.T) {
broadcastAddr: resolve("127.0.0.1:60000", t),
devices: map[uint32]Device{
423187757: Device{
Address: resolve("127.0.0.1:65001", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65001", t),
Doors: []string{},
},

757781324: Device{
Address: resolve("127.0.0.1:65002", t),
Rollover: 100000,
Doors: []string{},
Address: resolve("127.0.0.1:65002", t),
Doors: []string{},
},
},
driver: &udp{
Expand Down

0 comments on commit 3628244

Please sign in to comment.