l2cap.c (46788f9f6905befb62cc7edb9c8784c855a25535) l2cap.c (60a1ee1b3636b80e148491fec9284777b7193fc5)
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

--- 5236 unchanged lines hidden (view full) ---

5245
5246static void l2cap_credit_based_notify_channel_can_send(l2cap_channel_t *channel){
5247 if (!channel->waiting_for_can_send_now) return;
5248 if (channel->send_sdu_buffer) return;
5249 channel->waiting_for_can_send_now = 0;
5250 log_debug("le can send now, local_cid 0x%x", channel->local_cid);
5251 l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CAN_SEND_NOW);
5252}
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

--- 5236 unchanged lines hidden (view full) ---

5245
5246static void l2cap_credit_based_notify_channel_can_send(l2cap_channel_t *channel){
5247 if (!channel->waiting_for_can_send_now) return;
5248 if (channel->send_sdu_buffer) return;
5249 channel->waiting_for_can_send_now = 0;
5250 log_debug("le can send now, local_cid 0x%x", channel->local_cid);
5251 l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CAN_SEND_NOW);
5252}
5253
5254static uint16_t l2cap_credit_based_available_credits(uint16_t local_cid){
5255 l2cap_channel_t * channel = l2cap_get_channel_for_local_cid(local_cid);
5256 if (channel != NULL) {
5257 return channel->credits_outgoing;
5258 }
5259 return 0;
5260}
5261
5253#endif
5254
5255#ifdef ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
5256// 1BH2222
5257static void l2cap_cbm_emit_incoming_connection(l2cap_channel_t *channel) {
5258 log_info("le incoming addr_type %u, addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x, remote_mtu %u",
5259 channel->address_type, bd_addr_to_str(channel->address), channel->con_handle, channel->psm, channel->local_cid, channel->remote_cid, channel->remote_mtu);
5260 uint8_t event[19];

--- 219 unchanged lines hidden (view full) ---

5480 }
5481
5482 return ERROR_CODE_SUCCESS;
5483}
5484
5485uint8_t l2cap_cbm_provide_credits(uint16_t local_cid, uint16_t credits){
5486 return l2cap_credit_based_provide_credits(local_cid, credits);
5487}
5262#endif
5263
5264#ifdef ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
5265// 1BH2222
5266static void l2cap_cbm_emit_incoming_connection(l2cap_channel_t *channel) {
5267 log_info("le incoming addr_type %u, addr %s handle 0x%x psm 0x%x local_cid 0x%x remote_cid 0x%x, remote_mtu %u",
5268 channel->address_type, bd_addr_to_str(channel->address), channel->con_handle, channel->psm, channel->local_cid, channel->remote_cid, channel->remote_mtu);
5269 uint8_t event[19];

--- 219 unchanged lines hidden (view full) ---

5489 }
5490
5491 return ERROR_CODE_SUCCESS;
5492}
5493
5494uint8_t l2cap_cbm_provide_credits(uint16_t local_cid, uint16_t credits){
5495 return l2cap_credit_based_provide_credits(local_cid, credits);
5496}
5497
5498uint16_t l2cap_cbm_available_credits(uint16_t local_cid){
5499 return l2cap_credit_based_available_credits(local_cid);
5500}
5488#endif
5489
5490#ifdef ENABLE_L2CAP_ENHANCED_CREDIT_BASED_FLOW_CONTROL_MODE
5491
5492uint8_t l2cap_ecbm_register_service(btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t min_remote_mtu,
5493 gap_security_level_t security_level, bool authorization_required) {
5494
5495 // check for already registered psm

--- 218 unchanged lines hidden (view full) ---

5714
5715 l2cap_run();
5716 return ERROR_CODE_SUCCESS;
5717}
5718
5719uint8_t l2cap_ecbm_provide_credits(uint16_t local_cid, uint16_t credits){
5720 return l2cap_credit_based_provide_credits(local_cid, credits);
5721}
5501#endif
5502
5503#ifdef ENABLE_L2CAP_ENHANCED_CREDIT_BASED_FLOW_CONTROL_MODE
5504
5505uint8_t l2cap_ecbm_register_service(btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t min_remote_mtu,
5506 gap_security_level_t security_level, bool authorization_required) {
5507
5508 // check for already registered psm

--- 218 unchanged lines hidden (view full) ---

5727
5728 l2cap_run();
5729 return ERROR_CODE_SUCCESS;
5730}
5731
5732uint8_t l2cap_ecbm_provide_credits(uint16_t local_cid, uint16_t credits){
5733 return l2cap_credit_based_provide_credits(local_cid, credits);
5734}
5735
5736uint16_t l2cap_ecbm_available_credits(uint16_t local_cid){
5737 return l2cap_credit_based_available_credits(local_cid);
5738}
5722#endif
5723
5724#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
5725// @deprecated - please use l2cap_ertm_create_channel
5726uint8_t l2cap_create_ertm_channel(btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm,
5727 l2cap_ertm_config_t * ertm_contig, uint8_t * buffer, uint32_t size, uint16_t * out_local_cid){
5728 log_error("deprecated - please use l2cap_ertm_create_channel");
5729 return l2cap_ertm_create_channel(packet_handler, address, psm, ertm_contig, buffer, size, out_local_cid);

--- 135 unchanged lines hidden ---
5739#endif
5740
5741#ifdef ENABLE_L2CAP_ENHANCED_RETRANSMISSION_MODE
5742// @deprecated - please use l2cap_ertm_create_channel
5743uint8_t l2cap_create_ertm_channel(btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm,
5744 l2cap_ertm_config_t * ertm_contig, uint8_t * buffer, uint32_t size, uint16_t * out_local_cid){
5745 log_error("deprecated - please use l2cap_ertm_create_channel");
5746 return l2cap_ertm_create_channel(packet_handler, address, psm, ertm_contig, buffer, size, out_local_cid);

--- 135 unchanged lines hidden ---