use underscores instead of camel case

This commit is contained in:
matthias.ringwald@gmail.com 2013-11-01 13:37:55 +00:00
parent 20f37ec36c
commit c358e0b077
3 changed files with 28 additions and 38 deletions

View File

@ -210,10 +210,8 @@ extern "C" {
// data: event(8), len(8), record nr(16), attribute id(16), attribute value(var)
#define SDP_QUERY_ATTRIBUTE_VALUE 0x93
// data: event(8), total nr(16), current nr(16), service record handle(32)
#define SDP_QUERY_SERVICE_RECORD_HANDLE 0x94
//#define SDP_PARSER_ATTRIBUTE_VALUE 0x94
//#define SDP_PARSER_COMPLETE 0x95
// not provided by daemon, only used for internal testing
#define SDP_QUERY_SERVICE_RECORD_HANDLE 0x94
// last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors

View File

@ -80,12 +80,12 @@ void sdp_client_handle_done(uint8_t status){
sdp_parser_handle_done(status);
}
void parse_ServiceRecordHandleList(uint8_t* packet, uint16_t total_count, uint16_t current_count){
void parse_service_record_handle_list(uint8_t* packet, uint16_t total_count, uint16_t current_count){
sdp_parser_handle_service_search(packet, total_count, current_count);
}
// TODO: inline if not needed (des(des))
void parse_AttributeLists(uint8_t* packet, uint16_t length){
void parse_attribute_lists(uint8_t* packet, uint16_t length){
sdp_parser_handle_chunk(packet, length);
}
@ -132,7 +132,7 @@ void sdp_client_service_search(bd_addr_t remote, uint8_t * des_serviceSearchPatt
}
static void tryToSend(uint16_t channel){
static void try_to_send(uint16_t channel){
if (sdp_client_state != W2_SEND) return;
@ -152,11 +152,11 @@ static void tryToSend(uint16_t channel){
request_len = setup_ServiceSearchAttributeRequest(data);
break;
default:
log_info("SDP Client tryToSend :: PDU ID invalid. %u", PDU_ID);
log_info("SDP Client try_to_send :: PDU ID invalid. %u", PDU_ID);
return;
}
printf("tryToSend channel %x, size %u\n", channel, request_len);
printf("try_to_send channel %x, size %u\n", channel, request_len);
int err = l2cap_send_prepared(channel, request_len);
switch (err){
@ -175,7 +175,7 @@ static void tryToSend(uint16_t channel){
}
}
static void parse_ServiceSearchResponse(uint8_t* packet){
static void parse_service_search_response(uint8_t* packet){
uint16_t offset = 3;
uint16_t parameterLength = READ_NET_16(packet,offset);
offset+=2;
@ -191,7 +191,7 @@ static void parse_ServiceSearchResponse(uint8_t* packet){
return;
}
parse_ServiceRecordHandleList(packet+offset, totalServiceRecordCount, currentServiceRecordCount);
parse_service_record_handle_list(packet+offset, totalServiceRecordCount, currentServiceRecordCount);
offset+=(currentServiceRecordCount * 4);
@ -210,7 +210,7 @@ static void parse_ServiceSearchResponse(uint8_t* packet){
}
}
static void parse_ServiceAttributeResponse(uint8_t* packet){
static void parse_service_attribute_response(uint8_t* packet){
uint16_t offset = 3;
uint16_t parameterLength = READ_NET_16(packet,offset);
offset+=2;
@ -225,7 +225,7 @@ static void parse_ServiceAttributeResponse(uint8_t* packet){
}
// AttributeLists
parse_AttributeLists(packet+offset, attributeListByteCount);
parse_attribute_lists(packet+offset, attributeListByteCount);
offset+=attributeListByteCount;
continuationStateLen = packet[offset];
@ -244,7 +244,7 @@ static void parse_ServiceAttributeResponse(uint8_t* packet){
}
static void parse_ServiceSearchAttributeResponse(uint8_t* packet){
static void parse_service_search_attribute_response(uint8_t* packet){
uint16_t offset = 3;
uint16_t parameterLength = READ_NET_16(packet,offset);
offset+=2;
@ -258,7 +258,7 @@ static void parse_ServiceSearchAttributeResponse(uint8_t* packet){
}
// AttributeLists
parse_AttributeLists(packet+offset, attributeListByteCount);
parse_attribute_lists(packet+offset, attributeListByteCount);
offset+=attributeListByteCount;
continuationStateLen = packet[offset];
@ -276,7 +276,7 @@ static void parse_ServiceSearchAttributeResponse(uint8_t* packet){
}
}
static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
uint16_t handle;
@ -303,13 +303,13 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
log_info("SDP Client :: PDU ID. %u ,%u", PDU_ID, packet[0]);
switch (PDU_ID){
case SDP_ServiceSearchResponse:
parse_ServiceSearchResponse(packet);
parse_service_search_response(packet);
break;
case SDP_ServiceAttributeResponse:
parse_ServiceAttributeResponse(packet);
parse_service_attribute_response(packet);
break;
case SDP_ServiceSearchAttributeResponse:
parse_ServiceSearchAttributeResponse(packet);
parse_service_search_attribute_response(packet);
break;
default:
log_error("SDP Client :: PDU ID invalid. %u ,%u", PDU_ID, packet[0]);
@ -325,7 +325,7 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
}
// prepare next request and send
sdp_client_state = W2_SEND;
tryToSend(sdp_cid);
try_to_send(sdp_cid);
return;
}
@ -349,11 +349,11 @@ static void sdp_packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *p
printf("Connected, cid %x, mtu %u.\n\r", sdp_cid, mtu);
sdp_client_state = W2_SEND;
tryToSend(sdp_cid);
try_to_send(sdp_cid);
break;
case L2CAP_EVENT_CREDITS:
case DAEMON_EVENT_HCI_PACKET_SENT:
tryToSend(sdp_cid);
try_to_send(sdp_cid);
break;
case L2CAP_EVENT_CHANNEL_CLOSED:
printf("Channel closed.\n\r");

View File

@ -62,7 +62,7 @@ static uint16_t attribute_value_size;
static uint32_t record_handle;
static int record_counter = 0;
static void (*sdp_query_rfcomm_callback)(sdp_query_event_t * event);
static void (*sdp_query_callback)(sdp_query_event_t * event);
// Low level parser
static de_state_t de_header_state;
@ -106,9 +106,9 @@ int de_state_size(uint8_t eventByte, de_state_t *de_state){
void dummy_notify(sdp_query_event_t* event){}
void sdp_parser_register_callback(void (*sdp_callback)(sdp_query_event_t* event)){
sdp_query_rfcomm_callback = dummy_notify;
sdp_query_callback = dummy_notify;
if (sdp_callback != NULL){
sdp_query_rfcomm_callback = sdp_callback;
sdp_query_callback = sdp_callback;
}
}
@ -117,10 +117,6 @@ void parse(uint8_t eventByte){
list_offset++;
record_offset++;
static int b = 0;
printf("0x%02x, ", eventByte);
if (++b==16) { printf("\n"); b = 0; }
// printf(" parse BYTE_RECEIVED %02x\n", eventByte);
switch(state){
case GET_LIST_LENGTH:
@ -131,8 +127,6 @@ void parse(uint8_t eventByte){
record_counter = 0;
state = GET_RECORD_LENGTH;
printf("\n -- new record starts --\n"); b = 0;
break;
case GET_RECORD_LENGTH:
@ -175,7 +169,7 @@ void parse(uint8_t eventByte){
attribute_bytes_delivered++,
eventByte
};
(*sdp_query_rfcomm_callback)((sdp_query_event_t*)&attribute_value_event);
(*sdp_query_callback)((sdp_query_event_t*)&attribute_value_event);
}
if (!de_state_size(eventByte, &de_header_state)) break;
@ -196,7 +190,7 @@ void parse(uint8_t eventByte){
eventByte
};
(*sdp_query_rfcomm_callback)((sdp_query_event_t*)&attribute_value_event);
(*sdp_query_callback)((sdp_query_event_t*)&attribute_value_event);
}
// printf("paser: attribute_bytes_received %u, attribute_value_size %u\n", attribute_bytes_received, attribute_value_size);
@ -214,14 +208,13 @@ void parse(uint8_t eventByte){
record_counter++;
state = GET_RECORD_LENGTH;
// printf("parser: END_OF_RECORD\n\n");
printf("\n -- new record starts --\n %u %u %u", list_offset, list_size, record_offset); b = 0;
break;
}
list_offset = 0;
de_state_init(&de_header_state);
state = GET_LIST_LENGTH;
record_counter = 0;
printf("parser: END_OF_RECORD & DONE\n\n\n");
// printf("parser: END_OF_RECORD & DONE\n\n\n");
break;
default:
break;
@ -262,14 +255,13 @@ void sdp_parser_handle_service_search(uint8_t * data, uint16_t total_count, uint
for (i=0;i<record_handle_count;i++){
record_handle = READ_NET_32(data, i*4);
record_counter++;
printf("handle[%d/%d] = %d\n", i, record_handle_count, record_handle);
sdp_query_service_record_handle_event_t service_record_handle_event = {
SDP_QUERY_SERVICE_RECORD_HANDLE,
total_count,
record_counter,
record_handle
};
(*sdp_query_rfcomm_callback)((sdp_query_event_t*)&service_record_handle_event);
(*sdp_query_callback)((sdp_query_event_t*)&service_record_handle_event);
}
}
@ -279,5 +271,5 @@ void sdp_parser_handle_done(uint8_t status){
SDP_QUERY_COMPLETE,
status
};
(*sdp_query_rfcomm_callback)((sdp_query_event_t*)&complete_event);
(*sdp_query_callback)((sdp_query_event_t*)&complete_event);
}