mock.c (5611a760af48d1ce1beea59c7908be73bd2393f1) | mock.c (f8fbdce0c5067e7e7edd3a29934b1f9b79c8ff2d) |
---|---|
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 --- 164 unchanged lines hidden (view full) --- 173 174static void hci_event_sco_complete(){ 175 uint8_t event[19]; 176 uint8_t pos = 0; 177 event[pos++] = HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE; 178 event[pos++] = sizeof(event) - 2; 179 180 event[pos++] = 0; //status | 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 --- 164 unchanged lines hidden (view full) --- 173 174static void hci_event_sco_complete(){ 175 uint8_t event[19]; 176 uint8_t pos = 0; 177 event[pos++] = HCI_EVENT_SYNCHRONOUS_CONNECTION_COMPLETE; 178 event[pos++] = sizeof(event) - 2; 179 180 event[pos++] = 0; //status |
181 bt_store_16(event, pos, sco_handle); pos += 2; // sco handle | 181 little_endian_store_16(event, pos, sco_handle); pos += 2; // sco handle |
182 bt_flip_addr(&event[pos], dev_addr); pos += 6; 183 184 event[pos++] = 0; // link_type 185 event[pos++] = 0; // transmission_interval 186 event[pos++] = 0; // retransmission_interval 187 | 182 bt_flip_addr(&event[pos], dev_addr); pos += 6; 183 184 event[pos++] = 0; // link_type 185 event[pos++] = 0; // transmission_interval 186 event[pos++] = 0; // retransmission_interval 187 |
188 bt_store_16(event, pos, 0); pos += 2; // rx_packet_length 189 bt_store_16(event, pos, 0); pos += 2; // tx_packet_length | 188 little_endian_store_16(event, pos, 0); pos += 2; // rx_packet_length 189 little_endian_store_16(event, pos, 0); pos += 2; // tx_packet_length |
190 191 event[pos++] = 0; // air_mode 192 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event)); 193} 194 195int hci_send_cmd(const hci_cmd_t *cmd, ...){ 196 //printf("hci_send_cmd opcode 0x%02x\n", cmd->opcode); 197 if (cmd->opcode == 0x428){ --- 41 unchanged lines hidden (view full) --- 239 event[pos++] = RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE; 240 event[pos++] = sizeof(event) - 2; 241 event[pos++] = 0; 242 243 bt_flip_addr(&event[pos], addr); 244 memcpy(dev_addr, addr, 6); 245 pos += 6; 246 | 190 191 event[pos++] = 0; // air_mode 192 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event)); 193} 194 195int hci_send_cmd(const hci_cmd_t *cmd, ...){ 196 //printf("hci_send_cmd opcode 0x%02x\n", cmd->opcode); 197 if (cmd->opcode == 0x428){ --- 41 unchanged lines hidden (view full) --- 239 event[pos++] = RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE; 240 event[pos++] = sizeof(event) - 2; 241 event[pos++] = 0; 242 243 bt_flip_addr(&event[pos], addr); 244 memcpy(dev_addr, addr, 6); 245 pos += 6; 246 |
247 bt_store_16(event, pos, 1); pos += 2; | 247 little_endian_store_16(event, pos, 1); pos += 2; |
248 event[pos++] = 0; 249 | 248 event[pos++] = 0; 249 |
250 bt_store_16(event, pos, rfcomm_cid); pos += 2; // channel ID 251 bt_store_16(event, pos, 200); pos += 2; // max frame size | 250 little_endian_store_16(event, pos, rfcomm_cid); pos += 2; // channel ID 251 little_endian_store_16(event, pos, 200); pos += 2; // max frame size |
252 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, pos); 253 254 if (out_cid){ 255 *out_cid = rfcomm_cid; 256 } 257 return 0; 258} 259 260int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){ 261 return 1; 262} 263 264void rfcomm_disconnect(uint16_t rfcomm_cid){ 265 uint8_t event[4]; 266 event[0] = RFCOMM_EVENT_CHANNEL_CLOSED; 267 event[1] = sizeof(event) - 2; | 252 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, pos); 253 254 if (out_cid){ 255 *out_cid = rfcomm_cid; 256 } 257 return 0; 258} 259 260int rfcomm_can_send_packet_now(uint16_t rfcomm_cid){ 261 return 1; 262} 263 264void rfcomm_disconnect(uint16_t rfcomm_cid){ 265 uint8_t event[4]; 266 event[0] = RFCOMM_EVENT_CHANNEL_CLOSED; 267 event[1] = sizeof(event) - 2; |
268 bt_store_16(event, 2, rfcomm_cid); | 268 little_endian_store_16(event, 2, rfcomm_cid); |
269 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); 270} 271 272void rfcomm_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){ 273 registered_rfcomm_packet_handler = handler; 274} 275 276uint8_t rfcomm_register_service(uint8_t channel, uint16_t max_frame_size){ --- 24 unchanged lines hidden (view full) --- 301} 302 303 304void hci_emit_disconnection_complete(uint16_t handle, uint8_t reason){ 305 uint8_t event[6]; 306 event[0] = HCI_EVENT_DISCONNECTION_COMPLETE; 307 event[1] = sizeof(event) - 2; 308 event[2] = 0; // status = OK | 269 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, (uint8_t *) event, sizeof(event)); 270} 271 272void rfcomm_register_packet_handler(void (*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)){ 273 registered_rfcomm_packet_handler = handler; 274} 275 276uint8_t rfcomm_register_service(uint8_t channel, uint16_t max_frame_size){ --- 24 unchanged lines hidden (view full) --- 301} 302 303 304void hci_emit_disconnection_complete(uint16_t handle, uint8_t reason){ 305 uint8_t event[6]; 306 event[0] = HCI_EVENT_DISCONNECTION_COMPLETE; 307 event[1] = sizeof(event) - 2; 308 event[2] = 0; // status = OK |
309 bt_store_16(event, 3, handle); | 309 little_endian_store_16(event, 3, handle); |
310 event[5] = reason; 311 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event)); 312} 313 314uint8_t gap_disconnect(hci_con_handle_t handle){ 315 hci_emit_disconnection_complete(handle, 0); 316 return 0; 317} --- 47 unchanged lines hidden --- | 310 event[5] = reason; 311 (*registered_rfcomm_packet_handler)(HCI_EVENT_PACKET, 0, event, sizeof(event)); 312} 313 314uint8_t gap_disconnect(hci_con_handle_t handle){ 315 hci_emit_disconnection_complete(handle, 0); 316 return 0; 317} --- 47 unchanged lines hidden --- |