Changeset 374 for asp3_tinet_ecnl_rx/trunk/btstack
- Timestamp:
- Apr 5, 2019, 9:26:53 PM (5 years ago)
- Location:
- asp3_tinet_ecnl_rx/trunk/btstack
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/hci_cmds.h
r337 r374 404 404 * @param status 405 405 */ 406 #define SDP_ QUERY_COMPLETE0x91406 #define SDP_EVENT_QUERY_COMPLETE 0x91 407 407 408 408 // data: event(8), len(8), rfcomm channel(8), name(var) … … 422 422 * @param attribute_value 423 423 */ 424 #define SDP_ QUERY_ATTRIBUTE_VALUE0x93424 #define SDP_EVENT_QUERY_ATTRIBUTE_VALUE 0x93 425 425 426 426 // not provided by daemon, only used for internal testing -
asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/sdp_util.h
r337 r374 68 68 // UNIVERSAL ATTRIBUTE DEFINITIONS 69 69 #define SDP_ServiceRecordHandle 0x0000 70 #define SDP_ServiceClassIDList0x000170 #define BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST 0x0001 71 71 #define SDP_ServiceRecordState 0x0002 72 72 #define SDP_ServiceID 0x0003 73 #define SDP_ProtocolDescriptorList0x000473 #define BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST 0x0004 74 74 #define SDP_BrowseGroupList 0x0005 75 75 #define SDP_LanguageBaseAttributeIDList 0x0006 … … 93 93 #define SDP_RFCOMMProtocol 0x0003 94 94 #define SDP_OBEXProtocol 0x0008 95 #define SDP_L2CAPProtocol0x010096 #define SDP_BNEPProtocol0x000f95 #define BLUETOOTH_PROTOCOL_L2CAP 0x0100 96 #define BLUETOOTH_PROTOCOL_BNEP 0x000f 97 97 98 98 // OFFSETS FOR LOCALIZED ATTRIBUTES - SDP_LanguageBaseAttributeIDList -
asp3_tinet_ecnl_rx/trunk/btstack/include/btstack/utils.h
r337 r374 90 90 91 91 // helper for BT little endian format 92 #define READ_BT_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8))93 #define READ_BT_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16))94 #define READ_BT_32( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16) | (((uint32_t) buffer[pos+3])) << 24)92 #define little_endian_read_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8)) 93 #define little_endian_read_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16)) 94 #define little_endian_read_32( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16) | (((uint32_t) buffer[pos+3])) << 24) 95 95 96 96 // helper for SDP big endian format 97 #define READ_NET_16( buffer, pos) ( ((uint16_t) buffer[pos+1]) | (((uint16_t)buffer[pos ]) << 8))98 #define READ_NET_32( buffer, pos) ( ((uint32_t) buffer[pos+3]) | (((uint32_t)buffer[pos+2]) << 8) | (((uint32_t)buffer[pos+1]) << 16) | (((uint32_t) buffer[pos])) << 24)97 #define big_endian_read_16( buffer, pos) ( ((uint16_t) buffer[pos+1]) | (((uint16_t)buffer[pos ]) << 8)) 98 #define big_endian_read_32( buffer, pos) ( ((uint32_t) buffer[pos+3]) | (((uint32_t)buffer[pos+2]) << 8) | (((uint32_t)buffer[pos+1]) << 16) | (((uint32_t) buffer[pos])) << 24) 99 99 100 100 // HCI CMD OGF/OCF … … 103 103 104 104 // check if command complete event for given command 105 #define COMMAND_COMPLETE_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_COMPLETE && READ_BT_16(event,3) == cmd.opcode)106 #define COMMAND_STATUS_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_STATUS && READ_BT_16(event,4) == cmd.opcode)105 #define HCI_EVENT_IS_COMMAND_COMPLETE(event,cmd) ( event[0] == HCI_EVENT_COMMAND_COMPLETE && little_endian_read_16(event,3) == cmd.opcode) 106 #define COMMAND_STATUS_EVENT(event,cmd) ( event[0] == HCI_EVENT_COMMAND_STATUS && little_endian_read_16(event,4) == cmd.opcode) 107 107 108 108 // Code+Len=2, Pkts+Opcode=3; total=5 … … 110 110 111 111 // ACL Packet 112 #define READ_ACL_CONNECTION_HANDLE( buffer ) ( READ_BT_16(buffer,0) & 0x0fff)112 #define READ_ACL_CONNECTION_HANDLE( buffer ) ( little_endian_read_16(buffer,0) & 0x0fff) 113 113 #define READ_ACL_FLAGS( buffer ) ( buffer[1] >> 4 ) 114 #define READ_ACL_LENGTH( buffer ) ( READ_BT_16(buffer, 2))114 #define READ_ACL_LENGTH( buffer ) (little_endian_read_16(buffer, 2)) 115 115 116 116 // L2CAP Packet 117 #define READ_L2CAP_LENGTH(buffer) ( READ_BT_16(buffer, 4))118 #define READ_L2CAP_CHANNEL_ID(buffer) ( READ_BT_16(buffer, 6))117 #define READ_L2CAP_LENGTH(buffer) ( little_endian_read_16(buffer, 4)) 118 #define READ_L2CAP_CHANNEL_ID(buffer) ( little_endian_read_16(buffer, 6)) 119 119 120 void bt_store_16(uint8_t *buffer, uint16_t pos, uint16_t value);121 void bt_store_32(uint8_t *buffer, uint16_t pos, uint32_t value);122 void bt_flip_addr(bd_addr_t dest, bd_addr_t src);120 void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value); 121 void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value); 122 void reverse_bd_addr(bd_addr_t src, bd_addr_t dest); 123 123 124 124 void net_store_16(uint8_t *buffer, uint16_t pos, uint16_t value); -
asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.c
r337 r374 84 84 event[1] = sizeof(event) - 2; 85 85 event[2] = status; 86 bt_store_16(event, 3, channel->l2cap_cid);87 bt_store_16(event, 5, channel->uuid_source);88 bt_store_16(event, 7, channel->uuid_dest);89 bt_store_16(event, 9, channel->max_frame_size);86 little_endian_store_16(event, 3, channel->l2cap_cid); 87 little_endian_store_16(event, 5, channel->uuid_source); 88 little_endian_store_16(event, 7, channel->uuid_dest); 89 little_endian_store_16(event, 9, channel->max_frame_size); 90 90 BD_ADDR_COPY(&event[11], channel->remote_addr); 91 91 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 101 101 event[0] = BNEP_EVENT_CHANNEL_TIMEOUT; 102 102 event[1] = sizeof(event) - 2; 103 bt_store_16(event, 2, channel->l2cap_cid);104 bt_store_16(event, 4, channel->uuid_source);105 bt_store_16(event, 6, channel->uuid_dest);103 little_endian_store_16(event, 2, channel->l2cap_cid); 104 little_endian_store_16(event, 4, channel->uuid_source); 105 little_endian_store_16(event, 6, channel->uuid_dest); 106 106 BD_ADDR_COPY(&event[8], channel->remote_addr); 107 107 event[14] = channel->state; … … 118 118 event[0] = BNEP_EVENT_CHANNEL_CLOSED; 119 119 event[1] = sizeof(event) - 2; 120 bt_store_16(event, 2, channel->l2cap_cid);121 bt_store_16(event, 4, channel->uuid_source);122 bt_store_16(event, 6, channel->uuid_dest);120 little_endian_store_16(event, 2, channel->l2cap_cid); 121 little_endian_store_16(event, 4, channel->uuid_source); 122 little_endian_store_16(event, 6, channel->uuid_dest); 123 123 BD_ADDR_COPY(&event[8], channel->remote_addr); 124 124 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 133 133 event[0] = BNEP_EVENT_READY_TO_SEND; 134 134 event[1] = sizeof(event) - 2; 135 bt_store_16(event, 2, channel->l2cap_cid);135 little_endian_store_16(event, 2, channel->l2cap_cid); 136 136 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 137 137 (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); … … 464 464 BD_ADDR_COPY(addr_source, &packet[pos]); 465 465 pos += sizeof(bd_addr_t); 466 network_protocol_type = READ_NET_16(packet, pos);466 network_protocol_type = big_endian_read_16(packet, pos); 467 467 pos += sizeof(uint16_t); 468 468 … … 475 475 } 476 476 /* The "real" network protocol type is 4 bytes ahead in a VLAN packet */ 477 network_protocol_type = READ_NET_16(packet, pos + 2);477 network_protocol_type = big_endian_read_16(packet, pos + 2); 478 478 } 479 479 … … 808 808 /* Check source and destination UUIDs for valid combinations */ 809 809 if (response_code == BNEP_RESP_SETUP_SUCCESS) { 810 channel->uuid_dest = READ_NET_16(packet, 2 + uuid_offset);811 channel->uuid_source = READ_NET_16(packet, 2 + uuid_offset + uuid_size);812 813 if ((channel->uuid_dest != B NEP_UUID_PANU) &&814 (channel->uuid_dest != B NEP_UUID_NAP) &&815 (channel->uuid_dest != B NEP_UUID_GN)) {810 channel->uuid_dest = big_endian_read_16(packet, 2 + uuid_offset); 811 channel->uuid_source = big_endian_read_16(packet, 2 + uuid_offset + uuid_size); 812 813 if ((channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU) && 814 (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_NAP) && 815 (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_GN)) { 816 816 log_error("BNEP_CONNECTION_REQUEST: Invalid destination service UUID: %04x", channel->uuid_dest); 817 817 channel->uuid_dest = 0; 818 818 } 819 if ((channel->uuid_source != B NEP_UUID_PANU) &&820 (channel->uuid_source != B NEP_UUID_NAP) &&821 (channel->uuid_source != B NEP_UUID_GN)) {819 if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && 820 (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_NAP) && 821 (channel->uuid_source != BLUETOOTH_SERVICE_CLASS_GN)) { 822 822 log_error("BNEP_CONNECTION_REQUEST: Invalid source service UUID: %04x", channel->uuid_source); 823 823 channel->uuid_source = 0; … … 829 829 response_code = BNEP_RESP_SETUP_INVALID_DEST_UUID; 830 830 } else 831 if ((channel->uuid_source != B NEP_UUID_PANU) && (channel->uuid_dest != BNEP_UUID_PANU)) {831 if ((channel->uuid_source != BLUETOOTH_SERVICE_CLASS_PANU) && (channel->uuid_dest != BLUETOOTH_SERVICE_CLASS_PANU)) { 832 832 response_code = BNEP_RESP_SETUP_INVALID_SOURCE_UUID; 833 833 } … … 857 857 } 858 858 859 response_code = READ_NET_16(packet, 1);859 response_code = big_endian_read_16(packet, 1); 860 860 861 861 if (response_code == BNEP_RESP_SETUP_SUCCESS) { … … 882 882 } 883 883 884 list_length = READ_NET_16(packet, 1);884 list_length = big_endian_read_16(packet, 1); 885 885 /* Sanity check packet size again with known package size */ 886 886 if (size < 3 + list_length) { … … 903 903 /* There is still enough space, copy the filters to our filter list */ 904 904 for (i = 0; i < list_length / (2 * 2); i ++) { 905 channel->net_filter[channel->net_filter_count].range_start = READ_NET_16(packet, 1 + 2 + i * 4);906 channel->net_filter[channel->net_filter_count].range_end = READ_NET_16(packet, 1 + 2 + i * 4 + 2);905 channel->net_filter[channel->net_filter_count].range_start = big_endian_read_16(packet, 1 + 2 + i * 4); 906 channel->net_filter[channel->net_filter_count].range_end = big_endian_read_16(packet, 1 + 2 + i * 4 + 2); 907 907 if (channel->net_filter[channel->net_filter_count].range_start > channel->net_filter[channel->net_filter_count].range_end) { 908 908 /* Invalid filter range, ignore this filter rule */ … … 945 945 } 946 946 947 response_code = READ_NET_16(packet, 1);947 response_code = big_endian_read_16(packet, 1); 948 948 949 949 if (response_code == BNEP_RESP_FILTER_SUCCESS) { … … 966 966 } 967 967 968 list_length = READ_NET_16(packet, 1);968 list_length = big_endian_read_16(packet, 1); 969 969 /* Sanity check packet size again with known package size */ 970 970 if (size < 3 + list_length) { … … 1032 1032 } 1033 1033 1034 response_code = READ_NET_16(packet, 1);1034 response_code = big_endian_read_16(packet, 1); 1035 1035 1036 1036 if (response_code == BNEP_RESP_FILTER_SUCCESS) { … … 1169 1169 case L2CAP_EVENT_INCOMING_CONNECTION: 1170 1170 /* L2CAP event data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16) */ 1171 bt_flip_addr(event_addr, &packet[2]);1172 con_handle = READ_BT_16(packet, 8);1173 psm = READ_BT_16(packet, 10);1174 l2cap_cid = READ_BT_16(packet, 12);1171 reverse_bd_addr(&packet[2], event_addr); 1172 con_handle = little_endian_read_16(packet, 8); 1173 psm = little_endian_read_16(packet, 10); 1174 l2cap_cid = little_endian_read_16(packet, 12); 1175 1175 1176 1176 if (psm != PSM_BNEP) break; … … 1211 1211 case L2CAP_EVENT_CHANNEL_OPENED: 1212 1212 /* Check if the l2cap channel has been opened for PSM_BNEP */ 1213 if ( READ_BT_16(packet, 11) != PSM_BNEP) {1213 if (little_endian_read_16(packet, 11) != PSM_BNEP) { 1214 1214 break; 1215 1215 } … … 1219 1219 1220 1220 /* Get the bnep channel fpr remote address */ 1221 con_handle = READ_BT_16(packet, 9);1222 l2cap_cid = READ_BT_16(packet, 13);1223 bt_flip_addr(event_addr, &packet[3]);1221 con_handle = little_endian_read_16(packet, 9); 1222 l2cap_cid = little_endian_read_16(packet, 13); 1223 reverse_bd_addr(&packet[3], event_addr); 1224 1224 channel = bnep_channel_for_addr(&event_addr); 1225 1225 if (!channel) { … … 1252 1252 channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE; 1253 1253 bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST); 1254 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu( READ_BT_16(packet, 17));1254 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17)); 1255 1255 bnep_run(); 1256 1256 break; 1257 1257 case BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_REQUEST: 1258 1258 /* New information: channel mtu */ 1259 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu( READ_BT_16(packet, 17));1259 channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17)); 1260 1260 break; 1261 1261 default: … … 1272 1272 case L2CAP_EVENT_CHANNEL_CLOSED: 1273 1273 // data: event (8), len(8), channel (16) 1274 l2cap_cid = READ_BT_16(packet, 2);1274 l2cap_cid = little_endian_read_16(packet, 2); 1275 1275 channel = bnep_channel_for_l2cap_cid(l2cap_cid); 1276 1276 log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, channel %p", l2cap_cid, channel); … … 1331 1331 BD_ADDR_COPY(addr_source, &packet[pos]); 1332 1332 pos += sizeof(bd_addr_t); 1333 network_protocol_type = READ_NET_16(packet, pos);1333 network_protocol_type = big_endian_read_16(packet, pos); 1334 1334 pos += 2; 1335 1335 break; … … 1337 1337 BD_ADDR_COPY(addr_dest, channel->local_addr); 1338 1338 BD_ADDR_COPY(addr_source, channel->remote_addr); 1339 network_protocol_type = READ_NET_16(packet, pos);1339 network_protocol_type = big_endian_read_16(packet, pos); 1340 1340 pos += 2; 1341 1341 break; … … 1344 1344 BD_ADDR_COPY(addr_source, &packet[pos]); 1345 1345 pos += sizeof(bd_addr_t); 1346 network_protocol_type = READ_NET_16(packet, pos);1346 network_protocol_type = big_endian_read_16(packet, pos); 1347 1347 pos += 2; 1348 1348 break; … … 1351 1351 pos += sizeof(bd_addr_t); 1352 1352 BD_ADDR_COPY(addr_source, channel->remote_addr); 1353 network_protocol_type = READ_NET_16(packet, pos);1353 network_protocol_type = big_endian_read_16(packet, pos); 1354 1354 pos += 2; 1355 1355 break; … … 1563 1563 } 1564 1564 1565 channel->uuid_source = B NEP_UUID_PANU;1565 channel->uuid_source = BLUETOOTH_SERVICE_CLASS_PANU; 1566 1566 channel->uuid_dest = uuid_dest; 1567 1567 … … 1597 1597 1598 1598 /* Only alow one the three service types: PANU, NAP, GN */ 1599 if ((service_uuid != B NEP_UUID_PANU) &&1600 (service_uuid != B NEP_UUID_NAP) &&1601 (service_uuid != B NEP_UUID_GN)) {1599 if ((service_uuid != BLUETOOTH_SERVICE_CLASS_PANU) && 1600 (service_uuid != BLUETOOTH_SERVICE_CLASS_NAP) && 1601 (service_uuid != BLUETOOTH_SERVICE_CLASS_GN)) { 1602 1602 log_info("BNEP_REGISTER_SERVICE: Invalid service UUID: %04x", service_uuid); 1603 1603 return BNEP_CHANNEL_NOT_CONNECTED; -
asp3_tinet_ecnl_rx/trunk/btstack/src/bnep.h
r337 r374 72 72 73 73 /* BNEP UUIDs */ 74 #define B NEP_UUID_PANU0x111575 #define B NEP_UUID_NAP0x111676 #define B NEP_UUID_GN0x111774 #define BLUETOOTH_SERVICE_CLASS_PANU 0x1115 75 #define BLUETOOTH_SERVICE_CLASS_NAP 0x1116 76 #define BLUETOOTH_SERVICE_CLASS_GN 0x1117 77 77 78 78 /* BNEP packet types */ -
asp3_tinet_ecnl_rx/trunk/btstack/src/hci.c
r337 r374 233 233 bd_addr_t addr; 234 234 hci_connection_t * conn; 235 bt_flip_addr(addr, *(bd_addr_t *) bd_addr);235 reverse_bd_addr(*(bd_addr_t *) bd_addr, addr); 236 236 conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC); 237 237 if (conn) { … … 469 469 // copy handle_and_flags if not first fragment and update packet boundary flags to be 01 (continuing fragmnent) 470 470 if (acl_header_pos > 0){ 471 uint16_t handle_and_flags = READ_BT_16(hci_stack->hci_packet_buffer, 0);471 uint16_t handle_and_flags = little_endian_read_16(hci_stack->hci_packet_buffer, 0); 472 472 handle_and_flags = (handle_and_flags & 0xcfff) | (1 << 12); 473 bt_store_16(hci_stack->hci_packet_buffer, acl_header_pos, handle_and_flags);473 little_endian_store_16(hci_stack->hci_packet_buffer, acl_header_pos, handle_and_flags); 474 474 } 475 475 476 476 // update header len 477 bt_store_16(hci_stack->hci_packet_buffer, acl_header_pos + 2, current_acl_data_packet_length);477 little_endian_store_16(hci_stack->hci_packet_buffer, acl_header_pos + 2, current_acl_data_packet_length); 478 478 479 479 // count packet … … 640 640 conn->acl_recombination_pos = acl_length + 4; 641 641 conn->acl_recombination_length = l2cap_length; 642 bt_store_16(conn->acl_recombination_buffer, HCI_INCOMING_PRE_BUFFER_SIZE + 2, l2cap_length +4);642 little_endian_store_16(conn->acl_recombination_buffer, HCI_INCOMING_PRE_BUFFER_SIZE + 2, l2cap_length +4); 643 643 } 644 644 break; … … 793 793 // odd: waiting for event 794 794 if (packet[0] == HCI_EVENT_COMMAND_COMPLETE){ 795 uint16_t opcode = READ_BT_16(packet,3);795 uint16_t opcode = little_endian_read_16(packet,3); 796 796 if (opcode == hci_stack->last_cmd_opcode){ 797 797 command_completed = 1; … … 803 803 if (packet[0] == HCI_EVENT_COMMAND_STATUS){ 804 804 uint8_t status = packet[2]; 805 uint16_t opcode = READ_BT_16(packet,4);805 uint16_t opcode = little_endian_read_16(packet,4); 806 806 if (opcode == hci_stack->last_cmd_opcode){ 807 807 if (status){ … … 843 843 case 1: // SEND BAUD CHANGE 844 844 hci_stack->control->baudrate_cmd(hci_stack->config, ((hci_uart_config_t *)hci_stack->config)->baudrate_main, hci_stack->hci_packet_buffer); 845 hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);845 hci_stack->last_cmd_opcode = little_endian_read_16(hci_stack->hci_packet_buffer, 0); 846 846 hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]); 847 847 hci_send_cmd_packet(hci_stack->hci_packet_buffer, 3 + hci_stack->hci_packet_buffer[2]); … … 860 860 if (valid_cmd){ 861 861 int size = 3 + hci_stack->hci_packet_buffer[2]; 862 hci_stack->last_cmd_opcode = READ_BT_16(hci_stack->hci_packet_buffer, 0);862 hci_stack->last_cmd_opcode = little_endian_read_16(hci_stack->hci_packet_buffer, 0); 863 863 hci_dump_packet(HCI_COMMAND_DATA_PACKET, 0, hci_stack->hci_packet_buffer, size); 864 864 hci_stack->hci_transport->send_packet(HCI_COMMAND_DATA_PACKET, hci_stack->hci_packet_buffer, size); … … 992 992 hci_stack->num_cmd_packets = packet[2]; 993 993 994 if ( COMMAND_COMPLETE_EVENT(packet, hci_read_buffer_size)){994 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_buffer_size)){ 995 995 // from offset 5 996 996 // status 997 997 // "The HC_ACL_Data_Packet_Length return parameter will be used to determine the size of the L2CAP segments contained in ACL Data Packets" 998 hci_stack->acl_data_packet_length = READ_BT_16(packet, 6);998 hci_stack->acl_data_packet_length = little_endian_read_16(packet, 6); 999 999 // ignore: SCO data packet len (8) 1000 1000 hci_stack->acl_packets_total_num = packet[9]; … … 1010 1010 } 1011 1011 #ifdef HAVE_BLE 1012 if ( COMMAND_COMPLETE_EVENT(packet, hci_le_read_buffer_size)){1013 hci_stack->le_data_packets_length = READ_BT_16(packet, 6);1012 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_le_read_buffer_size)){ 1013 hci_stack->le_data_packets_length = little_endian_read_16(packet, 6); 1014 1014 hci_stack->le_acl_packets_total_num = packet[8]; 1015 1015 // determine usable ACL payload size … … 1021 1021 #endif 1022 1022 // Dump local address 1023 if ( COMMAND_COMPLETE_EVENT(packet, hci_read_bd_addr)) {1024 bt_flip_addr(hci_stack->local_bd_addr, &packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1]);1023 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_bd_addr)) { 1024 reverse_bd_addr(&packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE + 1], hci_stack->local_bd_addr); 1025 1025 log_info("Local Address, Status: 0x%02x: Addr: %s", 1026 1026 packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE], bd_addr_to_str(hci_stack->local_bd_addr)); 1027 1027 } 1028 if ( COMMAND_COMPLETE_EVENT(packet, hci_write_scan_enable)){1028 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_scan_enable)){ 1029 1029 hci_emit_discoverable_enabled(hci_stack->discoverable); 1030 1030 } 1031 1031 // Note: HCI init checks 1032 if ( COMMAND_COMPLETE_EVENT(packet, hci_read_local_supported_features)){1032 if (HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_read_local_supported_features)){ 1033 1033 memcpy(hci_stack->local_supported_features, &packet[OFFSET_OF_DATA_IN_COMMAND_COMPLETE+1], 8); 1034 1034 log_info("Local Supported Features: 0x%02x%02x%02x%02x%02x%02x%02x%02x", … … 1057 1057 for (i=0; i<packet[2];i++){ 1058 1058 uint16_t num_packets; 1059 handle = READ_BT_16(packet, offset);1059 handle = little_endian_read_16(packet, offset); 1060 1060 offset += 2; 1061 num_packets = READ_BT_16(packet, offset);1061 num_packets = little_endian_read_16(packet, offset); 1062 1062 offset += 2; 1063 1063 … … 1079 1079 } 1080 1080 case HCI_EVENT_CONNECTION_REQUEST: 1081 bt_flip_addr(addr, &packet[2]);1081 reverse_bd_addr(&packet[2], addr); 1082 1082 // TODO: eval COD 8-10 1083 1083 link_type = packet[11]; … … 1106 1106 case HCI_EVENT_CONNECTION_COMPLETE: 1107 1107 // Connection management 1108 bt_flip_addr(addr, &packet[5]);1108 reverse_bd_addr(&packet[5], addr); 1109 1109 log_info("Connection_complete (status=%u) %s", packet[2], bd_addr_to_str(addr)); 1110 1110 addr_type = BD_ADDR_TYPE_CLASSIC; … … 1113 1113 if (!packet[2]){ 1114 1114 conn->state = OPEN; 1115 conn->con_handle = READ_BT_16(packet, 3);1115 conn->con_handle = little_endian_read_16(packet, 3); 1116 1116 conn->bonding_flags |= BONDING_REQUEST_REMOTE_FEATURES; 1117 1117 … … 1148 1148 1149 1149 case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: 1150 handle = READ_BT_16(packet, 3);1150 handle = little_endian_read_16(packet, 3); 1151 1151 conn = hci_connection_for_handle(handle); 1152 1152 if (!conn) break; … … 1176 1176 case HCI_EVENT_LINK_KEY_NOTIFICATION: { 1177 1177 link_key_type_t link_key_type; 1178 bt_flip_addr(addr, &packet[2]);1178 reverse_bd_addr(&packet[2], addr); 1179 1179 conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC); 1180 1180 if (!conn) break; … … 1201 1201 // PIN CODE REQUEST means the link key request didn't succee -> delete stored link key 1202 1202 if (!hci_stack->remote_device_db) break; 1203 bt_flip_addr(addr, &packet[2]);1203 reverse_bd_addr(&packet[2], addr); 1204 1204 hci_stack->remote_device_db->delete_link_key(&addr); 1205 1205 break; … … 1223 1223 1224 1224 case HCI_EVENT_ENCRYPTION_CHANGE: 1225 handle = READ_BT_16(packet, 3);1225 handle = little_endian_read_16(packet, 3); 1226 1226 conn = hci_connection_for_handle(handle); 1227 1227 if (!conn) break; … … 1237 1237 1238 1238 case HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: 1239 handle = READ_BT_16(packet, 3);1239 handle = little_endian_read_16(packet, 3); 1240 1240 conn = hci_connection_for_handle(handle); 1241 1241 if (!conn) break; … … 1262 1262 if (!hci_stack->remote_device_db) break; 1263 1263 if (packet[2]) break; // status not ok 1264 bt_flip_addr(addr, &packet[3]);1264 reverse_bd_addr(&packet[3], addr); 1265 1265 // fix for invalid remote names - terminate on 0xff 1266 1266 for (i=0; i<248;i++){ … … 1283 1283 int offset = 3; 1284 1284 for (i=0; i<packet[2];i++){ 1285 bt_flip_addr(addr, &packet[offset]);1285 reverse_bd_addr(&packet[offset], addr); 1286 1286 offset += 14; // 6 + 1 + 1 + 1 + 3 + 2; 1287 1287 if (hci_stack->remote_device_db->get_name(&addr, &device_name)){ … … 1308 1308 case HCI_EVENT_ROLE_CHANGE: 1309 1309 if (packet[2]) break; // status != 0 1310 handle = READ_BT_16(packet, 3);1310 handle = little_endian_read_16(packet, 3); 1311 1311 conn = hci_connection_for_handle(handle); 1312 1312 if (!conn) break; // no conn … … 1331 1331 case HCI_SUBEVENT_LE_CONNECTION_COMPLETE: 1332 1332 // Connection management 1333 bt_flip_addr(addr, &packet[8]);1333 reverse_bd_addr(&packet[8], addr); 1334 1334 addr_type = (bd_addr_type_t)packet[7]; 1335 1335 log_info("LE Connection_complete (status=%u) type %u, %s", packet[3], addr_type, bd_addr_to_str(addr)); … … 1357 1357 1358 1358 conn->state = OPEN; 1359 conn->con_handle = READ_BT_16(packet, 4);1359 conn->con_handle = little_endian_read_16(packet, 4); 1360 1360 1361 1361 // TODO: store - role, peer address type, conn_interval, conn_latency, supervision timeout, master clock … … 1370 1370 break; 1371 1371 1372 // log_info("LE buffer size: %u, count %u", READ_BT_16(packet,6), packet[8]);1372 // log_info("LE buffer size: %u, count %u", little_endian_read_16(packet,6), packet[8]); 1373 1373 1374 1374 default: … … 1389 1389 if (hci_stack->state == HCI_STATE_FALLING_ASLEEP 1390 1390 && hci_stack->substate == 1 1391 && COMMAND_COMPLETE_EVENT(packet, hci_write_scan_enable)){1391 && HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_write_scan_enable)){ 1392 1392 hci_stack->substate++; 1393 1393 } … … 1400 1400 if (!packet[2]){ 1401 1401 hci_connection_t * conn; 1402 handle = READ_BT_16(packet, 3);1402 handle = little_endian_read_16(packet, 3); 1403 1403 conn = hci_connection_for_handle(handle); 1404 1404 if (conn) { … … 1793 1793 } 1794 1794 1795 void hci_discoverable_control(uint8_t enable){1795 void gap_discoverable_control(uint8_t enable){ 1796 1796 if (enable) enable = 1; // normalize argument 1797 1797 … … 2140 2140 // create_connection? 2141 2141 if (IS_COMMAND(packet, hci_create_connection)){ 2142 bt_flip_addr(addr, &packet[3]);2142 reverse_bd_addr(&packet[3], addr); 2143 2143 log_info("Create_connection to %s", bd_addr_to_str(addr)); 2144 2144 … … 2179 2179 if (IS_COMMAND(packet, hci_delete_stored_link_key)){ 2180 2180 if (hci_stack->remote_device_db){ 2181 bt_flip_addr(addr, &packet[3]);2181 reverse_bd_addr(&packet[3], addr); 2182 2182 hci_stack->remote_device_db->delete_link_key(&addr); 2183 2183 } … … 2186 2186 if (IS_COMMAND(packet, hci_pin_code_request_negative_reply) 2187 2187 || IS_COMMAND(packet, hci_pin_code_request_reply)){ 2188 bt_flip_addr(addr, &packet[3]);2188 reverse_bd_addr(&packet[3], addr); 2189 2189 conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC); 2190 2190 if (conn){ … … 2197 2197 || IS_COMMAND(packet, hci_user_passkey_request_negative_reply) 2198 2198 || IS_COMMAND(packet, hci_user_passkey_request_reply)) { 2199 bt_flip_addr(addr, &packet[3]);2199 reverse_bd_addr(&packet[3], addr); 2200 2200 conn = hci_connection_for_bd_addr_and_type(&addr, BD_ADDR_TYPE_CLASSIC); 2201 2201 if (conn){ … … 2209 2209 } 2210 2210 if (IS_COMMAND(packet, hci_le_set_random_address)){ 2211 bt_flip_addr(hci_stack->adv_address, &packet[3]);2211 reverse_bd_addr(&packet[3], hci_stack->adv_address); 2212 2212 } 2213 2213 #endif … … 2303 2303 event[1] = sizeof(event) - 2; 2304 2304 event[2] = status; 2305 bt_store_16(event, 3, conn->con_handle);2306 bt_flip_addr(&event[5], conn->address);2305 little_endian_store_16(event, 3, conn->con_handle); 2306 reverse_bd_addr(conn->address, &event[5]); 2307 2307 event[11] = 1; // ACL connection 2308 2308 event[12] = 0; // encryption disabled … … 2317 2317 event[2] = HCI_SUBEVENT_LE_CONNECTION_COMPLETE; 2318 2318 event[3] = status; 2319 bt_store_16(event, 4, conn_handle);2319 little_endian_store_16(event, 4, conn_handle); 2320 2320 event[6] = 0; // TODO: role 2321 2321 event[7] = address_type; 2322 bt_flip_addr(&event[8], *address);2323 bt_store_16(event, 14, 0); // interval2324 bt_store_16(event, 16, 0); // latency2325 bt_store_16(event, 18, 0); // supervision timeout2322 reverse_bd_addr(*address, &event[8]); 2323 little_endian_store_16(event, 14, 0); // interval 2324 little_endian_store_16(event, 16, 0); // latency 2325 little_endian_store_16(event, 18, 0); // supervision timeout 2326 2326 event[20] = 0; // master clock accuracy 2327 2327 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 2334 2334 event[1] = sizeof(event) - 2; 2335 2335 event[2] = 0; // status = OK 2336 bt_store_16(event, 3, handle);2336 little_endian_store_16(event, 3, handle); 2337 2337 event[5] = reason; 2338 2338 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 2346 2346 event[0] = L2CAP_EVENT_TIMEOUT_CHECK; 2347 2347 event[1] = sizeof(event) - 2; 2348 bt_store_16(event, 2, conn->con_handle);2348 little_endian_store_16(event, 2, conn->con_handle); 2349 2349 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 2350 2350 hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event)); … … 2378 2378 event[2] = BTSTACK_MAJOR; 2379 2379 event[3] = BTSTACK_MINOR; 2380 bt_store_16(event, 4, BTSTACK_REVISION);2380 little_endian_store_16(event, 4, BTSTACK_REVISION); 2381 2381 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 2382 2382 hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event)); … … 2399 2399 event[1] = sizeof(event) - 2 - 1; 2400 2400 event[2] = 0; // just to be compatible with HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE 2401 bt_flip_addr(&event[3], *addr);2401 reverse_bd_addr(*addr, &event[3]); 2402 2402 memcpy(&event[9], name, 248); 2403 2403 … … 2426 2426 event[pos++] = GAP_SECURITY_LEVEL; 2427 2427 event[pos++] = sizeof(event) - 2; 2428 bt_store_16(event, 2, con_handle);2428 little_endian_store_16(event, 2, con_handle); 2429 2429 pos += 2; 2430 2430 event[pos++] = level; … … 2441 2441 event[pos++] = sizeof(event) - 2; 2442 2442 event[pos++] = status; 2443 bt_flip_addr( * (bd_addr_t *) &event[pos], address);2443 reverse_bd_addr(address, * (bd_addr_t *) &event[pos]); 2444 2444 pos += 6; 2445 2445 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); -
asp3_tinet_ecnl_rx/trunk/btstack/src/hci.h
r337 r374 234 234 235 235 // 236 #define IS_COMMAND(packet, command) ( READ_BT_16(packet,0) == command.opcode)236 #define IS_COMMAND(packet, command) (little_endian_read_16(packet,0) == command.opcode) 237 237 238 238 // data: event(8) … … 595 595 596 596 // Allows to control if device is discoverable. OFF by default. 597 void hci_discoverable_control(uint8_t enable);597 void gap_discoverable_control(uint8_t enable); 598 598 599 599 // Creates and sends HCI command packets based on a template and -
asp3_tinet_ecnl_rx/trunk/btstack/src/hci_dump.c
r337 r374 194 194 195 195 case HCI_DUMP_BLUEZ: 196 bt_store_16( (uint8_t *) &header_bluez.len, 0, 1 + len);196 little_endian_store_16( (uint8_t *) &header_bluez.len, 0, 1 + len); 197 197 header_bluez.in = in; 198 198 header_bluez.pad = 0; 199 bt_store_32( (uint8_t *) &header_bluez.ts_sec, 0, curr_time.tv_sec);200 bt_store_32( (uint8_t *) &header_bluez.ts_usec, 0, curr_time.tv_usec);199 little_endian_store_32( (uint8_t *) &header_bluez.ts_sec, 0, curr_time.tv_sec); 200 little_endian_store_32( (uint8_t *) &header_bluez.ts_usec, 0, curr_time.tv_usec); 201 201 header_bluez.packet_type = packet_type; 202 202 write (dump_file, &header_bluez, sizeof(hcidump_hdr) ); -
asp3_tinet_ecnl_rx/trunk/btstack/src/l2cap.c
r337 r374 135 135 event[1] = sizeof(event) - 2; 136 136 event[2] = status; 137 bt_flip_addr(&event[3], channel->address);138 bt_store_16(event, 9, channel->handle);139 bt_store_16(event, 11, channel->psm);140 bt_store_16(event, 13, channel->local_cid);141 bt_store_16(event, 15, channel->remote_cid);142 bt_store_16(event, 17, channel->local_mtu);143 bt_store_16(event, 19, channel->remote_mtu);144 bt_store_16(event, 21, channel->flush_timeout);137 reverse_bd_addr(channel->address, &event[3]); 138 little_endian_store_16(event, 9, channel->handle); 139 little_endian_store_16(event, 11, channel->psm); 140 little_endian_store_16(event, 13, channel->local_cid); 141 little_endian_store_16(event, 15, channel->remote_cid); 142 little_endian_store_16(event, 17, channel->local_mtu); 143 little_endian_store_16(event, 19, channel->remote_mtu); 144 little_endian_store_16(event, 21, channel->flush_timeout); 145 145 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 146 146 l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event)); … … 152 152 event[0] = L2CAP_EVENT_CHANNEL_CLOSED; 153 153 event[1] = sizeof(event) - 2; 154 bt_store_16(event, 2, channel->local_cid);154 little_endian_store_16(event, 2, channel->local_cid); 155 155 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 156 156 l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event)); … … 163 163 event[0] = L2CAP_EVENT_INCOMING_CONNECTION; 164 164 event[1] = sizeof(event) - 2; 165 bt_flip_addr(&event[2], channel->address);166 bt_store_16(event, 8, channel->handle);167 bt_store_16(event, 10, channel->psm);168 bt_store_16(event, 12, channel->local_cid);169 bt_store_16(event, 14, channel->remote_cid);165 reverse_bd_addr(channel->address, &event[2]); 166 little_endian_store_16(event, 8, channel->handle); 167 little_endian_store_16(event, 10, channel->psm); 168 little_endian_store_16(event, 12, channel->local_cid); 169 little_endian_store_16(event, 14, channel->remote_cid); 170 170 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 171 171 l2cap_dispatch(channel, HCI_EVENT_PACKET, event, sizeof(event)); … … 176 176 event[0] = L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_RESPONSE; 177 177 event[1] = 4; 178 bt_store_16(event, 2, handle);179 bt_store_16(event, 4, result);178 little_endian_store_16(event, 2, handle); 179 little_endian_store_16(event, 4, result); 180 180 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 181 181 (*packet_handler)(NULL, HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 188 188 event[1] = sizeof(event) - 2; 189 189 event[2] = status; 190 bt_store_16(event, 3, psm);190 little_endian_store_16(event, 3, psm); 191 191 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); 192 192 (*packet_handler)(connection, HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 201 201 event[0] = L2CAP_EVENT_CREDITS; 202 202 event[1] = sizeof(event) - 2; 203 bt_store_16(event, 2, channel->local_cid);203 little_endian_store_16(event, 2, channel->local_cid); 204 204 event[4] = credits; 205 205 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 412 412 413 413 // 0 - Connection handle : PB=pb : BC=00 414 bt_store_16(acl_buffer, 0, channel->handle | (pb << 12) | (0 << 14));414 little_endian_store_16(acl_buffer, 0, channel->handle | (pb << 12) | (0 << 14)); 415 415 // 2 - ACL length 416 bt_store_16(acl_buffer, 2, len + 4);416 little_endian_store_16(acl_buffer, 2, len + 4); 417 417 // 4 - L2CAP packet length 418 bt_store_16(acl_buffer, 4, len + 0);418 little_endian_store_16(acl_buffer, 4, len + 0); 419 419 // 6 - L2CAP channel DEST 420 bt_store_16(acl_buffer, 6, channel->remote_cid);420 little_endian_store_16(acl_buffer, 6, channel->remote_cid); 421 421 // send 422 422 err = hci_send_acl_packet_buffer(len+8); … … 449 449 450 450 // 0 - Connection handle : PB=pb : BC=00 451 bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));451 little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14)); 452 452 // 2 - ACL length 453 bt_store_16(acl_buffer, 2, len + 4);453 little_endian_store_16(acl_buffer, 2, len + 4); 454 454 // 4 - L2CAP packet length 455 bt_store_16(acl_buffer, 4, len + 0);455 little_endian_store_16(acl_buffer, 4, len + 0); 456 456 // 6 - L2CAP channel DEST 457 bt_store_16(acl_buffer, 6, cid);457 little_endian_store_16(acl_buffer, 6, cid); 458 458 // send 459 459 err = hci_send_acl_packet_buffer(len+8); … … 665 665 config_options[0] = 1; // MTU 666 666 config_options[1] = 2; // len param 667 bt_store_16( (uint8_t*)&config_options, 2, channel->remote_mtu);667 little_endian_store_16( (uint8_t*)&config_options, 2, channel->remote_mtu); 668 668 l2cap_send_signaling_packet(channel->handle, CONFIGURE_RESPONSE, channel->remote_sig_id, channel->remote_cid, flags, 0, 4, &config_options); 669 669 channelStateVarClearFlag(channel,L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU); … … 679 679 config_options[0] = 1; // MTU 680 680 config_options[1] = 2; // len param 681 bt_store_16( (uint8_t*)&config_options, 2, channel->local_mtu);681 little_endian_store_16( (uint8_t*)&config_options, 2, channel->local_mtu); 682 682 l2cap_send_signaling_packet(channel->handle, CONFIGURE_REQUEST, channel->local_sig_id, channel->remote_cid, 0, 4, &config_options); 683 683 l2cap_start_rtx(channel); … … 893 893 // handle connection complete events 894 894 case HCI_EVENT_CONNECTION_COMPLETE: 895 bt_flip_addr(address, &packet[5]);895 reverse_bd_addr(&packet[5], address); 896 896 if (packet[2] == 0){ 897 handle = READ_BT_16(packet, 3);897 handle = little_endian_read_16(packet, 3); 898 898 l2cap_handle_connection_success_for_addr(address, handle); 899 899 } else { … … 904 904 // handle successful create connection cancel command 905 905 case HCI_EVENT_COMMAND_COMPLETE: 906 if ( COMMAND_COMPLETE_EVENT(packet, hci_create_connection_cancel) ) {906 if ( HCI_EVENT_IS_COMMAND_COMPLETE(packet, hci_create_connection_cancel) ) { 907 907 if (packet[5] == 0){ 908 bt_flip_addr(address, &packet[6]);908 reverse_bd_addr(&packet[6], address); 909 909 // CONNECTION TERMINATED BY LOCAL HOST (0X16) 910 910 l2cap_handle_connection_failed_for_addr(address, 0x16); … … 921 921 case HCI_EVENT_DISCONNECTION_COMPLETE: 922 922 // send l2cap disconnect events for all channels on this handle and free them 923 handle = READ_BT_16(packet, 3);923 handle = little_endian_read_16(packet, 3); 924 924 linked_list_iterator_init(&it, &l2cap_channels); 925 925 while (linked_list_iterator_has_next(&it)){ … … 940 940 // HCI Connection Timeouts 941 941 case L2CAP_EVENT_TIMEOUT_CHECK: 942 handle = READ_BT_16(packet, 2);942 handle = little_endian_read_16(packet, 2); 943 943 if (hci_authentication_active_for_handle(handle)) break; 944 944 hci_con_used = 0; … … 971 971 972 972 case HCI_EVENT_READ_REMOTE_SUPPORTED_FEATURES_COMPLETE: 973 handle = READ_BT_16(packet, 3);973 handle = little_endian_read_16(packet, 3); 974 974 linked_list_iterator_init(&it, &l2cap_channels); 975 975 while (linked_list_iterator_has_next(&it)){ … … 982 982 983 983 case GAP_SECURITY_LEVEL: 984 handle = READ_BT_16(packet, 2);984 handle = little_endian_read_16(packet, 2); 985 985 log_info("l2cap - security level update"); 986 986 linked_list_iterator_init(&it, &l2cap_channels); … … 1163 1163 channel->remote_sig_id = command[L2CAP_SIGNALING_COMMAND_SIGID_OFFSET]; 1164 1164 1165 flags = READ_BT_16(command, 6);1165 flags = little_endian_read_16(command, 6); 1166 1166 if (flags & 1) { 1167 1167 channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_CONT); … … 1169 1169 1170 1170 // accept the other's configuration options 1171 end_pos = 4 + READ_BT_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);1171 end_pos = 4 + little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET); 1172 1172 pos = 8; 1173 1173 while (pos < end_pos){ … … 1180 1180 // MTU { type(8): 1, len(8):2, MTU(16) } 1181 1181 if (option_type == 1 && length == 2){ 1182 channel->remote_mtu = READ_BT_16(command, pos);1182 channel->remote_mtu = little_endian_read_16(command, pos); 1183 1183 // log_info("l2cap cid 0x%02x, remote mtu %u", channel->local_cid, channel->remote_mtu); 1184 1184 channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_RSP_MTU); … … 1186 1186 // Flush timeout { type(8):2, len(8): 2, Flush Timeout(16)} 1187 1187 if (option_type == 2 && length == 2){ 1188 channel->flush_timeout = READ_BT_16(command, pos);1188 channel->flush_timeout = little_endian_read_16(command, pos); 1189 1189 } 1190 1190 // check for unknown options … … 1237 1237 case CONNECTION_RESPONSE: 1238 1238 l2cap_stop_rtx(channel); 1239 result = READ_BT_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);1239 result = little_endian_read_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4); 1240 1240 switch (result) { 1241 1241 case 0: 1242 1242 // successful connection 1243 channel->remote_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);1243 channel->remote_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET); 1244 1244 channel->state = L2CAP_STATE_CONFIG; 1245 1245 channelStateVarSetFlag(channel, L2CAP_CHANNEL_STATE_VAR_SEND_CONF_REQ); … … 1274 1274 1275 1275 case L2CAP_STATE_CONFIG: 1276 result = READ_BT_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4);1276 result = little_endian_read_16 (command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+4); 1277 1277 switch (code) { 1278 1278 case CONFIGURE_REQUEST: … … 1353 1353 1354 1354 case CONNECTION_REQUEST: { 1355 uint16_t psm = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);1356 uint16_t source_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+2);1355 uint16_t psm = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET); 1356 uint16_t source_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET+2); 1357 1357 l2cap_handle_connection_request(handle, sig_id, psm, source_cid); 1358 1358 return; … … 1364 1364 1365 1365 case INFORMATION_REQUEST: { 1366 uint16_t infoType = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);1366 uint16_t infoType = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET); 1367 1367 l2cap_register_signaling_response(handle, code, sig_id, infoType); 1368 1368 return; … … 1375 1375 1376 1376 // Get potential destination CID 1377 dest_cid = READ_BT_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET);1377 dest_cid = little_endian_read_16(command, L2CAP_SIGNALING_COMMAND_DATA_OFFSET); 1378 1378 1379 1379 // Find channel for this sig_id and connection handle … … 1415 1415 1416 1416 // increment command_offset 1417 command_offset += L2CAP_SIGNALING_COMMAND_DATA_OFFSET + READ_BT_16(packet, command_offset + L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET);1417 command_offset += L2CAP_SIGNALING_COMMAND_DATA_OFFSET + little_endian_read_16(packet, command_offset + L2CAP_SIGNALING_COMMAND_LENGTH_OFFSET); 1418 1418 } 1419 1419 break; … … 1435 1435 switch (packet[8]){ 1436 1436 case CONNECTION_PARAMETER_UPDATE_RESPONSE: { 1437 uint16_t result = READ_BT_16(packet, 12);1437 uint16_t result = little_endian_read_16(packet, 12); 1438 1438 l2cap_emit_connection_parameter_update_response(handle, result); 1439 1439 break; … … 1450 1450 int update_parameter = 1; 1451 1451 le_connection_parameter_range_t existing_range = gap_le_get_connection_parameter_range(); 1452 uint16_t le_conn_interval_min = READ_BT_16(packet,12);1453 uint16_t le_conn_interval_max = READ_BT_16(packet,14);1454 uint16_t le_conn_latency = READ_BT_16(packet,16);1455 uint16_t le_supervision_timeout = READ_BT_16(packet,18);1452 uint16_t le_conn_interval_min = little_endian_read_16(packet,12); 1453 uint16_t le_conn_interval_max = little_endian_read_16(packet,14); 1454 uint16_t le_conn_latency = little_endian_read_16(packet,16); 1455 uint16_t le_supervision_timeout = little_endian_read_16(packet,18); 1456 1456 1457 1457 if (le_conn_interval_min < existing_range.le_conn_interval_min) update_parameter = 0; -
asp3_tinet_ecnl_rx/trunk/btstack/src/l2cap_signaling.c
r337 r374 91 91 92 92 // 0 - Connection handle : PB=pb : BC=00 93 bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));93 little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14)); 94 94 // 6 - L2CAP channel = 1 95 bt_store_16(acl_buffer, 6, cid);95 little_endian_store_16(acl_buffer, 6, cid); 96 96 // 8 - Code 97 97 acl_buffer[8] = cmd; … … 134 134 135 135 // 2 - ACL length 136 bt_store_16(acl_buffer, 2, pos - 4);136 little_endian_store_16(acl_buffer, 2, pos - 4); 137 137 // 4 - L2CAP packet length 138 bt_store_16(acl_buffer, 4, pos - 6 - 2);138 little_endian_store_16(acl_buffer, 4, pos - 6 - 2); 139 139 // 10 - L2CAP signaling parameter length 140 bt_store_16(acl_buffer, 10, pos - 12);140 little_endian_store_16(acl_buffer, 10, pos - 12); 141 141 142 142 return pos; … … 158 158 159 159 // 0 - Connection handle : PB=pb : BC=00 160 bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));160 little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14)); 161 161 // 6 - L2CAP LE Signaling channel = 5 162 bt_store_16(acl_buffer, 6, 5);162 little_endian_store_16(acl_buffer, 6, 5); 163 163 // 8 - Code 164 164 acl_buffer[8] = CONNECTION_PARAMETER_UPDATE_REQUEST; … … 166 166 acl_buffer[9] = 1; 167 167 uint16_t pos = 12; 168 bt_store_16(acl_buffer, pos, interval_min);169 pos += 2; 170 bt_store_16(acl_buffer, pos, interval_max);171 pos += 2; 172 bt_store_16(acl_buffer, pos, slave_latency);173 pos += 2; 174 bt_store_16(acl_buffer, pos, timeout_multiplier);168 little_endian_store_16(acl_buffer, pos, interval_min); 169 pos += 2; 170 little_endian_store_16(acl_buffer, pos, interval_max); 171 pos += 2; 172 little_endian_store_16(acl_buffer, pos, slave_latency); 173 pos += 2; 174 little_endian_store_16(acl_buffer, pos, timeout_multiplier); 175 175 pos += 2; 176 176 // 2 - ACL length 177 bt_store_16(acl_buffer, 2, pos - 4);177 little_endian_store_16(acl_buffer, 2, pos - 4); 178 178 // 4 - L2CAP packet length 179 bt_store_16(acl_buffer, 4, pos - 6 - 2);179 little_endian_store_16(acl_buffer, 4, pos - 6 - 2); 180 180 // 10 - L2CAP signaling parameter length 181 bt_store_16(acl_buffer, 10, pos - 12);181 little_endian_store_16(acl_buffer, 10, pos - 12); 182 182 return pos; 183 183 } … … 188 188 189 189 // 0 - Connection handle : PB=pb : BC=00 190 bt_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14));190 little_endian_store_16(acl_buffer, 0, handle | (pb << 12) | (0 << 14)); 191 191 // 6 - L2CAP LE Signaling channel = 5 192 bt_store_16(acl_buffer, 6, 5);192 little_endian_store_16(acl_buffer, 6, 5); 193 193 // 8 - Code 194 194 acl_buffer[8] = CONNECTION_PARAMETER_UPDATE_REQUEST; … … 196 196 acl_buffer[9] = 1; 197 197 uint16_t pos = 12; 198 bt_store_16(acl_buffer, pos, response);198 little_endian_store_16(acl_buffer, pos, response); 199 199 pos += 2; 200 200 // 2 - ACL length 201 bt_store_16(acl_buffer, 2, pos - 4);201 little_endian_store_16(acl_buffer, 2, pos - 4); 202 202 // 4 - L2CAP packet length 203 bt_store_16(acl_buffer, 4, pos - 6 - 2);203 little_endian_store_16(acl_buffer, 4, pos - 6 - 2); 204 204 // 10 - L2CAP signaling parameter length 205 bt_store_16(acl_buffer, 10, pos - 12);205 little_endian_store_16(acl_buffer, 10, pos - 12); 206 206 return pos; 207 207 } -
asp3_tinet_ecnl_rx/trunk/btstack/src/pan.c
r337 r374 80 80 81 81 // 0x0001 "Service Class ID List" 82 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);82 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); 83 83 attribute = de_push_sequence(service); 84 84 { … … 89 89 90 90 // 0x0004 "Protocol Descriptor List" 91 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);91 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST); 92 92 attribute = de_push_sequence(service); 93 93 { … … 95 95 { 96 96 de_add_number(l2cpProtocol, DE_UUID, DE_SIZE_16, 0x0100); 97 de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, SDP_BNEPProtocol); // l2cap psm97 de_add_number(l2cpProtocol, DE_UINT, DE_SIZE_16, BLUETOOTH_PROTOCOL_BNEP); // l2cap psm 98 98 } 99 99 de_pop_sequence(attribute, l2cpProtocol); -
asp3_tinet_ecnl_rx/trunk/btstack/src/rfcomm.c
r337 r374 136 136 event[0] = RFCOMM_EVENT_INCOMING_CONNECTION; 137 137 event[1] = sizeof(event) - 2; 138 bt_flip_addr(&event[2], channel->multiplexer->remote_addr);138 reverse_bd_addr(channel->multiplexer->remote_addr, &event[2]); 139 139 event[8] = channel->dlci >> 1; 140 bt_store_16(event, 9, channel->rfcomm_cid);140 little_endian_store_16(event, 9, channel->rfcomm_cid); 141 141 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 142 142 (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); … … 157 157 event[pos++] = sizeof(event) - 2; 158 158 event[pos++] = status; 159 bt_flip_addr(&event[pos], channel->multiplexer->remote_addr); pos += 6;160 bt_store_16(event, pos, channel->multiplexer->con_handle); pos += 2;159 reverse_bd_addr(channel->multiplexer->remote_addr, &event[pos]); pos += 6; 160 little_endian_store_16(event, pos, channel->multiplexer->con_handle); pos += 2; 161 161 event[pos++] = channel->dlci >> 1; 162 bt_store_16(event, pos, channel->rfcomm_cid); pos += 2; // channel ID163 bt_store_16(event, pos, channel->max_frame_size); pos += 2; // max frame size162 little_endian_store_16(event, pos, channel->rfcomm_cid); pos += 2; // channel ID 163 little_endian_store_16(event, pos, channel->max_frame_size); pos += 2; // max frame size 164 164 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 165 165 (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, pos); … … 175 175 event[pos++] = sizeof(event) - 2; 176 176 event[pos++] = BTSTACK_MEMORY_ALLOC_FAILED; 177 bt_flip_addr(&event[pos], *addr); pos += 6;178 bt_store_16(event, pos, 0); pos += 2;177 reverse_bd_addr(*addr, &event[pos]); pos += 6; 178 little_endian_store_16(event, pos, 0); pos += 2; 179 179 event[pos++] = server_channel; 180 bt_store_16(event, pos, 0); pos += 2; // channel ID181 bt_store_16(event, pos, 0); pos += 2; // max frame size180 little_endian_store_16(event, pos, 0); pos += 2; // channel ID 181 little_endian_store_16(event, pos, 0); pos += 2; // max frame size 182 182 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 183 183 (*app_packet_handler)(connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, pos); … … 204 204 event[0] = RFCOMM_EVENT_CHANNEL_CLOSED; 205 205 event[1] = sizeof(event) - 2; 206 bt_store_16(event, 2, channel->rfcomm_cid);206 little_endian_store_16(event, 2, channel->rfcomm_cid); 207 207 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 208 208 (*app_packet_handler)(channel->connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); … … 214 214 event[0] = RFCOMM_EVENT_CREDITS; 215 215 event[1] = sizeof(event) - 2; 216 bt_store_16(event, 2, channel->rfcomm_cid);216 little_endian_store_16(event, 2, channel->rfcomm_cid); 217 217 event[4] = credits; 218 218 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 237 237 event[0] = RFCOMM_EVENT_REMOTE_LINE_STATUS; 238 238 event[1] = sizeof(event) - 2; 239 bt_store_16(event, 2, channel->rfcomm_cid);239 little_endian_store_16(event, 2, channel->rfcomm_cid); 240 240 event[4] = line_status; 241 241 hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event)); … … 905 905 case L2CAP_EVENT_INCOMING_CONNECTION: 906 906 // data: event(8), len(8), address(48), handle (16), psm (16), source cid(16) dest cid(16) 907 bt_flip_addr(event_addr, &packet[2]);908 con_handle = READ_BT_16(packet, 8);909 psm = READ_BT_16(packet, 10);910 l2cap_cid = READ_BT_16(packet, 12);907 reverse_bd_addr(&packet[2], event_addr); 908 con_handle = little_endian_read_16(packet, 8); 909 psm = little_endian_read_16(packet, 10); 910 l2cap_cid = little_endian_read_16(packet, 12); 911 911 912 912 if (psm != PSM_RFCOMM) break; … … 939 939 case L2CAP_EVENT_CHANNEL_OPENED: 940 940 941 if ( READ_BT_16(packet, 11) != PSM_RFCOMM) break;941 if (little_endian_read_16(packet, 11) != PSM_RFCOMM) break; 942 942 943 943 status = packet[2]; … … 945 945 946 946 // get multiplexer for remote addr 947 con_handle = READ_BT_16(packet, 9);948 l2cap_cid = READ_BT_16(packet, 13);949 bt_flip_addr(event_addr, &packet[3]);947 con_handle = little_endian_read_16(packet, 9); 948 l2cap_cid = little_endian_read_16(packet, 13); 949 reverse_bd_addr(&packet[3], event_addr); 950 950 multiplexer = rfcomm_multiplexer_for_addr(&event_addr); 951 951 if (!multiplexer) { … … 990 990 991 991 // set max frame size based on l2cap MTU 992 multiplexer->max_frame_size = rfcomm_max_frame_size_for_l2cap_mtu( READ_BT_16(packet, 17));992 multiplexer->max_frame_size = rfcomm_max_frame_size_for_l2cap_mtu(little_endian_read_16(packet, 17)); 993 993 } 994 994 return 1; … … 998 998 case L2CAP_EVENT_CREDITS: 999 999 // data: event(8), len(8), local_cid(16), credits(8) 1000 l2cap_cid = READ_BT_16(packet, 2);1000 l2cap_cid = little_endian_read_16(packet, 2); 1001 1001 multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid); 1002 1002 if (!multiplexer) break; … … 1019 1019 case L2CAP_EVENT_CHANNEL_CLOSED: 1020 1020 // data: event (8), len(8), channel (16) 1021 l2cap_cid = READ_BT_16(packet, 2);1021 l2cap_cid = little_endian_read_16(packet, 2); 1022 1022 multiplexer = rfcomm_multiplexer_for_l2cap_cid(l2cap_cid); 1023 1023 log_info("L2CAP_EVENT_CHANNEL_CLOSED cid 0x%0x, mult %p", l2cap_cid, multiplexer); … … 1478 1478 event_pn.super.type = CH_EVT_RCVD_PN; 1479 1479 event_pn.priority = packet[payload_offset+4]; 1480 event_pn.max_frame_size = READ_BT_16(packet, payload_offset+6);1480 event_pn.max_frame_size = little_endian_read_16(packet, payload_offset+6); 1481 1481 event_pn.credits_outgoing = packet[payload_offset+9]; 1482 1482 log_info("Received UIH Parameter Negotiation Command for #%u, credits %u", … … 1489 1489 event_pn.super.type = CH_EVT_RCVD_PN_RSP; 1490 1490 event_pn.priority = packet[payload_offset+4]; 1491 event_pn.max_frame_size = READ_BT_16(packet, payload_offset+6);1491 event_pn.max_frame_size = little_endian_read_16(packet, payload_offset+6); 1492 1492 event_pn.credits_outgoing = packet[payload_offset+9]; 1493 1493 log_info("Received UIH Parameter Negotiation Response max frame %u, credits %u", -
asp3_tinet_ecnl_rx/trunk/btstack/src/sdp.c
r337 r374 90 90 if (de_get_element_type(serviceRecordHandleAttribute) != DE_UINT) return 0; 91 91 if (de_get_size_type(serviceRecordHandleAttribute) != DE_SIZE_32) return 0; 92 return READ_NET_32(serviceRecordHandleAttribute, 1);92 return big_endian_read_32(serviceRecordHandleAttribute, 1); 93 93 } 94 94 … … 100 100 event[1] = sizeof(event) - 2; 101 101 event[2] = status; 102 bt_store_32(event, 3, handle);102 little_endian_store_32(event, 3, handle); 103 103 hci_dump_packet(HCI_EVENT_PACKET, 0, event, sizeof(event)); 104 104 (*app_packet_handler)(connection, HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); … … 275 275 276 276 // get request details 277 uint16_t transaction_id = READ_NET_16(packet, 1);278 // not used yet - uint16_t param_len = READ_NET_16(packet, 3);277 uint16_t transaction_id = big_endian_read_16(packet, 1); 278 // not used yet - uint16_t param_len = big_endian_read_16(packet, 3); 279 279 uint8_t * serviceSearchPattern = &packet[5]; 280 280 uint16_t serviceSearchPatternLen = de_get_len(serviceSearchPattern); 281 uint16_t maximumServiceRecordCount = READ_NET_16(packet, 5 + serviceSearchPatternLen);281 uint16_t maximumServiceRecordCount = big_endian_read_16(packet, 5 + serviceSearchPatternLen); 282 282 uint8_t * continuationState = &packet[5+serviceSearchPatternLen+2]; 283 283 … … 297 297 continuation_index = 0; 298 298 if (continuationState[0] == 2){ 299 continuation_index = READ_NET_16(continuationState, 1);299 continuation_index = big_endian_read_16(continuationState, 1); 300 300 } 301 301 … … 359 359 360 360 // get request details 361 uint16_t transaction_id = READ_NET_16(packet, 1);362 // not used yet - uint16_t param_len = READ_NET_16(packet, 3);363 uint32_t serviceRecordHandle = READ_NET_32(packet, 5);364 uint16_t maximumAttributeByteCount = READ_NET_16(packet, 9);361 uint16_t transaction_id = big_endian_read_16(packet, 1); 362 // not used yet - uint16_t param_len = big_endian_read_16(packet, 3); 363 uint32_t serviceRecordHandle = big_endian_read_32(packet, 5); 364 uint16_t maximumAttributeByteCount = big_endian_read_16(packet, 9); 365 365 uint8_t * attributeIDList = &packet[11]; 366 366 uint16_t attributeIDListLen = de_get_len(attributeIDList); … … 383 383 continuation_offset = 0; 384 384 if (continuationState[0] == 2){ 385 continuation_offset = READ_NET_16(continuationState, 1);385 continuation_offset = big_endian_read_16(continuationState, 1); 386 386 } 387 387 … … 452 452 453 453 // get request details 454 uint16_t transaction_id = READ_NET_16(packet, 1);455 // not used yet - uint16_t param_len = READ_NET_16(packet, 3);454 uint16_t transaction_id = big_endian_read_16(packet, 1); 455 // not used yet - uint16_t param_len = big_endian_read_16(packet, 3); 456 456 uint8_t * serviceSearchPattern = &packet[5]; 457 457 uint16_t serviceSearchPatternLen = de_get_len(serviceSearchPattern); 458 uint16_t maximumAttributeByteCount = READ_NET_16(packet, 5 + serviceSearchPatternLen);458 uint16_t maximumAttributeByteCount = big_endian_read_16(packet, 5 + serviceSearchPatternLen); 459 459 uint8_t * attributeIDList = &packet[5+serviceSearchPatternLen+2]; 460 460 uint16_t attributeIDListLen = de_get_len(attributeIDList); … … 481 481 continuation_offset = 0; 482 482 if (continuationState[0] == 4){ 483 continuation_service_index = READ_NET_16(continuationState, 1);484 continuation_offset = READ_NET_16(continuationState, 3);483 continuation_service_index = big_endian_read_16(continuationState, 1); 484 continuation_offset = big_endian_read_16(continuationState, 3); 485 485 } 486 486 … … 593 593 case L2CAP_DATA_PACKET: 594 594 pdu_id = (SDP_PDU_ID_t) packet[0]; 595 transaction_id = READ_NET_16(packet, 1);596 // param_len = READ_NET_16(packet, 3);595 transaction_id = big_endian_read_16(packet, 1); 596 // param_len = big_endian_read_16(packet, 3); 597 597 remote_mtu = l2cap_get_remote_mtu_for_local_cid(channel); 598 598 // account for our buffer -
asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_client.c
r337 r374 151 151 static void parse_service_search_attribute_response(uint8_t* packet){ 152 152 uint16_t offset = 3; 153 uint16_t parameterLength = READ_NET_16(packet,offset);153 uint16_t parameterLength = big_endian_read_16(packet,offset); 154 154 uint16_t attributeListByteCount; 155 155 offset+=2; 156 156 // AttributeListByteCount <= mtu 157 attributeListByteCount = READ_NET_16(packet,offset);157 attributeListByteCount = big_endian_read_16(packet,offset); 158 158 offset+=2; 159 159 … … 185 185 // uint16_t handle; 186 186 if (packet_type == L2CAP_DATA_PACKET){ 187 uint16_t responseTransactionID = READ_NET_16(packet,1);187 uint16_t responseTransactionID = big_endian_read_16(packet,1); 188 188 if ( responseTransactionID != transactionID){ 189 189 log_error("Missmatching transaction ID, expected %u, found %u.", transactionID, responseTransactionID); … … 247 247 } 248 248 sdp_cid = channel; 249 mtu = READ_BT_16(packet, 17);250 // handle = READ_BT_16(packet, 9);249 mtu = little_endian_read_16(packet, 17); 250 // handle = little_endian_read_16(packet, 9); 251 251 log_info("SDP Client Connected, cid %x, mtu %u.", sdp_cid, mtu); 252 252 … … 261 261 case L2CAP_EVENT_CHANNEL_CLOSED: { 262 262 uint8_t status; 263 if (sdp_cid != READ_BT_16(packet, 2)) {264 // log_info("Received L2CAP_EVENT_CHANNEL_CLOSED for cid %x, current cid %x\n", READ_BT_16(packet, 2),sdp_cid);263 if (sdp_cid != little_endian_read_16(packet, 2)) { 264 // log_info("Received L2CAP_EVENT_CHANNEL_CLOSED for cid %x, current cid %x\n", little_endian_read_16(packet, 2),sdp_cid); 265 265 break; 266 266 } … … 402 402 static void parse_service_search_response(uint8_t* packet){ 403 403 uint16_t offset = 3; 404 uint16_t parameterLength = READ_NET_16(packet,offset);404 uint16_t parameterLength = big_endian_read_16(packet,offset); 405 405 uint16_t totalServiceRecordCount; 406 406 uint16_t currentServiceRecordCount; 407 407 offset+=2; 408 408 409 totalServiceRecordCount = READ_NET_16(packet,offset);410 offset+=2; 411 412 currentServiceRecordCount = READ_NET_16(packet,offset);409 totalServiceRecordCount = big_endian_read_16(packet,offset); 410 offset+=2; 411 412 currentServiceRecordCount = big_endian_read_16(packet,offset); 413 413 offset+=2; 414 414 if (currentServiceRecordCount > totalServiceRecordCount){ … … 436 436 static void parse_service_attribute_response(uint8_t* packet){ 437 437 uint16_t offset = 3; 438 uint16_t parameterLength = READ_NET_16(packet,offset);438 uint16_t parameterLength = big_endian_read_16(packet,offset); 439 439 uint16_t attributeListByteCount; 440 440 offset+=2; 441 441 442 442 // AttributeListByteCount <= mtu 443 attributeListByteCount = READ_NET_16(packet,offset);443 attributeListByteCount = big_endian_read_16(packet,offset); 444 444 offset+=2; 445 445 -
asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_parser.c
r337 r374 166 166 { 167 167 sdp_query_attribute_value_event_t attribute_value_event = { 168 SDP_ QUERY_ATTRIBUTE_VALUE,168 SDP_EVENT_QUERY_ATTRIBUTE_VALUE, 169 169 record_counter, 170 170 attribute_id, … … 186 186 { 187 187 sdp_query_attribute_value_event_t attribute_value_event = { 188 SDP_ QUERY_ATTRIBUTE_VALUE,188 SDP_EVENT_QUERY_ATTRIBUTE_VALUE, 189 189 record_counter, 190 190 attribute_id, … … 258 258 int i; 259 259 for (i=0;i<record_handle_count;i++){ 260 record_handle = READ_NET_32(data, i*4);260 record_handle = big_endian_read_32(data, i*4); 261 261 record_counter++; 262 262 { … … 275 275 void sdp_parser_handle_done(uint8_t status){ 276 276 sdp_query_complete_event_t complete_event = { 277 SDP_ QUERY_COMPLETE,277 SDP_EVENT_QUERY_COMPLETE, 278 278 status 279 279 }; -
asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_query_rfcomm.c
r337 r374 248 248 sdp_query_attribute_value_event_t * ve; 249 249 switch (event->type){ 250 case SDP_ QUERY_ATTRIBUTE_VALUE:250 case SDP_EVENT_QUERY_ATTRIBUTE_VALUE: 251 251 ve = (sdp_query_attribute_value_event_t*) event; 252 252 // log_info("handle_sdp_parser_event [ AID, ALen, DOff, Data] : [%x, %u, %u] BYTE %02x", … … 254 254 255 255 switch (ve->attribute_id){ 256 case SDP_ProtocolDescriptorList:256 case BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST: 257 257 // find rfcomm channel 258 258 handleProtocolDescriptorListData(ve->attribute_length, ve->data_offset, ve->data); … … 267 267 } 268 268 break; 269 case SDP_ QUERY_COMPLETE:269 case SDP_EVENT_QUERY_COMPLETE: 270 270 (*sdp_app_callback)(event, sdp_app_context); 271 271 break; -
asp3_tinet_ecnl_rx/trunk/btstack/src/sdp_util.c
r337 r374 98 98 break; 99 99 case DE_SIZE_VAR_16: 100 result = READ_NET_16(header,1);100 result = big_endian_read_16(header,1); 101 101 break; 102 102 case DE_SIZE_VAR_32: 103 result = READ_NET_32(header,1);103 result = big_endian_read_32(header,1); 104 104 break; 105 105 default: … … 122 122 int de_element_get_uint16(uint8_t * element, uint16_t * value){ 123 123 if (de_get_size_type(element) != DE_SIZE_16) return 0; 124 *value = READ_NET_16(element, de_get_header_size(element));124 *value = big_endian_read_16(element, de_get_header_size(element)); 125 125 return 1; 126 126 } … … 134 134 switch (uuidSize){ 135 135 case DE_SIZE_16: 136 shortUUID = READ_NET_16(element, 1);136 shortUUID = big_endian_read_16(element, 1); 137 137 break; 138 138 case DE_SIZE_32: 139 shortUUID = READ_NET_32(element, 1);139 shortUUID = big_endian_read_32(element, 1); 140 140 break; 141 141 case DE_SIZE_128: … … 157 157 hasBlueoothBaseUuid = sdp_has_blueooth_base_uuid(uuid128); 158 158 if (!hasBlueoothBaseUuid) return 0; 159 return READ_NET_32(uuid128, 0);159 return big_endian_read_32(uuid128, 0); 160 160 } 161 161 … … 199 199 void de_pop_sequence(uint8_t * parent, uint8_t * child){ 200 200 int child_len = de_get_len(child); 201 int data_size_parent = READ_NET_16(parent,1);201 int data_size_parent = big_endian_read_16(parent,1); 202 202 net_store_16(parent, 1, data_size_parent + child_len); 203 203 } … … 205 205 /* adds a single number value and 16+32 bit UUID to the sequence */ 206 206 void de_add_number(uint8_t *seq, de_type_t type, de_size_t size, uint32_t value){ 207 int data_size = READ_NET_16(seq,1);207 int data_size = big_endian_read_16(seq,1); 208 208 int element_size = 1; // e.g. for DE_TYPE_NIL 209 209 de_store_descriptor(seq+3+data_size, type, size); … … 231 231 /* add a single block of data, e.g. as DE_STRING, DE_URL */ 232 232 void de_add_data( uint8_t *seq, de_type_t type, uint16_t size, uint8_t *data){ 233 int data_size = READ_NET_16(seq,1);233 int data_size = big_endian_read_16(seq,1); 234 234 if (size > 0xff) { 235 235 // use 16-bit lengh information (3 byte header) … … 247 247 248 248 void de_add_uuid128(uint8_t * seq, uint8_t * uuid){ 249 int data_size = READ_NET_16(seq,1);249 int data_size = big_endian_read_16(seq,1); 250 250 de_store_descriptor(seq+3+data_size, DE_UUID, DE_SIZE_128); 251 251 memcpy( seq + 4 + data_size, uuid, 16); … … 326 326 uint8_t done; 327 327 if (idType != DE_UINT || idSize != DE_SIZE_16) break; // wrong type 328 attribute_id = READ_NET_16(element, pos + 1);328 attribute_id = big_endian_read_16(element, pos + 1); 329 329 pos += 3; 330 330 if (pos >= end_pos) break; // array out of bounds … … 349 349 switch (size) { 350 350 case DE_SIZE_16: 351 if ( READ_NET_16(element, 1) == context->attributeID) {351 if (big_endian_read_16(element, 1) == context->attributeID) { 352 352 context->result = 1; 353 353 return 1; … … 355 355 break; 356 356 case DE_SIZE_32: 357 if ( READ_NET_16(element, 1) <= context->attributeID358 && context->attributeID <= READ_NET_16(element, 3)) {357 if (big_endian_read_16(element, 1) <= context->attributeID 358 && context->attributeID <= big_endian_read_16(element, 3)) { 359 359 context->result = 1; 360 360 return 1; … … 388 388 if (sdp_attribute_list_constains_id(context->attributeIDList, attributeID)) { 389 389 // DES_HEADER(3) + DES_DATA + (UINT16(3) + attribute) 390 uint16_t data_size = READ_NET_16(context->buffer, 1);390 uint16_t data_size = big_endian_read_16(context->buffer, 1); 391 391 int attribute_len = de_get_len(attributeValue); 392 392 if (3 + data_size + (3 + attribute_len) <= context->maxBytes) { … … 662 662 break; 663 663 case DE_SIZE_VAR_16: 664 len = READ_NET_16(element, 1);664 len = big_endian_read_16(element, 1); 665 665 break; 666 666 default: … … 678 678 break; 679 679 case DE_SIZE_16: 680 value = READ_NET_16(element,pos);680 value = big_endian_read_16(element,pos); 681 681 break; 682 682 case DE_SIZE_32: 683 value = READ_NET_32(element,pos);683 value = big_endian_read_32(element,pos); 684 684 break; 685 685 default: … … 712 712 713 713 // 0x0001 "Service Class ID List" 714 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ServiceClassIDList);714 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_SERVICE_CLASS_ID_LIST); 715 715 attribute = de_push_sequence(service); 716 716 { … … 720 720 721 721 // 0x0004 "Protocol Descriptor List" 722 de_add_number(service, DE_UINT, DE_SIZE_16, SDP_ProtocolDescriptorList);722 de_add_number(service, DE_UINT, DE_SIZE_16, BLUETOOTH_ATTRIBUTE_PROTOCOL_DESCRIPTOR_LIST); 723 723 attribute = de_push_sequence(service); 724 724 { -
asp3_tinet_ecnl_rx/trunk/btstack/src/utils.c
r337 r374 49 49 #include "debug.h" 50 50 51 void bt_store_16(uint8_t *buffer, uint16_t pos, uint16_t value){51 void little_endian_store_16(uint8_t *buffer, uint16_t pos, uint16_t value){ 52 52 buffer[pos++] = value; 53 53 buffer[pos++] = value >> 8; 54 54 } 55 55 56 void bt_store_32(uint8_t *buffer, uint16_t pos, uint32_t value){56 void little_endian_store_32(uint8_t *buffer, uint16_t pos, uint32_t value){ 57 57 buffer[pos++] = value; 58 58 buffer[pos++] = value >> 8; … … 73 73 } 74 74 75 void bt_flip_addr(bd_addr_t dest, bd_addr_t src){75 void reverse_bd_addr(bd_addr_t src, bd_addr_t dest){ 76 76 dest[0] = src[5]; 77 77 dest[1] = src[4];
Note:
See TracChangeset
for help on using the changeset viewer.