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

Add general citrine support #58

Merged

Conversation

ChrisWeissmann
Copy link
Contributor

feat: add general citrine support with own device-model. Run bash command with argument -c.

Testing done:
Used local branch to test before pushing to remote ./demo-iso15118-2-ac-plus-ocpp.sh -2 -c -r $(pwd) -b feature/add-citrine-support-signedoff

[+] Running 5/5
 ✔ Network citrineos-csms_default          Created                                                                                                                                                            0.0s
 ✔ Container citrineos-csms-ocpp-db-1      Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-amqp-broker-1  Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-directus-1     Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-citrine-1      Healthy                                                                                                                                                           22.5s

Adding charger successfully:

Adding a charger to CitrineOS
Adding new station...
{"data":{"id":"cp001","isOnline":null,"locationId":2,"createdAt":"2024-06-10T15:10:18.175Z","updatedAt":"2024-06-10T15:10:18.176Z"}}{"data":{"id":"cp001","isOnline":null,"locationId":2,"createdAt":"2024-06-10T15:10:18.175Z","updatedAt":"2024-06-10T15:10:18.176Z"}}
Add cp001 password to citrine...
[+] Running 4/4
 ✔ Network everest-ac-demo_default          Created                                                                                                                                                           0.0s
 ✔ Container everest-ac-demo-mqtt-server-1  Healthy                                                                                                                                                           1.1s
 ✔ Container everest-ac-demo-nodered-1      Healthy                                                                                                                                                          31.0s
 ✔ Container everest-ac-demo-manager-1      Healthy
2024-06-10 15:13:05.314829 [INFO] ocpp:OCPP201     :: Received BootNotificationResponse: {
    "currentTime": "2024-06-10T15:13:05.306Z",
    "interval": 60,
    "status": "Accepted"
}

…mand with argument `-c`.

Testing done:
Used local branch to test before pushing to remote `./demo-iso15118-2-ac-plus-ocpp.sh -2 -c -r $(pwd) -b feature/add-citrine-support-signedoff`

```
[+] Running 5/5
 ✔ Network citrineos-csms_default          Created                                                                                                                                                            0.0s
 ✔ Container citrineos-csms-ocpp-db-1      Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-amqp-broker-1  Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-directus-1     Healthy                                                                                                                                                           22.6s
 ✔ Container citrineos-csms-citrine-1      Healthy                                                                                                                                                           22.5s

 ```
 Adding charger successfully:
 ```
Adding a charger to CitrineOS
Adding new station...
{"data":{"id":"cp001","isOnline":null,"locationId":2,"createdAt":"2024-06-10T15:10:18.175Z","updatedAt":"2024-06-10T15:10:18.176Z"}}{"data":{"id":"cp001","isOnline":null,"locationId":2,"createdAt":"2024-06-10T15:10:18.175Z","updatedAt":"2024-06-10T15:10:18.176Z"}}
Add cp001 password to citrine...
```
```
[+] Running 4/4
 ✔ Network everest-ac-demo_default          Created                                                                                                                                                           0.0s
 ✔ Container everest-ac-demo-mqtt-server-1  Healthy                                                                                                                                                           1.1s
 ✔ Container everest-ac-demo-nodered-1      Healthy                                                                                                                                                          31.0s
 ✔ Container everest-ac-demo-manager-1      Healthy
```
```
2024-06-10 15:13:05.314829 [INFO] ocpp:OCPP201     :: Received BootNotificationResponse: {
    "currentTime": "2024-06-10T15:13:05.306Z",
    "interval": 60,
    "status": "Accepted"
}
```

Signed-off-by: Christian Weissmann <[email protected]>
@thanaParis
Copy link
Contributor

@shankari can we close #53 in favor of this PR? Hoping we can merge this soon!

@louisg1337
Copy link
Contributor

louisg1337 commented Jun 17, 2024

Thank you guys for getting this over to us. I took some time to try out the new demo script and almost everything worked as expected. Here are the steps I took and the results I saw.

  1. Cloned repo + checked out branch.
    git clone https://github.com/ChrisWeissmann/everest-demo.git
    git checkout -b feature/add-citrine-support-signedoff origin/feature/add-citrine-support-signedoff      
    
  2. Ran the demo script.
    bash demo-iso15118-2-ac-plus-ocpp.sh -2 -c -r $(pwd) -b feature/add-citrine-support-signedoff     
    
  3. Observed all of the following (same as @ChrisWeissmann above).
    • Citrine containers start successfully ✅
    • Charger and password set successfully ✅
    • EVerest containers loaded properly ✅
    • BootNotificationResponse returned accepted ✅
  4. Went to localhost:8080/docs and sent a setChargingProfile API request.
    • Message was successfully sent to EVerest as it was in the OCPP logs and returned a Not Implemented. ✅
  5. Went to localhost:1880/ui and tried to start a charging session.
    • Unfortunately this didn't work as it seems like we aren't adding any authorization token to Citrine. Whenever I tried swiping the RFID to authorize the transaction, I get this message in return. ❌
    2024-06-17 22:49:02.926657 [INFO] token_provider_  :: Publishing new dummy token: {"id_token":{"value":"DEADBEEF","type":"ISO14443"},"authorization_type":"RFID","prevalidated":false,"connectors":[1]}
    2024-06-17 22:49:02.931590 [INFO] auth:Auth        :: Received new token: {
        "authorization_type": "RFID",
        "connectors": [
            1
         ],
        "id_token": {
            "type": "ISO14443",
            "value": "DEADBEEF"
         },
      "prevalidated": false
    }
    2024-06-17 22:49:02.942580 [INFO] ocpp:OCPP201     :: Found invalid entry in AuthCache: Sending new request
    2024-06-17 22:49:03.076192 [INFO] auth:Auth        :: Result for token: DEADBEEF: REJECTED
    

