#include #include #include "Includes.h" #include "profile.h" #include "ble.h" #include "platform.h" hci_con_handle_t connection_handle; void sm_peripheral_setup (void){ } void _HWradio_Go_To_Idle_State_Patch (void){ } static uint32_t min(uint32_t a, uint32_t b){ return a < b ? a : b; } static int g_conn_stat = 0; int app_get_connect_state(void) { return g_conn_stat; } // att_read_callback helpers static uint16_t att_read_callback_handle_blob(const uint8_t * blob, uint16_t blob_size, uint16_t offset, uint8_t * buffer, uint16_t buffer_size){ if (buffer){ uint16_t bytes_to_copy = min(blob_size - offset, buffer_size); memcpy(buffer, &blob[offset], bytes_to_copy); return bytes_to_copy; } else { return blob_size; } } // read requests static uint16_t att_read_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){ printf("%s, con_handle=%x, att_handle=%x, offset=%x, buffer=%x, size=%x\n",__func__, con_handle, att_handle, offset,(uint32_t)buffer, buffer_size); if((att_handle != ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE) && (att_handle != ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE)) return 0; static uint8_t read_test[10] = "012345678"; return att_read_callback_handle_blob((const uint8_t *)read_test, sizeof(read_test), offset, buffer, buffer_size); } // write requests static int att_write_callback(hci_con_handle_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size){ uint32_t le_notification_enabled; printf("%s, con_handle=%x, att_handle=%x, offset=%x, buffer=%x, size=%x\n", __func__, con_handle, att_handle, offset, (uint32_t)buffer, buffer_size); if (transaction_mode != ATT_TRANSACTION_MODE_NONE) return 0; switch(att_handle) { case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_CLIENT_CONFIGURATION_HANDLE: le_notification_enabled = little_endian_read_16(buffer, 0) == GATT_CLIENT_CHARACTERISTICS_CONFIGURATION_NOTIFICATION; printf("Notifications enabled %u\n",le_notification_enabled); break; case ATT_CHARACTERISTIC_0000FF11_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE: case ATT_CHARACTERISTIC_0000FF12_0000_1000_8000_00805F9B34FB_01_VALUE_HANDLE: printf("att_handle=0x%x, offset=0x%x, length=0x%x\n", att_handle, offset, buffer_size); printf("att data: "); for(uint32_t i=0; i= 5000){ i=0; // gap_request_connection_parameter_update(connection_handle, 400-20, 400, 0, 600); gap_request_connection_parameter_update(connection_handle, 800-20, 800, 0, 600); con_count = 0; } } } }