1 /**************************************************************************/
2 /* */
3 /* Copyright (c) Microsoft Corporation. All rights reserved. */
4 /* */
5 /* This software is licensed under the Microsoft Software License */
6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */
7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */
8 /* and in the root directory of this software. */
9 /* */
10 /**************************************************************************/
11
12
13 /**************************************************************************/
14 /**************************************************************************/
15 /** */
16 /** USBX Component */
17 /** */
18 /** Pictbridge Application */
19 /** */
20 /**************************************************************************/
21 /**************************************************************************/
22
23
24 /* Include necessary system files. */
25
26 #define UX_SOURCE_CODE
27
28 #include "ux_api.h"
29 #include "ux_pictbridge.h"
30 #include "ux_device_class_pima.h"
31
32
33 /**************************************************************************/
34 /* */
35 /* FUNCTION RELEASE */
36 /* */
37 /* _ux_pictbridge_dpsclient_api_configure_print_service */
38 /* PORTABLE C */
39 /* 6.1.12 */
40 /* */
41 /* AUTHOR */
42 /* */
43 /* Chaoqiong Xiao, Microsoft Corporation */
44 /* */
45 /* DESCRIPTION */
46 /* */
47 /* This function creates the tag lines of the configure_print_service */
48 /* request and then output the request to the printer. */
49 /* */
50 /* INPUT */
51 /* */
52 /* pictbridge Pictbridge instance */
53 /* */
54 /* OUTPUT */
55 /* */
56 /* Completion Status */
57 /* */
58 /* CALLS */
59 /* */
60 /* _ux_utility_delay_ms Delay ms */
61 /* */
62 /* CALLED BY */
63 /* */
64 /* _ux_pictbridge_dpshost_object_get */
65 /* */
66 /* RELEASE HISTORY */
67 /* */
68 /* DATE NAME DESCRIPTION */
69 /* */
70 /* 05-19-2020 Chaoqiong Xiao Initial Version 6.0 */
71 /* 09-30-2020 Chaoqiong Xiao Modified comment(s), */
72 /* used UX prefix to refer to */
73 /* TX symbols instead of using */
74 /* them directly, */
75 /* resulting in version 6.1 */
76 /* 07-29-2022 Chaoqiong Xiao Modified comment(s), */
77 /* used macros for RTOS calls, */
78 /* resulting in version 6.1.12 */
79 /* */
80 /**************************************************************************/
_ux_pictbridge_dpsclient_api_configure_print_service(UX_PICTBRIDGE * pictbridge)81 UINT _ux_pictbridge_dpsclient_api_configure_print_service(UX_PICTBRIDGE *pictbridge)
82 {
83 UINT status;
84 ULONG actual_flags;
85
86 /* Wait for 100 ms to give a chance to the host to send a request before the client can post a Object Added event. */
87 _ux_utility_delay_ms(100);
88
89 /* Prepare the object for configure print service. */
90 status = _ux_pictbridge_dpsclient_input_object_prepare(pictbridge, UX_PICTBRIDGE_OR_CONFIGURE_PRINT_SERVICE, 0, 0);
91
92 /* Check status. */
93 if (status != UX_SUCCESS)
94 return(status);
95
96 /* We should wait for the host to send a script with the response. */
97 status = _ux_system_event_flags_get(&pictbridge -> ux_pictbridge_event_flags_group, UX_PICTBRIDGE_EVENT_FLAG_CONFIGURE_PRINT_SERVICE,
98 UX_AND_CLEAR, &actual_flags, UX_PICTBRIDGE_EVENT_TIMEOUT);
99
100 /* Check status. */
101 if (status != UX_SUCCESS)
102 return(UX_EVENT_ERROR);
103
104 /* Ensure the flag was set. */
105 if (actual_flags & UX_PICTBRIDGE_EVENT_FLAG_CONFIGURE_PRINT_SERVICE)
106
107 /* Return completion status. */
108 return(UX_SUCCESS);
109
110 else
111
112 /* Return completion status. */
113 return(UX_ERROR);
114 }
115
116