mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-15 23:42:52 +00:00
goep_client: make generic add header functions public
This commit is contained in:
parent
60dfc259fe
commit
c49af926f2
@ -373,31 +373,6 @@ static void goep_client_packet_init(uint16_t goep_cid, uint8_t opcode){
|
||||
context->obex_opcode = opcode;
|
||||
}
|
||||
|
||||
static void goep_client_add_variable_header(uint16_t goep_cid, uint8_t header_type, uint16_t header_data_length, const uint8_t * header_data){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[3];
|
||||
header[0] = header_type;
|
||||
big_endian_store_16(header, 1, sizeof(header) + header_data_length);
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
goep_client_packet_append(header_data, header_data_length);
|
||||
}
|
||||
|
||||
static void goep_client_add_byte_header(uint16_t goep_cid, uint8_t header_type, uint8_t value){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[2];
|
||||
header[0] = header_type;
|
||||
header[1] = value;
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
}
|
||||
|
||||
static void goep_client_add_word_header(uint16_t goep_cid, uint8_t header_type, uint32_t value){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[5];
|
||||
header[0] = header_type;
|
||||
big_endian_store_32(header, 1, value);
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
}
|
||||
|
||||
static void goep_client_packet_add_connection_id(uint16_t goep_cid){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_t * context = goep_client;
|
||||
@ -476,29 +451,11 @@ void goep_client_create_connect_request(uint16_t goep_cid, uint8_t obex_version_
|
||||
goep_client_packet_append(&fields[0], sizeof(fields));
|
||||
}
|
||||
|
||||
void goep_client_create_disconnect_request(uint16_t goep_cid){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_DISCONNECT);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_create_get_request(uint16_t goep_cid){
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_GET | OBEX_OPCODE_FINAL_BIT_MASK);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_create_abort_request(uint16_t goep_cid){
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_ABORT);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_add_header_srm_enable(uint16_t goep_cid){
|
||||
goep_client_t * context = goep_client;
|
||||
if (!context->l2cap_psm) return;
|
||||
// SRM was added in GOEP v2, which uses L2CAP
|
||||
goep_client_add_byte_header(goep_cid, OBEX_HEADER_SINGLE_RESPONSE_MODE, OBEX_SRM_ENABLE);
|
||||
}
|
||||
|
||||
void goep_client_create_set_path_request(uint16_t goep_cid, uint8_t flags){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_SETPATH);
|
||||
@ -509,6 +466,49 @@ void goep_client_create_set_path_request(uint16_t goep_cid, uint8_t flags){
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_create_abort_request(uint16_t goep_cid){
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_ABORT);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_create_disconnect_request(uint16_t goep_cid){
|
||||
UNUSED(goep_cid);
|
||||
goep_client_packet_init(goep_cid, OBEX_OPCODE_DISCONNECT);
|
||||
goep_client_packet_add_connection_id(goep_cid);
|
||||
}
|
||||
|
||||
void goep_client_add_variable_header(uint16_t goep_cid, uint8_t header_type, uint16_t header_data_length, const uint8_t * header_data){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[3];
|
||||
header[0] = header_type;
|
||||
big_endian_store_16(header, 1, sizeof(header) + header_data_length);
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
goep_client_packet_append(header_data, header_data_length);
|
||||
}
|
||||
|
||||
void goep_client_add_byte_header(uint16_t goep_cid, uint8_t header_type, uint8_t value){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[2];
|
||||
header[0] = header_type;
|
||||
header[1] = value;
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
}
|
||||
|
||||
void goep_client_add_word_header(uint16_t goep_cid, uint8_t header_type, uint32_t value){
|
||||
UNUSED(goep_cid);
|
||||
uint8_t header[5];
|
||||
header[0] = header_type;
|
||||
big_endian_store_32(header, 1, value);
|
||||
goep_client_packet_append(&header[0], sizeof(header));
|
||||
}
|
||||
|
||||
void goep_client_add_header_srm_enable(uint16_t goep_cid){
|
||||
goep_client_t * context = goep_client;
|
||||
if (!context->l2cap_psm) return;
|
||||
// SRM was added in GOEP v2, which uses L2CAP
|
||||
goep_client_add_byte_header(goep_cid, OBEX_HEADER_SINGLE_RESPONSE_MODE, OBEX_SRM_ENABLE);
|
||||
}
|
||||
|
||||
void goep_client_add_header_target(uint16_t goep_cid, uint16_t length, const uint8_t * target){
|
||||
goep_client_add_variable_header(goep_cid, OBEX_HEADER_TARGET, length, target);
|
||||
}
|
||||
|
@ -149,6 +149,30 @@ void goep_client_create_set_path_request(uint16_t goep_cid, uint8_t flags);
|
||||
// not implemented yet
|
||||
// void goep_client_create_put(uint16_t goep_cid);
|
||||
|
||||
/**
|
||||
* @brief Add header with single byte value (8 bit)
|
||||
* @param gope_cid
|
||||
* @param header_type
|
||||
* @param value
|
||||
*/
|
||||
void goep_client_add_byte_header(uint16_t goep_cid, uint8_t header_type, uint8_t value);
|
||||
|
||||
/**
|
||||
* @brief Add header with word value (32 bit)
|
||||
* @param gope_cid
|
||||
* @param header_type
|
||||
* @param value
|
||||
*/
|
||||
void goep_client_add_word_header(uint16_t goep_cid, uint8_t header_type, uint32_t value);
|
||||
|
||||
/**
|
||||
* @brief Add header with variable size
|
||||
* @param gope_cid
|
||||
* @param header_type
|
||||
* @param value
|
||||
*/
|
||||
void goep_client_add_variable_header(uint16_t goep_cid, uint8_t header_type, uint16_t header_data_length, const uint8_t * header_data);
|
||||
|
||||
/**
|
||||
* @brief Add name header to current request
|
||||
* @param goep_cid
|
||||
|
Loading…
x
Reference in New Issue
Block a user