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> 42*30f40b4aSMatthias 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 585fe90018SMatthias Ringwald uint8_t srm_value; 595fe90018SMatthias Ringwald uint8_t srmp_value; 605fe90018SMatthias Ringwald } obex_srm_client_t; 615fe90018SMatthias Ringwald 625fe90018SMatthias Ringwald /** 63*30f40b4aSMatthias Ringwald * Init SRM to disabled state 64*30f40b4aSMatthias Ringwald * SRM needs to be disabled for each new GET/PUT operation 655fe90018SMatthias Ringwald * @param obex_srm 665fe90018SMatthias Ringwald */ 675fe90018SMatthias Ringwald void obex_srm_client_init(obex_srm_client_t * obex_srm); 685fe90018SMatthias Ringwald 695fe90018SMatthias Ringwald /** 70*30f40b4aSMatthias Ringwald * Reset SRM/SRMP fields 71*30f40b4aSMatthias Ringwald * Needs to be called before parsing response 72*30f40b4aSMatthias Ringwald * @param obex_srm 73*30f40b4aSMatthias Ringwald */ 74*30f40b4aSMatthias Ringwald void obex_srm_client_reset_fields(obex_srm_client_t * obex_srm); 75*30f40b4aSMatthias Ringwald 76*30f40b4aSMatthias Ringwald /** 775fe90018SMatthias Ringwald * Update SRM state based on SRM headers 785fe90018SMatthias Ringwald * @param obex_srm 795fe90018SMatthias Ringwald */ 805fe90018SMatthias Ringwald void obex_srm_client_handle_headers(obex_srm_client_t *obex_srm); 815fe90018SMatthias Ringwald 825fe90018SMatthias Ringwald /** 83*30f40b4aSMatthias Ringwald * Check if SRM is active 84*30f40b4aSMatthias Ringwald * @param obex_srm 85*30f40b4aSMatthias Ringwald */ 86*30f40b4aSMatthias Ringwald bool obex_srm_client_is_srm_active(obex_srm_client_t *obex_srm); 87*30f40b4aSMatthias Ringwald 88*30f40b4aSMatthias Ringwald /** 895fe90018SMatthias Ringwald * Add SRM headers if 905fe90018SMatthias Ringwald * @param obex_srm 915fe90018SMatthias Ringwald * @param goep_cid 925fe90018SMatthias Ringwald */ 935fe90018SMatthias Ringwald void obex_srm_client_prepare_header(obex_srm_client_t *obex_srm, uint16_t goep_cid); 945fe90018SMatthias Ringwald 955fe90018SMatthias Ringwald #if defined __cplusplus 965fe90018SMatthias Ringwald } 975fe90018SMatthias Ringwald #endif 985fe90018SMatthias Ringwald 995fe90018SMatthias Ringwald #endif 100