Run in bash:
mkdir ~/.dav
touch ~/.dav/wallet
Open and edit ~/.dav/wallet
and save with following content:
{
"private": "0x<<YOUR WALLET PRIVATE KEY>>",
"address": "0x<<YOUR WALLET ADDRESS>>",
"nodeUrl": "https://<<A NETWORK NODE URL>>",
"networkType": "<<ropsten/...>>",
"apiSecret": "<<SOME SECRET PHRASE>>"
}
This wallet should have enough balance to perform the necessary transactions. Then run:
npm i
npm run gen-n-reg
Copy the new DAV Identity Address which is printed if all goes well.
curl -X POST -H "Content-Type: application/json" -d '{"toWhom":"<<ADDRESS>>"}' https://ropsten.faucet.b9lab.com/tap
Follow these instructions to have a locally running DAVNN cluster using Minikube. After that you should have a port-forwarding setup for the DAVNN server. These are required for the captain-charger server to communicate with captain-drone server.
Run:
npm run start-server
In another terminal:
npm run start-ui
Register a new charger to start accepting missions. The returned token must be kept for future interactions with the API.
- Method: POST
- Path: /register
- Body (json):
{
"address": "" /* Charger DAV ID */,
"lat": "" /* Charger latitude */,
"lon": "" /* Charger longitude */,
"radius": "" /* Charger service radius */
}
- Response (text): charger token
Access current status for charger. Use the token returned by /register
to authenticate.
- Method: GET
- Path: /status
- Headers:
- Authorization: Bearer
[charger token]
- Authorization: Bearer
- Response (text): Waiting/Committed/Ready
- Waiting: Charger is waiting for new missions.
- Committed: Charger is committed to a mission.
- Ready: Charger can begin charging.
Notify that charging has began. Use the token returned by /register
to authenticate.
- Method: POST
- Path: /started
- Headers:
- Authorization: Bearer
[charger token]
- Authorization: Bearer
- Response: (200 Ok)
Notify that charging has been completed. Use the token returned by /register
to authenticate.
- Method: POST
- Path: /complete
- Headers:
- Authorization: Bearer
[charger token]
- Authorization: Bearer
- Response: (200 Ok)
Notify that charger is ready for a new mission after drone has left it. Use the token returned by /register
to authenticate.
- Method: POST
- Path: /clear
- Headers:
- Authorization: Bearer
[charger token]
- Authorization: Bearer
- Response: (200 Ok)
Register a charger:
curl -w "\n" -X POST localhost:3000/register -H"Content-Type:application/json" -d'{"address":"0x8B22d48bd7fFBcE764c60AE2a78128427973DAdB","lat":"32.050382","lon":"34.766149","radius":"1000"}'
Store returned token into environment:
export CHARGER_TOKEN=<<TOKEN>>
Get charger status:
curl -w "\n" -X GET localhost:3000/status -H"Authorization: Bearer ${CHARGER_TOKEN}"
When status becomes Ready
- Start the mission:
curl -w "\n" -X POST localhost:3000/started -H"Authorization: Bearer ${CHARGER_TOKEN}"
When charging is complete:
curl -w "\n" -X POST localhost:3000/complete -H"Authorization: Bearer ${CHARGER_TOKEN}"
After drone has cleared the charger and charger is again ready for a new mission:
curl -w "\n" -X POST localhost:3000/clear -H"Authorization: Bearer ${CHARGER_TOKEN}"
Status should return to Waiting
until a new mission has been created.