Jump to content

coderforlife

Dormant
  • Posts

    6
  • Joined

  • Last visited

Posts posted by coderforlife

  1. There is a way to add CORS support to the printer without breaking authentication. You do not need to respond with the

    Access-Control-Allow-Origin : *

    header instead you can reply with an Access-Control-Allow-Origin header that copies the request Origin (which will always be provided if it matters for CORS). I added the following code to /usr/share/griffin/griffin/interface/http/server.py and it now allows CORS:

    # At the end of __init__:
    
            # Add CORS support
            self.after_request(Server.allow_cors)
    
    # At the end of Server:
    
        @staticmethod                                           
        def allow_cors(response):                                    
            if "Origin" in flask.request.headers:                                                                                
                response.headers["Access-Control-Allow-Origin"] = flask.request.headers["Origin"]
                response.headers["Vary"] = "Origin"
            return response                              

    Then you have to restart the HTTP server with 

    systemctl restart griffin.interface.http

    or just restart the machine.

     

    It would be nice if this showed up in the next firmware update so we don't have to go into developer mode to do it.

     

  2. Thanks! Great! Didn't know about that alternate view. It helped a bunch. Although, it doesn't have all of the states. For example, there seems to be no listing for "pause_source" or the history event IDs. I was able to dig through the griffin source and find some more of them.

     

    I have found a bug in the camera API and I think that the line in interfaces/html/um3server.py that is

    camera = Camera(self.__camera_service, api_v1)
    

    should be

    camera = Camera(self.__camera_service, "camera", api_v1)
    

    since otherwise it uses api_v1 as the "local_path" for the HTTPExposedItem and has no parent. I will be testing this out soon.

     

    Digging through the Griffin source I was also able to answer my question about the only maintenance events (type id 4) are post-able to /history/events. Still working on the remaining questions:

    • Things that are listed with a PUT but are not settable
    • The response of the /auth/check/{id} command
    • Connecting to a hidden command

     

  3. I have been working with the Ultimaker API for awhile and I have several questions about the API.

     

    I noticed a few days ago that the entire /camera API is no longer working, I always get a 404 error. The camera stream is still available at the :8080/?action=stream URL, but the API no longer is usable for finding that URL. I have tried power cycling the machine with no difference. Did this change at some point?

     

    Additionally, the /auth/check/{id} documentation doesn't seem to be clear. Does it only work for recently requested IDs? Like if I have an authorized ID from a day ago should it still remote "authorized"? For me it seems to only be reporting "unauthorized" unless I am actively in the approval process for the account (in which case it says "unknown"). I think that for a brief time after the "Accept" it does give "authorized" but I haven't confirmed this recently. I can each use the HTTP Digest Authorization with a particular ID/Key and it will still say "unauthorized". Seems strange. 

     

    Is there any way to connect to a hidden wifi network?

     

    Are only maintenance events (type id 4) post-able to /history/events?

     

    Some of things listed in /printer are said to be settable (e.g. /printer/heads/#/max_speed or /printer/heads/#/jerk) however their value does not seem to change with a PUT. There are others that are actually settable and do support PUT that are not listed as such (e.g. /printer/bed/temperature/current).

     

    My final question is what are the possible values to be reported from the following APIs? I know some of the values, but in many cases I am clearly missing several values. Is this documented?

    • /printer/status - I know booting, idle, printing, error, maintenance
    • /printer/head/#/extruder/#/hotend/offset/state - I know valid
    • /printer/network/wifi/mode - I know CABLE and AUTO
    • /print_job/source - I know WEB_API/*, WEB_API, and USB
    • /print_job/pause_source and in /history/print_jobs/* - I know api
    • /print_job/state - I know none, pre_print, printing, pausing, paused, resuming, and post_print
    • /print_job/result and in /history/print_jobs/* - I know "", Failed, Finished, and Aborted
    • /system/firmware/status - I know IDLE
     
    Thanks for any inputs anyone may have on any of these topics.
     
    Note: I am using an Ultimaker 3 Extended with the latest firmware
×
×
  • Create New...