Skip to content

feat(cp): StatusNotification — send connector state transitions to CSMS (M4) #28

@duyhuynh-vn

Description

@duyhuynh-vn

Background

A charge point must send a StatusNotification CALL to the CSMS whenever a connector's operational state changes. This is how the CSMS tracks connector availability in real time — without it, the CSMS never knows whether connectors are available, charging, faulted, etc.

The Python reference handles this in ocpp/v16/call.py:

@dataclass
class StatusNotification:
    connector_id: int
    error_code: enums.ChargePointErrorCode
    status: enums.ChargePointStatus
    timestamp: Optional[str] = None
    info: Optional[str] = None
    vendor_id: Optional[str] = None
    vendor_error_code: Optional[str] = None

The current Rust ChargePoint never sends StatusNotification, even as connector state transitions happen inside TransactionManager. This means a connected CSMS has no visibility into connector state.

What needs to change

  1. ChargePoint::send_status_notification(connector_id, status, error_code) — sends StatusNotificationRequest via call(). Timestamp set to Utc::now().
  2. Automatic notifications on state transitionsstart_transaction() and stop_transaction() should send StatusNotification to reflect each state change:
    • Before auth: Available → Preparing
    • After StartTransactionResponse accepted: Preparing → Charging
    • After StopTransactionRequest sent: Charging → Finishing → Available
  3. On connect / after boot: send StatusNotification(connector_id=0, status=Available, error_code=NoError) for each configured connector.
  4. CSMS handler on the server side: default on_status_notification handler in OcppServer that logs the status change and emits a TransportEvent::StatusNotification { cp_id, connector_id, status }.

Acceptance criteria

  • ChargePoint::send_status_notification(connector_id: u32, status: ChargePointStatus, error_code: ChargePointErrorCode) -> OcppResult<()> implemented
  • Called automatically during transaction lifecycle:
    • start_transaction(): sends Preparing before authorize, Charging after accepted start
    • stop_transaction(): sends Finishing, then Available after stop confirmed
  • After boot accepted: sends StatusNotification(connector_id=0, status=Available, error_code=NoError) for each connector
  • ChargePointErrorCode::NoError is the default for normal state transitions
  • Tests:
    • status_notification_sent_on_start_transaction — verify Preparing → Charging frames
    • status_notification_sent_on_stop_transaction — verify Finishing → Available frames
    • status_notification_sent_after_boot_accepted — connector 0 Available after boot
    • send_status_notification_custom_error_code — sends with specified error code
  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test --workspace all pass

Python reference

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions