mock.c (bcc59d6cd901fd07d4ded397b9cb4b1d8148201c) mock.c (f8fbdce0c5067e7e7edd3a29934b1f9b79c8ff2d)
1#include <stdint.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include "ble/att.h"
7#include "hci.h"
8#include "hci_dump.h"

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

77void mock_simulate_sm_data_packet(uint8_t * packet, uint16_t len){
78
79 uint16_t handle = 0x40;
80 uint16_t cid = 0x06;
81
82 uint8_t acl_buffer[len + 8];
83
84 // 0 - Connection handle : PB=10 : BC=00
1#include <stdint.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5
6#include "ble/att.h"
7#include "hci.h"
8#include "hci_dump.h"

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

77void mock_simulate_sm_data_packet(uint8_t * packet, uint16_t len){
78
79 uint16_t handle = 0x40;
80 uint16_t cid = 0x06;
81
82 uint8_t acl_buffer[len + 8];
83
84 // 0 - Connection handle : PB=10 : BC=00
85 bt_store_16(acl_buffer, 0, handle | (0 << 12) | (0 << 14));
85 little_endian_store_16(acl_buffer, 0, handle | (0 << 12) | (0 << 14));
86 // 2 - ACL length
86 // 2 - ACL length
87 bt_store_16(acl_buffer, 2, len + 4);
87 little_endian_store_16(acl_buffer, 2, len + 4);
88 // 4 - L2CAP packet length
88 // 4 - L2CAP packet length
89 bt_store_16(acl_buffer, 4, len + 0);
89 little_endian_store_16(acl_buffer, 4, len + 0);
90 // 6 - L2CAP channel DEST
90 // 6 - L2CAP channel DEST
91 bt_store_16(acl_buffer, 6, cid);
91 little_endian_store_16(acl_buffer, 6, cid);
92
93 memcpy(&acl_buffer[8], packet, len);
94 hci_dump_packet(HCI_ACL_DATA_PACKET, 1, &acl_buffer[0], len + 8);
95
96 le_data_handler(SM_DATA_PACKET, handle, packet, len);
97}
98
99void mock_simulate_command_complete(const hci_cmd_t *cmd){

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

203}
204
205int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t * buffer, uint16_t len){
206 // printf("l2cap_send_connectionless\n");
207
208 int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;
209
210 // 0 - Connection handle : PB=pb : BC=00
92
93 memcpy(&acl_buffer[8], packet, len);
94 hci_dump_packet(HCI_ACL_DATA_PACKET, 1, &acl_buffer[0], len + 8);
95
96 le_data_handler(SM_DATA_PACKET, handle, packet, len);
97}
98
99void mock_simulate_command_complete(const hci_cmd_t *cmd){

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

203}
204
205int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t * buffer, uint16_t len){
206 // printf("l2cap_send_connectionless\n");
207
208 int pb = hci_non_flushable_packet_boundary_flag_supported() ? 0x00 : 0x02;
209
210 // 0 - Connection handle : PB=pb : BC=00
211 bt_store_16(packet_buffer, 0, handle | (pb << 12) | (0 << 14));
211 little_endian_store_16(packet_buffer, 0, handle | (pb << 12) | (0 << 14));
212 // 2 - ACL length
212 // 2 - ACL length
213 bt_store_16(packet_buffer, 2, len + 4);
213 little_endian_store_16(packet_buffer, 2, len + 4);
214 // 4 - L2CAP packet length
214 // 4 - L2CAP packet length
215 bt_store_16(packet_buffer, 4, len + 0);
215 little_endian_store_16(packet_buffer, 4, len + 0);
216 // 6 - L2CAP channel DEST
216 // 6 - L2CAP channel DEST
217 bt_store_16(packet_buffer, 6, cid);
217 little_endian_store_16(packet_buffer, 6, cid);
218
219 memcpy(&packet_buffer[8], buffer, len);
220 hci_dump_packet(HCI_ACL_DATA_PACKET, 0, &packet_buffer[0], len + 8);
221
222 dump_packet(HCI_ACL_DATA_PACKET, packet_buffer, len + 8);
223 packet_buffer_len = len + 8;
224
225 return 0;

--- 12 unchanged lines hidden ---
218
219 memcpy(&packet_buffer[8], buffer, len);
220 hci_dump_packet(HCI_ACL_DATA_PACKET, 0, &packet_buffer[0], len + 8);
221
222 dump_packet(HCI_ACL_DATA_PACKET, packet_buffer, len + 8);
223 packet_buffer_len = len + 8;
224
225 return 0;

--- 12 unchanged lines hidden ---