Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Oct 25, 2024
1 parent f9cd779 commit 3977372
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions charger/ocpp/cs.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ func (cs *CS) WithChargepointStatusByID(id string, fun func(status *core.StatusN
cs.mu.Lock()
defer cs.mu.Unlock()

state, ok := cs.cps[id]
if ok && state.status != nil {
fun(state.status)
if state, ok := cs.cps[id]; ok {
state.mu.Lock()
if state.status != nil {
fun(state.status)
}
state.mu.Unlock()
}
}

Expand Down
2 changes: 2 additions & 0 deletions charger/ocpp/cs_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ func (cs *CS) OnStatusNotification(id string, request *core.StatusNotificationRe

// cache status for future cp connection
if state, ok := cs.cps[id]; ok {
state.mu.Lock()
state.status = request
state.mu.Unlock()
}

return new(core.StatusNotificationConfirmation), nil
Expand Down

0 comments on commit 3977372

Please sign in to comment.