Print Workflow
This workflow describes how an application uploads print data and starts printing.
Sequence
- Register and start event notifications.
- Upload at least one set of print data.
- Send the start-print command.
- Wait for the print-start result notification.
Starting event notifications and uploading print data both return before the final print result is available.
Retry Guidance
- If the start-print command fails, wait one second and retry.
- Limit the total retry period to ten seconds.
- After the start command succeeds, wait up to ten seconds for the print-start result.
Result Handling
| Result | Application behavior |
|---|---|
| Start accepted, result success | Enter the printable state |
| Start accepted, result failure | Show the failure message and stop the flow |
| No result within ten seconds | Report a start-result timeout |
| Data upload failed | Stop the flow and report the upload error |
C Example
void on_event(const char *event_json, void *user_data)
{
(void)event_json;
(void)user_data;
/* Update the print workflow state. */
}
ti_set_event_callback(cli, on_event, NULL);
ti_start_event_subscription(cli);
if (ti_set_print_data(cli, print_data, print_data_len, 0) != TI_OK) {
return;
}
int rc = ti_print_control(cli, "START_PRINT");
if (rc != TI_OK) {
/* Wait one second and retry within the total timeout. */
}
Integration Notes
- Use uppercase command keys such as
"START_PRINT". - Do not treat print-data upload success as proof that the device is ready.
- Use the print-start result notification as the final startup result.
- Event callbacks must not block for long periods.