PrusaConnect camera with raspberry pi + curl
 
Notifications
Clear all

PrusaConnect camera with raspberry pi + curl  

  RSS
Florian Castellane
(@florian-castellane)
Member
PrusaConnect camera with raspberry pi + curl

I'm trying to use this thread as a reference together with the prusa connect camera api reference and  to register a camera with curl, but keep getting

{"message": "Missing or invalid security token", "code": "UNAUTHORIZED"}

My request:

curl -X POST \
  -H "token: <token from  https://connect.prusa3d.com/printer/<my  printer uuid>/cameras>" \
  -H "fingerprint: <name of the camera in  https://connect.prusa3d.com/printer/<my  printer uuid>/cameras>" \
   https://connect.prusa3d.com/app/printers/<my  printer uuid/camera?origin=OTHER 

 I think I just didn't understand what the token and fingerprint are. These are given here right? I guess the fingerprint is the camera name, and the token is what is given here.

Can you see what I am doing wrong here?

Posted : 23/01/2024 6:53 am
Florian Castellane
(@florian-castellane)
Member
Topic starter answered:
RE: PrusaConnect camera with raspberry pi + curl

never mind, the service seems to be down at the moment...

{"message": "Service is unavailable at this moment. Try again later", "code": "SERVICE_UNAVAILABLE"}
Posted : 23/01/2024 7:14 am
Florian Castellane
(@florian-castellane)
Member
Topic starter answered:
RE: PrusaConnect camera with raspberry pi + curl

I got it to work. The TOKEN is not the same as the QR code it seems, you have to grab that as well from the web app. Here is some code to make it work with rpicam-still:

#!/usr/bin/env bash

set -Eeu
set -o pipefail
shopt -s extdebug

FINGERPRINT="changeme"
TOKEN="changeme"

trap 'declare rc=$?;
      >&2 echo "Unexpected error (exit-code $rc) executing $BASH_COMMAND at ${BASH_SOURCE[0]} line $LINENO";
      exit $rc' ERR

main () {

  while true
  do
    if rpicam-still -t 1 -o - \
    | curl   https://webcam.connect.prusa3d.com/c/snapshot   \
      -X PUT \
      -L --fail-with-body \
      -H "Content-Type: image/jpg" \
      -H "Fingerprint: $FINGERPRINT" \
      -H "Token: $TOKEN" \
      --data-binary @-
    then
      printf "."
    else
      echo
      echo "?"
    fi
    sleep 30
  done
}

main "$@"

 

Posted : 24/01/2024 9:29 am
timzilla
(@timzilla)
Active Member
RE: PrusaConnect camera with raspberry pi + curl

Just adding here that the camera fingerprint seems to be a generated UUID.   `uuidgen` in your shell, or any uuid generator should be able to create one.  no need to go through the prusa QR flow.  

Posted : 04/02/2024 5:23 pm
Kopr
 Kopr
(@kopr)
Member
RE: PrusaConnect camera with raspberry pi + curl

Follow the guide in my project and you should get it working without any problems

https://www.printables.com/model/989624-prusa-enclosure-raspberry-pi-camera-modification-w

Posted : 16/11/2024 7:42 am
Share: