Bambu-Research-Group / RFID-Tag-Guide

Instructions on how to read out the bambulab nfc tags
731 stars 68 forks source link

Filament Internal Code #42

Open spuder opened 1 month ago

spuder commented 1 month ago

Dumping the mqtt messages I've identified an internal code that is used for filaments

Screenshot 2024-10-22 at 19 06 36

WolfWithSword has documented most of these internal filament codes

https://github.com/WolfwithSword/ha-bambulab/blob/78cc6bda14ef0f82e74b59afc745cc5534c01a5e/custom_components/bambu_lab/pybambu/const.py#L40-L62

    "default": "Unknown",
    "GFU99": "Generic TPU",
    "GFS99": "Generic PVA",
    "GFL98": "Generic PLA-CF",
    "GFL99": "Generic PLA",
    "GFG99": "Generic PETG",
    "GFC99": "Generic PC",
    "GFN98": "Generic PA-CF",
    "GFN99": "Generic PA",
    "GFB98": "Generic ASA",
    "GFB99": "Generic ABS",
    "GFU01": "Bambu TPU 95A",
    "GFS00": "Bambu Support W",
    "GFS01": "Bambu Support G",
    "GFA01": "Bambu PLA Matte",
    "GFA00": "Bambu PLA Basic",
    "GFC00": "Bambu PC",
    "GFN03": "Bambu PA-CF",
    "GFB00": "Bambu ABS",
    "GFL01": "PolyTerra PLA",
    "GFL00": "PolyLite PLA"
}
CodeBradley commented 3 weeks ago

You sir are a gentleman and a scholar. How are you dumping the mqtt messages like this btw? His script looked home assistant based.

spuder commented 3 weeks ago

To get the mqtt messages use mqttx

mqttx sub -t 'device/$SERIAL_NUMBER/report' -u -P $LAN_ACCESS_CODE --mqtt-version 3.1.1 -h $IP_ADDRESS -p 8883 -l mqtts --insecure

The mqtt api is documented here:

https://github.com/Doridian/OpenBambuAPI/blob/main/mqtt.md

The 2 main endpoints are /report and /request

For example to change the filament color you would do a request with a json payload like this

{
    "print": {
        "sequence_id": "0",
        "command": "ams_filament_setting",
        "ams_id": 0,
        "tray_id": 0,
        "tray_info_idx": "GFG99",
        "tray_color": "F72323FF",
        "nozzle_temp_min": 220,
        "nozzle_temp_max": 270,
        "tray_type": "PETG",
        "setting_id": ""
    }
}
capull0 commented 2 weeks ago

you can query the Bambulab API and you will get a full filament list, also with your custom profiles. each filament has a uniq ID, also the custom profiles. You can have a look here, how you can read the filament list over the API: https://github.com/capull0/BambuAMSCtrl I coded this flask application, which will make the Bambulab RFID tags obsolete. Is working flawless since weeks.

johnhaxx commented 4 days ago

https://github.com/capull0/BambuAMSCtrl I coded this flask application, which will make the Bambulab RFID tags obsolete. Is working flawless since weeks.

Sounds amazing. I'll be following this pretty closely.

Elektroarzt commented 4 days ago

I coded this flask application, which will make the Bambulab RFID tags obsolete.

That sounds really cool! Is the following valid from your opinion to recognize custom filaments with the AMS?

Equipment

Work Flow

  1. Set new custom filament in Bambu Studio, generating a unique ID for it
  2. Have RFID reader connected to computer running flask app
  3. Flask app connects to Bambu Lab printer via API and MQTT
  4. Scan RFID chip via flask app
  5. App retrieves filament list with newly generated custom filament data
  6. App connects RFID chip data with new custom filament ID and writes back to Bambu Lab printer
  7. Stick RFID chip to custom filament spool
  8. Printer will recognize the spool from now on with all data

Is that right or is something missing? Thanks in advance for your help.

capull0 commented 4 days ago

I coded this flask application, which will make the Bambulab RFID tags obsolete.

That sounds really cool! Is the following valid from your opinion to recognize custom filaments with the AMS?

Equipment

  • Proxmark 3 easy RFID Reader
  • compatible 13.56MHz RFID chip as described in this issue
  • Any computer running your flask app

Work Flow

  1. Set new custom filament in Bambu Studio, generating a unique ID for it
  2. Have RFID reader connected to computer running flask app
  3. Flask app connects to Bambu Lab printer via API and MQTT
  4. Scan RFID chip via flask app
  5. App retrieves filament list with newly generated custom filament data
  6. App connects RFID chip data with new custom filament ID and writes back to Bambu Lab printer
  7. Stick RFID chip to custom filament spool
  8. Printer will recognize the spool from now on with all data

Is that right or is something missing? Thanks in advance for your help.

No, it's much easier. Right now i'm using a barcode reader, the module for reading RFID chips is not yet implemented. Since only the unique Filament ID and color is read from the QR-code or from the RFID tag (when implemented), you don't need a Proxmark3 and you can use any RFID tag. At the QR-code or the RFID tag (when implemented) is only the UUID and the color-code stored, everything else is configured in your Bambu Studio filament profiles.

Work Flow: prepare a filament spool:

  1. Open the Website, the Flask App offers and login to your Bambulab Cloud Account (LAN only not yet tested, but should also work). The generated token is stored and used for all requests.
  2. Open the Filament page, the app is fetching all filaments and sort all builtin and custom filament profiles.
  3. select filament and the color. Either apply this settings to your printer directly or print the generated QR-code and place it on the filament spool (later there will be a button to store the information on a RFID tag)

print with this filament:

  1. The app is reading over MQTT the AMS and is getting all empty AMS slots.
  2. If you scan a QR code (or later the RFID tag) the App will set this filament to the most left empty slot.
  3. Load the filament spool to the most left empty slot and you will see the selected filament in the device tab of Bambu Studio.
  4. Press the sync button in your prepare tab.
  5. Print
Elektroarzt commented 4 days ago

This is absolutely amazing, you rock! 🤩 Have to try that asap. Will the RFID option utilize the onboard reader of the AMS to recognize inserted spools?