xref: /btstack/src/classic/obex_srm_client.h (revision e3bb42c259e0e2b54fb29afff9b1ba86c21b3610)
15fe90018SMatthias Ringwald /*
25fe90018SMatthias Ringwald  * Copyright (C) 2024 BlueKitchen GmbH
35fe90018SMatthias Ringwald  *
45fe90018SMatthias Ringwald  * Redistribution and use in source and binary forms, with or without
55fe90018SMatthias Ringwald  * modification, are permitted provided that the following conditions
65fe90018SMatthias Ringwald  * are met:
75fe90018SMatthias Ringwald  *
85fe90018SMatthias Ringwald  * 1. Redistributions of source code must retain the above copyright
95fe90018SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer.
105fe90018SMatthias Ringwald  * 2. Redistributions in binary form must reproduce the above copyright
115fe90018SMatthias Ringwald  *    notice, this list of conditions and the following disclaimer in the
125fe90018SMatthias Ringwald  *    documentation and/or other materials provided with the distribution.
135fe90018SMatthias Ringwald  * 3. Neither the name of the copyright holders nor the names of
145fe90018SMatthias Ringwald  *    contributors may be used to endorse or promote products derived
155fe90018SMatthias Ringwald  *    from this software without specific prior written permission.
165fe90018SMatthias Ringwald  * 4. Any redistribution, use, or modification is done solely for
175fe90018SMatthias Ringwald  *    personal benefit and not for any commercial purpose or for
185fe90018SMatthias Ringwald  *    monetary gain.
195fe90018SMatthias Ringwald  *
205fe90018SMatthias Ringwald  * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS
215fe90018SMatthias Ringwald  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
225fe90018SMatthias Ringwald  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
235fe90018SMatthias Ringwald  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN
245fe90018SMatthias Ringwald  * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
255fe90018SMatthias Ringwald  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
265fe90018SMatthias Ringwald  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
275fe90018SMatthias Ringwald  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
285fe90018SMatthias Ringwald  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
295fe90018SMatthias Ringwald  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
305fe90018SMatthias Ringwald  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
315fe90018SMatthias Ringwald  * SUCH DAMAGE.
325fe90018SMatthias Ringwald  *
335fe90018SMatthias Ringwald  * Please inquire about commercial licensing options at
345fe90018SMatthias Ringwald  * [email protected]
355fe90018SMatthias Ringwald  *
365fe90018SMatthias Ringwald  */
375fe90018SMatthias Ringwald 
385fe90018SMatthias Ringwald #ifndef OBEX_SRM_CLIENT_H
395fe90018SMatthias Ringwald #define OBEX_SRM_CLIENT_H
405fe90018SMatthias Ringwald 
415fe90018SMatthias Ringwald #include <stdint.h>
4230f40b4aSMatthias Ringwald #include "btstack_bool.h"
435fe90018SMatthias Ringwald 
445fe90018SMatthias Ringwald #if defined __cplusplus
455fe90018SMatthias Ringwald extern "C" {
465fe90018SMatthias Ringwald #endif
475fe90018SMatthias Ringwald 
485fe90018SMatthias Ringwald typedef enum {
495fe90018SMatthias Ringwald     OBEX_SRM_CLIENT_STATE_DISABLED,
505fe90018SMatthias Ringwald     OBEX_SRM_CLIENT_STATE_W4_CONFIRM,
515fe90018SMatthias Ringwald     OBEX_SRM_CLIENT_STATE_ENABLED_BUT_WAITING,
525fe90018SMatthias Ringwald     OBEX_SRM_CLIENT_STATE_ENABLED
535fe90018SMatthias Ringwald } obex_srm_client_state_t;
545fe90018SMatthias Ringwald 
555fe90018SMatthias Ringwald typedef struct {
565fe90018SMatthias Ringwald     obex_srm_client_state_t srm_state;
575fe90018SMatthias Ringwald 
58*e3bb42c2SMatthias Ringwald     bool srmp_waiting;
59*e3bb42c2SMatthias Ringwald 
605fe90018SMatthias Ringwald     uint8_t srm_value;
615fe90018SMatthias Ringwald     uint8_t srmp_value;
625fe90018SMatthias Ringwald } obex_srm_client_t;
635fe90018SMatthias Ringwald 
645fe90018SMatthias Ringwald /**
6530f40b4aSMatthias Ringwald  * Init SRM to disabled state
6630f40b4aSMatthias Ringwald  * SRM needs to be disabled for each new GET/PUT operation
675fe90018SMatthias Ringwald  * @param obex_srm
685fe90018SMatthias Ringwald  */
695fe90018SMatthias Ringwald void obex_srm_client_init(obex_srm_client_t * obex_srm);
705fe90018SMatthias Ringwald 
715fe90018SMatthias Ringwald /**
72*e3bb42c2SMatthias Ringwald  * Control SRMP stata
73*e3bb42c2SMatthias Ringwald  * While waiting, SRMP header is added, effectively disabling SRM
74*e3bb42c2SMatthias Ringwald  * @param obex_srm
75*e3bb42c2SMatthias Ringwald  * @param waiting
76*e3bb42c2SMatthias Ringwald  */
77*e3bb42c2SMatthias Ringwald void obex_srm_client_set_waiting(obex_srm_client_t * obex_srm, bool waiting);
78*e3bb42c2SMatthias Ringwald 
79*e3bb42c2SMatthias Ringwald /**
8030f40b4aSMatthias Ringwald  * Reset SRM/SRMP fields
8130f40b4aSMatthias Ringwald  * Needs to be called before parsing response
8230f40b4aSMatthias Ringwald  * @param obex_srm
8330f40b4aSMatthias Ringwald  */
8430f40b4aSMatthias Ringwald void obex_srm_client_reset_fields(obex_srm_client_t * obex_srm);
8530f40b4aSMatthias Ringwald 
8630f40b4aSMatthias Ringwald /**
875fe90018SMatthias Ringwald  * Update SRM state based on SRM headers
885fe90018SMatthias Ringwald  * @param obex_srm
895fe90018SMatthias Ringwald  */
905fe90018SMatthias Ringwald void obex_srm_client_handle_headers(obex_srm_client_t *obex_srm);
915fe90018SMatthias Ringwald 
925fe90018SMatthias Ringwald /**
9330f40b4aSMatthias Ringwald  * Check if SRM is active
9430f40b4aSMatthias Ringwald  * @param obex_srm
9530f40b4aSMatthias Ringwald  */
9630f40b4aSMatthias Ringwald bool obex_srm_client_is_srm_active(obex_srm_client_t *obex_srm);
9730f40b4aSMatthias Ringwald 
9830f40b4aSMatthias Ringwald /**
995fe90018SMatthias Ringwald  * Add SRM headers if
1005fe90018SMatthias Ringwald  * @param obex_srm
1015fe90018SMatthias Ringwald  * @param goep_cid
1025fe90018SMatthias Ringwald  */
1035fe90018SMatthias Ringwald void obex_srm_client_prepare_header(obex_srm_client_t *obex_srm, uint16_t goep_cid);
1045fe90018SMatthias Ringwald 
1055fe90018SMatthias Ringwald #if defined __cplusplus
1065fe90018SMatthias Ringwald }
1075fe90018SMatthias Ringwald #endif
1085fe90018SMatthias Ringwald 
1095fe90018SMatthias Ringwald #endif
110