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

chrivers/webserver-mainsail-rpc #115

Draft
wants to merge 290 commits into
base: upcoming/v1.1
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
290 commits
Select commit Hold shift + click to select a range
d6f2ee9
* Refactor web server to use new ws blueprint from web.api.ws
chrivers May 26, 2023
2020ab8
* Move ankerctl api endpoints to web.api.ankerctl, implemented with …
chrivers May 26, 2023
07c2f36
* Move /websocket endpoint to web/__init__.py
chrivers May 26, 2023
d1c5620
- Remove unused imports
chrivers May 26, 2023
6951a1c
* Refactor moonraker.server to implement via Blueprint. This avoids …
chrivers May 26, 2023
03a7747
- Remove unused imports
chrivers May 26, 2023
2e86b6d
* Move octoprint api endpoints into web.api.octoprint
chrivers May 26, 2023
7910c97
* Specify parameter list for server.announcements.list
chrivers May 26, 2023
53ccc17
* Avoid circular imports of moonraker, now that we use blueprints th…
chrivers May 27, 2023
d70e37c
* Avoid circular imports of services, now that we use blueprints thr…
chrivers May 27, 2023
51807bb
* Move base endpoints into web.base, to make web/__init__.py less cl…
chrivers May 27, 2023
0777e46
* Move all Flask initialization into webserver()
chrivers May 27, 2023
3f3263e
* Rework all rpc functions to accept actual parameters, instead of g…
chrivers May 27, 2023
2aeac61
+ Added rpc stub for printer.print.start
chrivers May 27, 2023
8c50217
+ Added rpc stub for server.files.move
chrivers May 27, 2023
1e06ce2
+ Added rpc stub for machine.{services.restart,reboot,shutdown,devic…
chrivers May 27, 2023
d8639d0
+ Added rpc stub for server.logs.rollover
chrivers May 27, 2023
c1b476e
* Fixed parameter default for server.database.list
chrivers May 27, 2023
8973818
* Rename MqttNotifierService to UpdateNotifierService, since it will…
chrivers May 27, 2023
9c51a5b
+ Add notify_error() method on UpdateNotifierService
chrivers May 27, 2023
13b952b
+ Add rpcutil.format_response(), to support moonraker formatting of …
chrivers May 27, 2023
0ad7578
+ Make /websocket endpoint report on error conditions in mainsail ui
chrivers May 27, 2023
1adcc24
+ Add Heater and PrinterState dataclasses, for use with moonraker st…
chrivers May 27, 2023
d7739c8
* Make log_jsonrpc_req() handle TypeError when logging rpc requests
chrivers May 27, 2023
9b572ce
- Remove obsolete debug print
chrivers May 27, 2023
2a320b2
+ Add debug line in ServiceManager.atexit() when waiting for service…
chrivers May 27, 2023
dbfe517
* Disable video frame debug output in libflagship.ppppapi, since it …
chrivers May 27, 2023
bdef369
+ Implement web.model.PrinterStats, for tracking temperature history
chrivers May 27, 2023
7726544
* Extend MQTT cli parsing with support for nested keys. This is need…
chrivers May 28, 2023
e33b189
* Make UpdateNotifierService track temperature state and history. Us…
chrivers May 28, 2023
4bc9144
* Make UpdateNotifierService depend on mqttqueue, but do not require…
chrivers May 28, 2023
49577ca
* Make "updates" service always active, to track printer state even …
chrivers May 28, 2023
38a70b9
- Remove dummy data for device_power, which we do not have an equiva…
chrivers May 28, 2023
00f6d7e
* Fixed machine.proc_stats, by removing use of obsolete app.websocke…
chrivers May 28, 2023
5167718
- Remove sd_info from machine.system_info, since we have no equivalent
chrivers May 28, 2023
8d0e759
- Disable output from printer.query_endstops.status, since we cannot…
chrivers May 28, 2023
7a70346
- Remove virtual_sdcard object from moonraker
chrivers May 28, 2023
f3f3404
- Remove query_endstops object from moonraker
chrivers May 28, 2023
2d983d2
- Remove filament_motion_sensor object from moonraker
chrivers May 28, 2023
2019752
- Remove manual_probe object from moonraker
chrivers May 28, 2023
f6853fc
- Remove output_pin object from moonraker
chrivers May 28, 2023
8be953d
- Remove printer, stepper_{x,y,z} from moonraker "configfile" object
chrivers May 28, 2023
20ddc72
+ Add dummy virtual_sdcard dict to moonraker configfile api, to avoi…
chrivers May 28, 2023
b8f90ca
- Remove unnecessary mcu-related values in moonraker configfile api
chrivers May 28, 2023
5697ebe
- Remove firmware_retraction object from moonraker
chrivers May 28, 2023
6d1abd7
- Remove all configfile-related data from moonraker
chrivers May 28, 2023
2a4d45d
* Fixed url_for() in tabs/print.html
chrivers May 28, 2023
bb62bb4
+ Implemented web.lib.trace, a module for dumping stack traces of th…
chrivers May 28, 2023
0c26516
+ Hook web.lib.trace into atexit() handler of ServiceManager, for be…
chrivers May 28, 2023
5c76b58
+ Implement UpdateNotifierService.notify_status_updates() helper, fo…
chrivers May 28, 2023
dd41cc2
* Fixed incorrect parameters in notify_status_update()
chrivers May 28, 2023
f75e1b4
+ Add UpdateNotifierService.notify_job_queue_changed()
chrivers May 28, 2023
d542fb8
* Fix missing default for "root" parameter in /server/files/upload
chrivers May 28, 2023
182f6a9
* Make json-rpc error formatting able to handle edge cases with miss…
chrivers May 28, 2023
43afff2
+ Stubbed out all server.job_queue.* moonraker rpc endpoints
chrivers May 28, 2023
76291d5
- Remove unused canbus fields from machine_system_info()
chrivers May 28, 2023
156e40f
+ Add stubs for machine.services.{stop,start} moonraker rpc endpoints
chrivers May 28, 2023
ed15deb
+ Added PoC of persisting temperature stats between runs
chrivers May 28, 2023
c689ce8
- Remove obsolete import
chrivers May 29, 2023
c25fbfe
+ Add dataclasses for Job and JobQueue
chrivers May 29, 2023
8567d99
+ Add proof-of-concept JobQueueService, for tracking queued print jobs
chrivers May 29, 2023
c4d170e
+ Register JobQueueService as "jobqueue" in ServiceManager
chrivers May 29, 2023
9bf05a6
+ Added minimal implementation of server.job_queue.{status, post_job…
chrivers May 29, 2023
8fed946
+ Added dummy implementation of printer.print.{start, pause, resume,…
chrivers May 29, 2023
4b05a39
* Fixed "memavail" field in print_objects_subscribe() semi-dummy data
chrivers May 29, 2023
cf47808
- Remove old commented code
chrivers May 30, 2023
6e3044a
* Updated hardcoded semi-dummy data for machine_update_status()
chrivers May 30, 2023
0a54e4a
+ Added rpc stub for machine.update.{klipper, system, full}
chrivers May 30, 2023
ab8fedf
* Use new match-case syntax for Service.run()
chrivers May 30, 2023
6be0221
* Use new match-case syntax for UpdateNotifierService.mqtt_to_jsonrp…
chrivers May 30, 2023
b65483a
* Use match-case in printer_gcode_script()
chrivers May 30, 2023
d6db51e
+ Define some common gcode macros for moonraker, in printer_objects_…
chrivers May 30, 2023
5a85599
+ Add experimental stubs for ANKERCTL_LIGHT_{ON, OFF} gcode macros
chrivers May 30, 2023
dd1c28c
* Make printer_gcode_script() support gcode with multiple instructio…
chrivers May 30, 2023
e8fa9e7
+ Added base class for gcode metadata readers
chrivers May 30, 2023
9a8b5cb
+ Implemented Ankermake Slicer gcode metadata reader
chrivers May 30, 2023
de6ed6d
+ Implemented PrusaSlicer gcode metadata reader
chrivers May 30, 2023
d75e1ad
* Move notify_job_queue_changed() from rpc/server/job_queue.py to se…
chrivers May 30, 2023
4a652e0
+ Add GCodeMetaAuto class for auto-detecting gcode metadata, based o…
chrivers May 31, 2023
7138214
+ Implement support for parsing metadata in head of prusaslicer gcode
chrivers May 31, 2023
62fee19
+ Implement support for parsing metadata in head of ankerslicer gcode
chrivers May 31, 2023
42f728e
+ Implemented GCodeMetaSuperSlicer as a specialization of GCodeMetaP…
chrivers May 31, 2023
a930a70
+ Implement parsing of slicer name and version in prusaslicer metada…
chrivers May 31, 2023
0fde4c8
+ Implemented thumbnail parsing and extraction in GCodeMetaAnkerSlicer
chrivers May 31, 2023
0d38d1b
+ Implemented thumbnail parsing and extraction in GCodeMetaPrusaSlicer
chrivers May 31, 2023
f28f20d
+ Implement .load_metadata() in GCodeMeta, GCodeMetaAuto
chrivers May 31, 2023
44ba5f3
+ Implement slicer name/version parsing in GCodeMetaAnkerSlicer
chrivers May 31, 2023
ad87b81
+ Make GCodeMetaPrusaSlicer parse values strings as json, where poss…
chrivers May 31, 2023
ac69e1f
+ Implement data models for FileThumbnail, FileMetadata
chrivers May 31, 2023
2efc3c5
+ Implement load_metadata() in GCodeMetaAnkerSlicer
chrivers May 31, 2023
4ef144e
+ Implement load_metadata() in GCodeMetaPrusaSlicer
chrivers May 31, 2023
75367c1
+ Implement server_files_get_metadata() in terms of GCodeMetaAuto, w…
chrivers May 31, 2023
cb6897b
+ Implement web util function flash_redirect_root(), for redirecting…
chrivers Jun 1, 2023
5fc468a
* Fix redirects in web/api/ankerctl.py, which should now point to ba…
chrivers Jun 1, 2023
52db5b5
* Fixed rpc handler functions that had mismatched function names
chrivers Jun 1, 2023
df8d7d0
+ Make printer_print_cancel() set "current file" to None, to have it…
chrivers Jun 1, 2023
7e6c533
* For some reason, mainsail sometimes calls server.files.metadata wi…
chrivers Jun 1, 2023
d75db65
- Remove fan, heater_fan and controller_fan objects from moonraker a…
chrivers Jun 1, 2023
fc11d73
- Remove unsupported motion_report object from moonraker
chrivers Jun 1, 2023
ce2aa23
- Removed accidentally included parameter in flash_redirect_root(). …
chrivers Jun 3, 2023
6b589ab
+ Added MqttPrintEvent and MqttMarlinEvent to mqtt specification
chrivers Jun 3, 2023
dfc6132
- Remove duplicate fields in FileMetadata
chrivers Jun 3, 2023
b5d4558
* Fix default value for FileMetadata.thumbnails. Should be empty arr…
chrivers Jun 3, 2023
c261f08
* Make format_jsonrpc_req() handle requests without "param" field (f…
chrivers Jun 3, 2023
15f43fb
* Move machine.py into machine/__init__.py, in preparation for facto…
chrivers Jun 3, 2023
b88f3ae
* Move machine.update.* into machine/update.py
chrivers Jun 3, 2023
552cd78
+ Stubbed out machine.update.{client, recover}
chrivers Jun 3, 2023
ff7cc0a
* Move machine.device_power.* into machine/device_power.py
chrivers Jun 3, 2023
b809cb2
+ Stubbed out machine.device_power.post_device
chrivers Jun 3, 2023
e5a65b8
+ Added stubs for machine.timelapse.* moonraker rpc commands
chrivers Jun 3, 2023
2cc9402
* Fix arguments for server_files_get_directory: path should default …
chrivers Jun 3, 2023
d243fae
+ Add "root" parameter to server_files_get_directory, which Fluidd s…
chrivers Jun 3, 2023
d6f80bc
+ Make server_files_get_directory abort if "extended" argument is gi…
chrivers Jun 3, 2023
3845632
+ Stubbed server.files.zip moonraker rpc method
chrivers Jun 3, 2023
0081f48
+ Stubbed server.{announcements.dismiss, history.delete_job, webcams…
chrivers Jun 3, 2023
032d6b7
+ Stubbed printer.{restart, firmware_restart} moonraker rpc methods
chrivers Jun 3, 2023
f8b4eb8
+ Add dummy implementation of /access/* moonraker APIs. This is need…
chrivers Jun 3, 2023
2fee823
+ Fix default value for thumbnails in gcode metadata parsers
chrivers Jun 3, 2023
ddc1c4a
+ Added missing configfile.config.heater_bed value. Without this, ma…
chrivers Jun 3, 2023
08b3235
* Cleaned up some dummy data
chrivers Jun 3, 2023
8095249
* Make sure all gcode_macro objects have .description, as otherwise …
chrivers Jun 3, 2023
b2dc32f
+ Add empty "bed_mesh" fields to .configfile and .settings to make b…
chrivers Jun 3, 2023
614868e
+ Add empty "extruder" fields to .configfile and .settings to make n…
chrivers Jun 3, 2023
9dd89f9
* Adjust toolhead info with values from @just-trey slicer profiles
chrivers Jun 3, 2023
65d7886
* Adjust toolhead.axis_minimum with (assumed) correct values
chrivers Jun 3, 2023
1516de9
* Sketched out dataclasses for moonraker api
chrivers Jun 3, 2023
250cc7c
* Converted some timelapse endpoints to provide dummy data, instead …
chrivers Jun 3, 2023
6755447
+ Added missing imports for moonraker.model
chrivers Jun 3, 2023
8fc5e3a
* Fixed default values for moonraker.model
chrivers Jun 3, 2023
5ff0b6f
* Make all moonraker.model classes use unsafe_hash, to support chang…
chrivers Jun 3, 2023
ff62c82
* Fixed capitalization for Configfile and Mcu classes
chrivers Jun 3, 2023
1c5dec4
+ Added missing GcodeMoves and ExcludeObjects classes
chrivers Jun 3, 2023
cd6d387
+ Make Serialize class implement best-effort __hash__ function, supp…
chrivers Jun 3, 2023
100f51d
* Make moonraker models use eq=False instead of unsafe_hash=True, to…
chrivers Jun 3, 2023
640844b
+ Implement UpdateManager, a class that monitors a collection of moo…
chrivers Jun 3, 2023
851061d
+ Implement http wrappers for some ws endpoints needed for Fluidd
chrivers Jun 3, 2023
bc9f82e
+ Added support for handling gcode M117 (Set LCD Message), as used f…
chrivers Jun 3, 2023
fcb5003
+ Add delay between each line of gcode sent over mqtt, as otherwise …
chrivers Jun 3, 2023
b616cdf
+ Implement handling of ANKERCTL_LIGHT_{ON, OFF} gcode, and convert …
chrivers Jun 3, 2023
16d73b8
+ Add handling of ZZ_MQTT_CMD_AUTO_LEVELING, and create update messa…
chrivers Jun 3, 2023
090ccdc
+ Added proof-of-concept handling of ZZ_MQTT_CMD_PRINT_SCHEDULE (cur…
chrivers Jun 3, 2023
44ddf67
+ Added proof-of-concept handling of ZZ_MQTT_CMD_MOTOR_LOCK, and att…
chrivers Jun 3, 2023
10e8c65
+ Add initial support for parsing reply from "M420 V1" (print bed le…
chrivers Jun 3, 2023
78b19db
+ Make UpdateNotifierService send out an empty update at regular int…
chrivers Jun 3, 2023
ab56611
+ Implement UpdateManager.moonraker_status_update()
chrivers Jun 3, 2023
d22a87c
+ Integrate UpdateManager into UpdateNotifierService
chrivers Jun 3, 2023
8a884ad
* Fix typos in moonraker dataclasses
chrivers Jun 3, 2023
173c80d
+ Set useful defaults on moonraker dataclasses
chrivers Jun 3, 2023
7877615
* Fixed type of BedMeshProfile.mesh_params
chrivers Jun 3, 2023
8930c2f
+ Add missing VirtualSdcard moonraker dataclass
chrivers Jun 3, 2023
c82cba9
+ Add moonraker_object_list(), moonraker_status_full() integration m…
chrivers Jun 3, 2023
7cf5a1c
* Make printer.objects.list rpc method use UpdateManager to query bu…
chrivers Jun 3, 2023
efdbfb1
* Use UpdateManager to simplify printer.objects.subscribe rpc endpoi…
chrivers Jun 3, 2023
09ce870
* Convert ZZ_MQTT_CMD_HOTBED_TEMP and ZZ_MQTT_CMD_NOZZLE_TEMP to use…
chrivers Jun 3, 2023
8a3e296
* Convert ZZ_MQTT_CMD_AUTO_LEVELING to use UpdateManager
chrivers Jun 3, 2023
2181d9f
* Convert ZZ_MQTT_CMD_PRINT_SCHEDULE to use UpdateManager
chrivers Jun 3, 2023
3437653
* Convert ZZ_MQTT_CMD_MOTOR_LOCK to use UpdateManager
chrivers Jun 3, 2023
8702d58
* Convert ZZ_MQTT_CMD_GCODE_COMMAND to use UpdateManager
chrivers Jun 3, 2023
e8c0f8a
- Remove obsolete code from mqtt_to_jsonrpc_req(), now that UpdateMa…
chrivers Jun 3, 2023
bce3a7f
* Make Serialize.to_dict() properly handle nested complex data types…
chrivers Jun 3, 2023
9e3871a
+ Add "recursive" option to Serialize.to_dict(), since full recursio…
chrivers Jun 4, 2023
253c504
* Make BaseConfigManager use non-recursive dict flattening of Serial…
chrivers Jun 4, 2023
6aab928
- Remove custom to_dict() on Job dataclass. It is no longer needed, …
chrivers Jun 4, 2023
d60e752
* Use shlex splitting in GCode parser, to support commands with quot…
chrivers Jun 4, 2023
c64e4bf
+ Add command queue to MqttQueue service, to avoid accessing the Pah…
chrivers Jun 4, 2023
23bb6e3
+ Add api_*() helper methods on MqttService, for queuing commands
chrivers Jun 4, 2023
e2f2ceb
+ Attempt to strip internal "ringbuf:" suffixes on gcode replies, to…
chrivers Jun 4, 2023
78f74d0
* Fake heater power status, by comparing current and target temperat…
chrivers Jun 4, 2023
29bce86
* Fix buggy default value in BedMeshProfile dataclass. The mesh_para…
chrivers Jun 4, 2023
0954445
+ Provide "ankermake-builtin" default profile in BedMesh dataclass
chrivers Jun 4, 2023
8c62c85
* Simplify printer.gcode.script handler using .api_gcode() helper in…
chrivers Jun 4, 2023
38f9a16
+ Support dynamic loading of bed mesh from printer in printer.gcode.…
chrivers Jun 4, 2023
75c088a
* Simplify MqttQueue.api_command() using keyword arguments
chrivers Jun 4, 2023
cdb395a
* Simplify printer_gcode_script() using MqttQueue.api_command()
chrivers Jun 4, 2023
ee9e5a2
* Simplify printer_gcode_script() using UpdateManager state tracking
chrivers Jun 4, 2023
bff33ae
* Simplify printer.print.* handlers using UpdateManager state tracking
chrivers Jun 4, 2023
3b562ef
+ Added description to ConnectionResetError in ppppapi
chrivers Jun 4, 2023
bc0a1ec
* Improved error message in Service.await_ready()
chrivers Jun 4, 2023
27291fe
+ Hook machine.services.restart into ServiceManager. This makes it p…
chrivers Jun 4, 2023
cfa4499
* Move Job, JobQueue classes below FileThumbnail, since Job needs to…
chrivers Jun 4, 2023
d7ee438
+ Add missing fields on Job dataclass
chrivers Jun 4, 2023
a891922
- Remove job_id from FileMetadata. It turns out the metadata *endpoi…
chrivers Jun 4, 2023
11873dd
* Change .job_id from "bytes" to "str", and add helper function to c…
chrivers Jun 4, 2023
4fdf135
+ Add Job.time_taken property (calculated from .start_time and .end_…
chrivers Jun 4, 2023
ab71102
+ Override Job.to_dict() to include .time_in_queue property
chrivers Jun 4, 2023
697d4e6
+ Add FileMetadata to allowed jobs.json types
chrivers Jun 4, 2023
1f7d6a8
+ Add .history field to JobQueue, for tracking job history
chrivers Jun 4, 2023
4d7db5c
+ Add support for UnionType (datetime | None) in Serialize.from_dict…
chrivers Jun 4, 2023
2e7b396
* Fixed style
chrivers Jun 4, 2023
8a4ffe0
* Make server_files_metadata enrich metadata with .job_id and .uuid,…
chrivers Jun 4, 2023
7d91433
+ Add UpdateNotifierService.notify_history_changed() for moonraker h…
chrivers Jun 5, 2023
65449bf
* Move JobQueueService.next_job_id() to JobQueue class
chrivers Jun 5, 2023
89db219
+ Implement .load_metadata() and .load_metadata_dict() on JobQueueSe…
chrivers Jun 5, 2023
6390fda
+ Use load_metadata_dict() to add metadata in JobQueueService.post_j…
chrivers Jun 5, 2023
2424b77
+ Implement history_{start, error, status, delete} methods on JobQue…
chrivers Jun 5, 2023
0fb2bbf
+ Implement proof-of-concept server.job_queue.start. Not the correct…
chrivers Jun 5, 2023
8aa4a9b
+ Simplify server_files_metadata() using JobQueueService.load_metada…
chrivers Jun 5, 2023
2f39ddb
+ Implement server_history_list() using jobqueue history functions
chrivers Jun 5, 2023
1ccefed
+ Implement server_history_totals() using jobqueue history functions
chrivers Jun 5, 2023
5eb81c1
+ Implement server_history_delete_job() using jobqueue history funct…
chrivers Jun 5, 2023
8054d01
+ Make FileTransferService.api_aabb_request() check FileTransferRepl…
chrivers Jun 5, 2023
5e6b1ef
+ Improve exception handling in FileTransferService, and report empt…
chrivers Jun 5, 2023
321a525
+ Make FileTransferService.api_aabb_request() use a timeout, to avoi…
chrivers Jun 5, 2023
bc37db0
* Use api_aabb_request() instead of api_aabb() for FileTransfer.BEGI…
chrivers Jun 5, 2023
4a338a8
+ Connect FileTransferService to UpdateNotifierService and JobQueueS…
chrivers Jun 5, 2023
0d2f2ea
- Remove ZZ_MQTT_{PRINT,MARLIN}_EVENT_MAX
chrivers Jun 5, 2023
799618e
+ Implement handling of status updates from MqttMsgType.ZZ_MQTT_CMD_…
chrivers Jun 5, 2023
bc15e9f
+ Implement progress updates from MqttMsgType.ZZ_MQTT_CMD_MODEL_LAYE…
chrivers Jun 5, 2023
9adb473
+ Added descriptions for printer and marlin events
chrivers Jun 10, 2023
9ae592e
* Change deprecated log.warn to log.warning
chrivers Jun 10, 2023
dd8fede
* Style and naming fixes
chrivers Jun 10, 2023
d71f7f5
+ Prefix log messages with timestamp (very useful for debugging timi…
chrivers Jun 10, 2023
ccd6faf
+ Fix broken endpoint /video. Since we are generating a video stream…
chrivers Jun 10, 2023
75958e4
+ Improved await_{ready, stopped}() logging in Service
chrivers Jun 10, 2023
d0af9e4
+ Add workaround for bug in printer firmware: printer cannot handle …
chrivers Jun 10, 2023
0695721
+ Improved gcode reply cleanup, by capturing junk parts with a regul…
chrivers Jun 10, 2023
3fc5f22
+ Handle MqttPrintEvent.ZZ_MQTT_PRINT_EVENT_LEVELING notifications
chrivers Jun 10, 2023
b9c4693
+ Handle MqttMarlinEvent updates (error messages reported from marli…
chrivers Jun 10, 2023
3e8c498
+ Implemented basic support for Runstate.Idle for services, to allow…
chrivers Jun 10, 2023
466f594
+ Added Holdoff.remaining property
chrivers Jun 10, 2023
f5463f2
+ Make Holdoff() initialize deadline to datetime.now(), to ensure .r…
chrivers Jun 10, 2023
d3b4778
+ Implement __repr__ on Holdoff
chrivers Jun 10, 2023
a050820
+ Added docstring for Holdoff
chrivers Jun 10, 2023
3342e49
* Move service dump below log message
chrivers Jun 10, 2023
73fda5e
+ Move thread tracebacks below service list dump
chrivers Jun 10, 2023
5c7ef80
+ Implement WaitableHoldoff class, for managing a deadline that can …
chrivers Jun 10, 2023
3cd6684
* Rework Service class to use new WaitableHoldoff, which replaces ._…
chrivers Jun 10, 2023
48cd553
- Remove obsolete shutdown code in Service class
chrivers Jun 10, 2023
c0d4dea
- Remove Service.name property, and simply set .name in __init__()
chrivers Jun 10, 2023
0cb5245
+ Wrap Service.state in property, to allow easy logging of state cha…
chrivers Jun 10, 2023
072c8f8
+ Add "name" field to log format output. This prefixes each log mess…
chrivers Jun 11, 2023
2784abb
+ Print "\n" in ServiceManager.atexit(), to provide clean separation…
chrivers Jun 11, 2023
ab04d15
* Convert Service and ServiceManager classes to use loggers from log…
chrivers Jun 11, 2023
dddd8ac
* Convert rpcutil to use instance logger, and make rpc response outp…
chrivers Jun 11, 2023
092708c
* Convert lib/trace.py to use instance logger
chrivers Jun 11, 2023
b9a6153
* Only set Service._shutdown flag on Service.shutdown(), not Service…
chrivers Jun 11, 2023
11d0cd8
+ Make ServiceManager.atexit() set ._shutdown flag on all services, …
chrivers Jun 11, 2023
fa2d203
* Completely rework Service class handling of run states. This new v…
chrivers Jun 11, 2023
7f4a6c6
+ Implement printer.objects.query moonraker RPC method, and use this…
chrivers Jun 11, 2023
30cee4f
* Optimize gcode rpc endpoint, by joining gcode commands with ",", i…
chrivers Jun 11, 2023
c9512da
+ Implemented MotionReport moonraker dataclass
chrivers Jun 11, 2023
452887c
+ Add motion_report support in UpdateManager
chrivers Jun 11, 2023
711531f
* Make MQTT service create Queue object on worker init, not each tim…
chrivers Jun 11, 2023
05e927f
* Whitespace cleanup
chrivers Jun 11, 2023
815c3ae
+ Implemented rpc_wrap_* helper functions, for creating http endpoin…
chrivers Jun 11, 2023
f715fd7
* Convert manually crated endpoint wrappers into rpc_wrap_*() helpers
chrivers Jun 11, 2023
4d453af
+ Added more http endpoint wrappers for websocket endpoints
chrivers Jun 11, 2023
83460cd
+ Added http wrapper /printer/objects/query for websocket endpoint
chrivers Jun 11, 2023
62ce560
+ Make printer gcode endpoint catch BED_MESH_CALIBRATE and convert i…
chrivers Jun 11, 2023
01a0650
+ Added docstrings for rpc_wrap_*
chrivers Jun 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions ankerctl.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ def mqtt_send(env, command_type, args, force):
To see a list of known command types, run this command without arguments.
"""

cmd = {
"commandType": command_type,
**{key: value for (key, value) in args},
}
cmd = cli.util.make_mqtt_req(command_type, args)

if not force:
if command_type == MqttMsgType.ZZ_MQTT_CMD_RECOVER_FACTORY.value:
Expand Down
2 changes: 1 addition & 1 deletion cli/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def _save_json(val):
if not isinstance(val, Serialize):
return val

data = val.to_dict()
data = val.to_dict(recursive=False)
data["__type__"] = type(val).__name__
return data

Expand Down
5 changes: 4 additions & 1 deletion cli/logfmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def __init__(self, fmt):
logging.DEBUG: "D",
}

default_msec_format = click.style("%s.%03d", dim=True)

def format(self, rec):
marks, colors = self._marks, self._colors
return "".join([
Expand All @@ -47,5 +49,6 @@ def setup_logging(level=logging.INFO):
log = logging.getLogger()
log.setLevel(level)
handler = log.handlers[0]
handler.setFormatter(ColorFormatter("%(message)s"))
name_fmt = click.style('%(name)s', fg='blue', bold=True)
handler.setFormatter(ColorFormatter(f"[%(asctime)s] {name_fmt}: %(message)s"))
return log
51 changes: 45 additions & 6 deletions cli/model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,35 @@
import json
from types import UnionType
from datetime import datetime
from dataclasses import dataclass
from libflagship.util import unhex, enhex


class Serialize:

@staticmethod
def _safe_hash(obj):
h = 0
if isinstance(obj, list):
for e in obj:
h ^= Serialize._safe_hash(e)
elif isinstance(obj, dict):
for k, v in obj.items():
h ^= Serialize._safe_hash(k)
h ^= Serialize._safe_hash(v)
elif hasattr(obj, "__dataclass_fields__"):
return Serialize.__hash__(obj)
else:
h ^= hash(obj)
return h

def __hash__(self):
h = 0
for name in self.__dataclass_fields__:
field = getattr(self, name)
h ^= self._safe_hash(field)
return h

@classmethod
def from_dict(cls, data):
res = {}
Expand All @@ -15,16 +39,31 @@ def from_dict(cls, data):
res[k] = unhex(res[k])
elif v.type == datetime:
res[k] = datetime.fromtimestamp(res[k])
elif isinstance(v.type, UnionType):
if res[k] and v.type.__args__[0] == datetime:
res[k] = datetime.fromtimestamp(res[k])
return cls(**res)

def to_dict(self):
@staticmethod
def _to_dict(val, recursive):
if isinstance(val, bytes):
return enhex(val)
elif isinstance(val, datetime):
return val.timestamp()
elif isinstance(val, Serialize) and recursive:
return val.to_dict()
elif isinstance(val, dict) and recursive:
res = {}
for k, v in val.items():
res[k] = Serialize._to_dict(v, recursive)
return res
else:
return val

def to_dict(self, recursive=True):
res = {}
for k, v in self.__dataclass_fields__.items():
res[k] = getattr(self, k)
if v.type == bytes:
res[k] = enhex(res[k])
elif v.type == datetime:
res[k] = res[k].timestamp()
res[k] = self._to_dict(getattr(self, k), recursive)
return res

@classmethod
Expand Down
12 changes: 12 additions & 0 deletions cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ def json_key_value(str):
except ValueError:
return key, value

def make_mqtt_req(command_type, args):
cmd = { "commandType": command_type }
for path, value in args:
path = path.split(".")
obj = cmd
for step in path[:-1]:
obj = obj.setdefault(step, {})

obj[path[-1]] = value

return cmd


class EnumType(click.ParamType):
def __init__(self, enum):
Expand Down
47 changes: 47 additions & 0 deletions libflagship/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,53 @@ def parse(cls, p):
def pack(self):
return struct.pack("B", self)

class MqttPrintEvent(enum.IntEnum):
ZZ_MQTT_PRINT_EVENT_IDLE = 0x00 # unknown
ZZ_MQTT_PRINT_EVENT_PRINTING = 0x01 # unknown (guess: print job starting)
ZZ_MQTT_PRINT_EVENT_PAUSED = 0x02 # print paused
ZZ_MQTT_PRINT_EVENT_STOPPED = 0x03 # print stopped
ZZ_MQTT_PRINT_EVENT_COMPLETED = 0x04 # print completed
ZZ_MQTT_PRINT_EVENT_LEVELING = 0x05 # printer needs leveling
ZZ_MQTT_PRINT_EVENT_DOWNLOADING = 0x06 # unknown
ZZ_MQTT_PRINT_EVENT_LEVEL_HEATING = 0x07 # heating for leveling
ZZ_MQTT_PRINT_EVENT_HEATING = 0x08 # heating for printing
ZZ_MQTT_PRINT_EVENT_PREHEAT = 0x09 # unknown
ZZ_MQTT_PRINT_EVENT_PRINT_DL = 0x0a # unknown

@classmethod
def parse(cls, p):
return cls(struct.unpack("B", p[:1])[0]), p[1:]

def pack(self):
return struct.pack("B", self)

class MqttMarlinEvent(enum.IntEnum):
ZZ_MQTT_MARLIN_ALERT_HALTED = 0x01 #
ZZ_MQTT_MARLIN_ALERT_OFFLINE = 0x02 #
ZZ_MQTT_MARLIN_ALERT_NOZZEL_HEAT = 0x03 #
ZZ_MQTT_MARLIN_ALERT_PANEL_HEAT = 0x04 #
ZZ_MQTT_MARLIN_ALERT_PRINT = 0x05 #
ZZ_MQTT_MARLIN_ALERT_BLANKING = 0x06 #
ZZ_MQTT_MARLIN_ALERT_BLOCKING = 0x07 #
ZZ_MQTT_MARLIN_ALERT_LEVELING = 0x08 #
ZZ_MQTT_MARLIN_COMM_ERR = 0x09 #
ZZ_MQTT_LBOARD_COMM_ERR = 0x0a #
ZZ_MQTT_NOZZLE_HIGH_TEMP = 0x0b #
ZZ_MQTT_HEATBED_HIGH_TEMP = 0x0c #
ZZ_MQTT_HEATBED_MOS1 = 0x0d #
ZZ_MQTT_LEVEL_FAILED = 0x0e #
ZZ_MQTT_HEATBED_MOS2 = 0x0f #
ZZ_MQTT_NOZZLE_LOW_TEMP = 0x10 #
ZZ_MQTT_MARLIN_AUTO_PAUSE = 0x11 # M600 encountered
ZZ_MQTT_PRINT_DL_FAILED = 0x12 # print failed to download

@classmethod
def parse(cls, p):
return cls(struct.unpack("B", p[:1])[0]), p[1:]

def pack(self):
return struct.pack("B", self)

@dataclass
class _MqttMsg:
signature : bytes = field(repr=False, kw_only=True, default=b'MA') # Signature: 'MA'
Expand Down
8 changes: 4 additions & 4 deletions libflagship/ppppapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def rx_drw(self, index, data):
# drop any packets we have already recieved
if self.rx_ctr > index:
if self.max_age_warn and (self.rx_ctr - index > self.max_age_warn):
log.warn(f"Dropping old packet: index {index} while expecting {self.rx_ctr}.")
log.warning(f"Dropping old packet: index {index} while expecting {self.rx_ctr}.")
return

# record packet in queue
Expand Down Expand Up @@ -298,7 +298,7 @@ def process(self, msg):

if msg.type == Type.CLOSE:
log.error("CLOSE")
raise ConnectionResetError
raise ConnectionResetError("Printer rejected connection")

elif msg.type == Type.REPORT_SESSION_READY:
pkt = PktSessionReady(
Expand Down Expand Up @@ -352,7 +352,7 @@ def recv(self, timeout=None):
if self.dumper:
self.dumper.rx(data, self.addr)
msg = Message.parse(data)[0]
log.debug(f"RX <-- {str(msg)[:128]}")
# log.debug(f"RX <-- {str(msg)[:128]}")
return msg

def send(self, pkt, addr=None):
Expand All @@ -363,7 +363,7 @@ def send(self, pkt, addr=None):
if self.dumper:
self.dumper.tx(resp, self.addr)
msg = Message.parse(resp)[0]
log.debug(f"TX --> {str(msg)[:128]}")
# log.debug(f"TX --> {str(msg)[:128]}")
self.sock.sendto(resp, addr or self.addr)

def send_xzyh(self, data, cmd, chan=0, unk0=0, unk1=0, sign_code=0, unk3=0, dev_type=0, block=True):
Expand Down
6 changes: 3 additions & 3 deletions libflagship/seccode.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ def gen_check_code_v1(base_code, seed):


def gen_rand_seed(mac):
rnd = random.randint(10000000,99999999)
rnd = random.randint(10000000, 99999999)

suffix = cal_hw_id_suffix(mac)
txtbuf = str(1000 - suffix) + str(rnd)

sec_ts = "01%d" % rnd
sec_code = hashlib.md5(txtbuf.encode()).hexdigest().upper().encode()
seed = hashlib.md5(txtbuf.encode()).hexdigest().upper().encode()

return sec_ts, sec_code
return sec_ts, seed


def create_check_code_v1(sn, mac):
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,9 @@ crcmod==1.7
tqdm==4.65.0
flask==2.3.2
flask-sock==0.6.0
Flask-Cors==3.0.10
user-agents==2.2.0
json-rpc==1.14.0
psutil==5.9.5
distro==1.8.0
py-cpuinfo==9.0.0
64 changes: 64 additions & 0 deletions specification/mqtt.stf
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,67 @@ enum MqttMsgType

#
ZZ_MQTT_CMD_ALEXA_MSG = 0xbb8


enum MqttPrintEvent
# unknown
ZZ_MQTT_PRINT_EVENT_IDLE = 0x00
# unknown (guess: print job starting)
ZZ_MQTT_PRINT_EVENT_PRINTING = 0x01
# print paused
ZZ_MQTT_PRINT_EVENT_PAUSED = 0x02
# print stopped
ZZ_MQTT_PRINT_EVENT_STOPPED = 0x03
# print completed
ZZ_MQTT_PRINT_EVENT_COMPLETED = 0x04
# printer needs leveling
ZZ_MQTT_PRINT_EVENT_LEVELING = 0x05
# unknown
ZZ_MQTT_PRINT_EVENT_DOWNLOADING = 0x06
# heating for leveling
ZZ_MQTT_PRINT_EVENT_LEVEL_HEATING = 0x07
# heating for printing
ZZ_MQTT_PRINT_EVENT_HEATING = 0x08
# unknown
ZZ_MQTT_PRINT_EVENT_PREHEAT = 0x09
# unknown
ZZ_MQTT_PRINT_EVENT_PRINT_DL = 0x0a


enum MqttMarlinEvent
#
ZZ_MQTT_MARLIN_ALERT_HALTED = 0x01
#
ZZ_MQTT_MARLIN_ALERT_OFFLINE = 0x02
#
ZZ_MQTT_MARLIN_ALERT_NOZZEL_HEAT = 0x03
#
ZZ_MQTT_MARLIN_ALERT_PANEL_HEAT = 0x04
#
ZZ_MQTT_MARLIN_ALERT_PRINT = 0x05
#
ZZ_MQTT_MARLIN_ALERT_BLANKING = 0x06
#
ZZ_MQTT_MARLIN_ALERT_BLOCKING = 0x07
#
ZZ_MQTT_MARLIN_ALERT_LEVELING = 0x08
#
ZZ_MQTT_MARLIN_COMM_ERR = 0x09
#
ZZ_MQTT_LBOARD_COMM_ERR = 0x0a
#
ZZ_MQTT_NOZZLE_HIGH_TEMP = 0x0b
#
ZZ_MQTT_HEATBED_HIGH_TEMP = 0x0c
#
ZZ_MQTT_HEATBED_MOS1 = 0x0d
#
ZZ_MQTT_LEVEL_FAILED = 0x0e
#
ZZ_MQTT_HEATBED_MOS2 = 0x0f
#
ZZ_MQTT_NOZZLE_LOW_TEMP = 0x10
# M600 encountered
ZZ_MQTT_MARLIN_AUTO_PAUSE = 0x11
# print failed to download
ZZ_MQTT_PRINT_DL_FAILED = 0x12
2 changes: 1 addition & 1 deletion static/tabs/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</div>
<div class="card-body">
<form
action="{{ url_for('app_api_ankerctl_file_upload') }}"
action="{{ url_for('ankerctl.app_api_ankerctl_file_upload') }}"
method="POST"
enctype="multipart/form-data"
id="gcode-upload-form"
Expand Down
4 changes: 2 additions & 2 deletions static/tabs/setup.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<div class="row g-3">
<div class="col-lg-6">
<form
action="{{ url_for('app_api_ankerctl_config_upload') }}"
action="{{ url_for('ankerctl.app_api_ankerctl_config_upload') }}"
method="POST"
enctype="multipart/form-data"
class="mb-3"
Expand Down Expand Up @@ -53,7 +53,7 @@
<button id="reload" type="button" class="btn btn-danger"
data-bs-toggle="modal" data-bs-target="#popupModal"
data-msg="Reloading ankerctl..."
data-href="{{ url_for('app_api_ankerctl_server_reload') }}">
data-href="{{ url_for('ankerctl.app_api_ankerctl_server_reload') }}">
{{ macro.bi_icon("bootstrap-reboot", "Reload Services") }}
</button>
</div>
Expand Down
Loading