goep_client.c (c411eed24b26cfa41e73a317dc86256703f78556) | goep_client.c (808cabbb633637da6056b1971ad7d92eae2c49bc) |
---|---|
1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 59 unchanged lines hidden (view full) --- 68static uint16_t goep_client_cid; 69static btstack_linked_list_t goep_clients; 70 71static goep_client_t * goep_client_sdp_active; 72static uint8_t goep_client_sdp_query_attribute_value[30]; 73static const unsigned int goep_client_sdp_query_attribute_value_buffer_size = sizeof(goep_client_sdp_query_attribute_value); 74static uint8_t goep_packet_buffer[150]; 75 | 1/* 2 * Copyright (C) 2014 BlueKitchen GmbH 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 8 * 1. Redistributions of source code must retain the above copyright --- 59 unchanged lines hidden (view full) --- 68static uint16_t goep_client_cid; 69static btstack_linked_list_t goep_clients; 70 71static goep_client_t * goep_client_sdp_active; 72static uint8_t goep_client_sdp_query_attribute_value[30]; 73static const unsigned int goep_client_sdp_query_attribute_value_buffer_size = sizeof(goep_client_sdp_query_attribute_value); 74static uint8_t goep_packet_buffer[150]; 75 |
76// singleton instance 77static goep_client_t goep_client_singleton; 78 79#ifdef ENABLE_GOEP_L2CAP 80// singleton instance 81static uint8_t goep_client_singleton_ertm_buffer[1000]; 82static l2cap_ertm_config_t goep_client_singleton_ertm_config = { 83 1, // ertm mandatory 84 2, // max transmit, some tests require > 1 85 2000, 86 12000, 87 512, // l2cap ertm mtu 88 2, 89 2, 90 1, // 16-bit FCS 91}; 92#endif 93 | |
94static inline void goep_client_emit_connected_event(goep_client_t * goep_client, uint8_t status){ 95 uint8_t event[15]; 96 int pos = 0; 97 event[pos++] = HCI_EVENT_GOEP_META; 98 pos++; // skip len 99 event[pos++] = GOEP_SUBEVENT_CONNECTION_OPENED; 100 little_endian_store_16(event, pos, goep_client->cid); 101 pos+=2; --- 335 unchanged lines hidden (view full) --- 437 } else { 438 rfcomm_reserve_packet_buffer(); 439 } 440 // store opcode for parsing of response 441 goep_client->obex_opcode = opcode; 442} 443 444void goep_client_init(void){ | 76static inline void goep_client_emit_connected_event(goep_client_t * goep_client, uint8_t status){ 77 uint8_t event[15]; 78 int pos = 0; 79 event[pos++] = HCI_EVENT_GOEP_META; 80 pos++; // skip len 81 event[pos++] = GOEP_SUBEVENT_CONNECTION_OPENED; 82 little_endian_store_16(event, pos, goep_client->cid); 83 pos+=2; --- 335 unchanged lines hidden (view full) --- 419 } else { 420 rfcomm_reserve_packet_buffer(); 421 } 422 // store opcode for parsing of response 423 goep_client->obex_opcode = opcode; 424} 425 426void goep_client_init(void){ |
445 goep_client_singleton.state = GOEP_CLIENT_INIT; | |
446} 447 448void goep_client_deinit(void){ 449 goep_clients = NULL; 450 goep_client_cid = 0; | 427} 428 429void goep_client_deinit(void){ 430 goep_clients = NULL; 431 goep_client_cid = 0; |
451 memset(&goep_client_singleton, 0, sizeof(goep_client_t)); | |
452 memset(goep_client_sdp_query_attribute_value, 0, sizeof(goep_client_sdp_query_attribute_value)); 453 memset(goep_packet_buffer, 0, sizeof(goep_packet_buffer)); 454} 455 456static void geop_client_sdp_query_start(void * context){ 457 uint16_t goep_cid = (uint16_t)(uintptr_t) context; 458 goep_client_t * goep_client = goep_client_for_cid(goep_cid); 459 if (context != NULL){ --- 73 unchanged lines hidden (view full) --- 533 goep_client->l2cap_psm = l2cap_psm; 534 535 *out_cid = goep_client->cid; 536 537 return goep_client_start_connect(goep_client); 538} 539#endif 540 | 432 memset(goep_client_sdp_query_attribute_value, 0, sizeof(goep_client_sdp_query_attribute_value)); 433 memset(goep_packet_buffer, 0, sizeof(goep_packet_buffer)); 434} 435 436static void geop_client_sdp_query_start(void * context){ 437 uint16_t goep_cid = (uint16_t)(uintptr_t) context; 438 goep_client_t * goep_client = goep_client_for_cid(goep_cid); 439 if (context != NULL){ --- 73 unchanged lines hidden (view full) --- 513 goep_client->l2cap_psm = l2cap_psm; 514 515 *out_cid = goep_client->cid; 516 517 return goep_client_start_connect(goep_client); 518} 519#endif 520 |
541uint8_t goep_client_create_connection(btstack_packet_handler_t handler, bd_addr_t addr, uint16_t uuid, uint16_t * out_cid){ 542 goep_client_t * goep_client = &goep_client_singleton; 543 if (goep_client->state != GOEP_CLIENT_INIT) { 544 return BTSTACK_MEMORY_ALLOC_FAILED; 545 } 546#ifdef ENABLE_GOEP_L2CAP 547 return goep_client_connect(goep_client, &goep_client_singleton_ertm_config, goep_client_singleton_ertm_buffer, 548 sizeof(goep_client_singleton_ertm_buffer), handler, addr, uuid, 0, out_cid); 549#else 550 return goep_client_connect(goep_client,NULL, NULL, 0, handler, addr, uuid, 0, out_cid); 551#endif 552} 553 | |
554uint32_t goep_client_get_pbap_supported_features(uint16_t goep_cid){ 555 goep_client_t * goep_client = goep_client_for_cid(goep_cid); 556 if (goep_client == NULL){ 557 return PBAP_FEATURES_NOT_PRESENT; 558 } 559 return goep_client->profile_supported_features; 560} 561 --- 329 unchanged lines hidden --- | 521uint32_t goep_client_get_pbap_supported_features(uint16_t goep_cid){ 522 goep_client_t * goep_client = goep_client_for_cid(goep_cid); 523 if (goep_client == NULL){ 524 return PBAP_FEATURES_NOT_PRESENT; 525 } 526 return goep_client->profile_supported_features; 527} 528 --- 329 unchanged lines hidden --- |