hfp_ag: fix sending outgoing cmds in chunks

This commit is contained in:
Matthias Ringwald 2016-03-30 10:21:23 +02:00
parent 497fcc1c7f
commit aba39421e9

View File

@ -388,6 +388,7 @@ static int hfp_ag_cmd_via_generator(uint16_t cid, hfp_connection_t * hfp_connect
// assumes: can send now == true // assumes: can send now == true
// assumes: num segments > 0 // assumes: num segments > 0
// assumes: individual segments are smaller than MTU
rfcomm_reserve_packet_buffer(); rfcomm_reserve_packet_buffer();
int mtu = rfcomm_get_max_frame_size(cid); int mtu = rfcomm_get_max_frame_size(cid);
uint8_t * data = rfcomm_get_outgoing_buffer(); uint8_t * data = rfcomm_get_outgoing_buffer();
@ -395,11 +396,11 @@ static int hfp_ag_cmd_via_generator(uint16_t cid, hfp_connection_t * hfp_connect
int segment = start_segment; int segment = start_segment;
while (segment < num_segments){ while (segment < num_segments){
int segment_len = get_segment_len(hfp_connection, segment); int segment_len = get_segment_len(hfp_connection, segment);
if (offset + segment_len <= mtu){ if (offset + segment_len > mtu) break;
store_segment(hfp_connection, segment, data+offset); // append segement
offset += segment_len; store_segment(hfp_connection, segment, data+offset);
segment++; offset += segment_len;
} segment++;
} }
rfcomm_send_prepared(cid, offset); rfcomm_send_prepared(cid, offset);
return segment; return segment;