NaitLee / Cat-Printer

Application supporting Bluetooth thermal “Cat Printers”, for everyone!
GNU General Public License v3.0
379 stars 38 forks source link

Way to interact with the android app via python? #95

Open diggedypomme opened 9 months ago

diggedypomme commented 9 months ago

The android version of this works great via the android phone app, but via termux and running the python, the bluetooth doesn't work (due to termux, not this repo). I am running a separate python app and want to print out - is there a setup that can be used to interact and push images to the backend of the android app without using the web front end? I was trying to get it working via post to /set but I'm struggling with it, so any advice would be great. Thank you

NaitLee commented 9 months ago

The android app do have the server listening on 127.0.0.1:8095, so leaving the app background and doing http requests with programs will work.

You can see API endpoints in the server code, and see how to interact with it by seeking for calls to this function in frontend code.

Most api data is in JSON, posting to individual endpoints /*; sending printing data is via posting raw PBM image data to /print.

PBM image can be converted from other image with imagemagick, or be created easily by some programming.

Any language would be ok for this task. If you need any example code, just ask :)

diggedypomme commented 9 months ago

Awesome thank you. I got it working - printed my first hello message.

bgcheck commented 7 months ago

Quick and dirty example https://gist.github.com/bgcheck/09d093633ddd2349f160153d12c1bd54