Let me know if I did something wrong somewhere along the line that would get 5 working. Other than that one issue, it all looked great. We really appreciate all the work that was put into getting this PR together!

EDIT:

I forgot to check this before, but MaEVe doesn't work with this new script. There are a few changes that need to be made to make it work in this new script, all of which I am working on getting into the review.

@shankari
Copy link
Collaborator

@thanaParis @ChrisWeissmann please see comment from @louisg1337

Copy link
Contributor

Choose a reason for hiding this comment

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

If you could put in an extra function to support adding in EVerest's authorization token to Citrine that would be great. I put more context regarding this in my comment here.


if [[ "$DEMO_VERSION" != v1.6j ]]; then
echo "Cloning ${CSMS} CSMS from ${CSMS_REPO} into ${DEMO_DIR}/${CSMS}-csms and starting it"
if [[ "$DEMO_VERSION" != v1.6j && "$DEMO_CSMS" == meave ]]; then
Copy link
Contributor

Choose a reason for hiding this comment

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

Small typo meave --> 'maeve'

echo "Cloning ${CSMS} CSMS from ${CSMS_REPO} into ${DEMO_DIR}/${CSMS}-csms and starting it"
if [[ "$DEMO_VERSION" != v1.6j && "$DEMO_CSMS" == meave ]]; then
echo "Cloning ${DEMO_CSMS} CSMS from ${MAEVE_REPO} into ${DEMO_DIR}/${DEMO_CSMS}-csms and starting it"
git clone --branch "${MAEVE_BRANCH}" "${MAEVE_REPO}" "${CSMS}-csms"
Copy link
Contributor

Choose a reason for hiding this comment

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

Change "${CSMS}-csms" to "${DEMO_CSMS}-csms"

Comment on lines -311 to -340
if [[ "$DEMO_VERSION" =~ sp1 ]]; then
echo "MaEVe CSMS started, adding charge station with Security Profile 1 (note: profiles in MaEVe start with 0 so SP-0 == OCPP SP-1)"
curl http://localhost:9410/api/v0/cs/cp001 -H 'content-type: application/json' \
-d '{"securityProfile": 0, "base64SHA256Password": "3oGi4B5I+Y9iEkYtL7xvuUxrvGOXM/X2LQrsCwf/knA="}'
elif [[ "$DEMO_VERSION" =~ sp2 ]]; then
echo "MaEVe CSMS started, adding charge station with Security Profile 2 (note: profiles in MaEVe start with 0 so SP-1 == OCPP SP-2)"
curl http://localhost:9410/api/v0/cs/cp001 -H 'content-type: application/json' \
-d '{"securityProfile": 1, "base64SHA256Password": "3oGi4B5I+Y9iEkYtL7xvuUxrvGOXM/X2LQrsCwf/knA="}'
elif [[ "$DEMO_VERSION" =~ sp3 ]]; then
echo "MaEVe CSMS started, adding charge station with Security Profile 3 (note: profiles in MaEVe start with 0 so SP-2 == OCPP SP-3)"
curl http://localhost:9410/api/v0/cs/cp001 -H 'content-type: application/json' -d '{"securityProfile": 2}'
fi

echo "Charge station added, adding user token"

curl http://localhost:9410/api/v0/token -H 'content-type: application/json' -d '{
"countryCode": "GB",
"partyId": "TWK",
"type": "RFID",
"uid": "DEADBEEF",
"contractId": "GBTWK012345678V",
"issuer": "Thoughtworks",
"valid": true,
"cacheMode": "ALWAYS"
}'

curl http://localhost:9410/api/v0/token -H 'content-type: application/json' -d '{"countryCode": "UK", "partyId": "Switch", "contractId": "UKSWI123456789G", "uid": "UKSWI123456789G", "issuer": "Switch", "valid": true, "cacheMode": "ALWAYS"}'
fi

echo "API calls to CSMS finished, starting EVerest..."
Copy link
Contributor

@louisg1337 louisg1337 Jun 18, 2024

Choose a reason for hiding this comment

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

All of this needs to be re-added into the MaEVe section. You can just copy and paste all of it into line 147, although please don't include the fi on line 338.

@thanaParis thanaParis force-pushed the feature/add-citrine-support-signedoff branch from eb7c43a to 0b1584a Compare June 18, 2024 18:21
Signed-off-by: Christian Weissmann <[email protected]>
@thanaParis
Copy link
Contributor

@louisg1337 the issues with maeve have been fixed! the add-charger.sh script was expanded to add-charger-and-rfid-card.sh and now adds an idToken to CitrineOS with value 'DEADBEEF' and type 'ISO14443'.

@shankari
Copy link
Collaborator

@louisg1337 in the absence of github actions, can you please try to rerun this for both MaEVe and Citrine? I can then merge this. @MukuFlash03 for an example of what the lack of GH actions is doing 😦

@louisg1337
Copy link
Contributor

@louisg1337 the issues with maeve have been fixed! the add-charger.sh script was expanded to add-charger-and-rfid-card.sh and now adds an idToken to CitrineOS with value 'DEADBEEF' and type 'ISO14443'.

I can confirm everything works as expected now. I tested both Citrine and MaEVe and they both posted Accepted and worked in the SIL demo. Thank you @thanaParis and @ChrisWeissmann for fixing that for us!

Copy link
Contributor

@louisg1337 louisg1337 left a comment

Choose a reason for hiding this comment

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

Looks great, thanks again for getting this in to us!

@shankari shankari merged commit 6ac3228 into EVerest:main Jun 26, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants