mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 03:40:47 +00:00
fix c99 warnings for missing argument of functions with no arguments, fix more warnings
This commit is contained in:
parent
9ba99baec4
commit
71de195ed3
@ -117,7 +117,7 @@ static void notify_client(int event_type){
|
|||||||
(*client_handler)(&event);
|
(*client_handler)(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ancs_chunk_parser_init(){
|
static void ancs_chunk_parser_init(void){
|
||||||
chunk_parser_state = W4_ATTRIBUTE_ID;
|
chunk_parser_state = W4_ATTRIBUTE_ID;
|
||||||
ancs_bytes_received = 0;
|
ancs_bytes_received = 0;
|
||||||
ancs_bytes_needed = 6;
|
ancs_bytes_needed = 6;
|
||||||
@ -315,6 +315,6 @@ void ancs_client_hci_event_handler (uint8_t packet_type, uint16_t channel, uint8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ancs_client_init(){
|
void ancs_client_init(void){
|
||||||
gc_id = gatt_client_register_packet_handler(&handle_gatt_client_event);
|
gc_id = gatt_client_register_packet_handler(&handle_gatt_client_event);
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ typedef struct ancs_event{
|
|||||||
const char * text;
|
const char * text;
|
||||||
} ancs_event_t;
|
} ancs_event_t;
|
||||||
|
|
||||||
void ancs_client_init();
|
void ancs_client_init(void);
|
||||||
void ancs_client_hci_event_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
void ancs_client_hci_event_handler (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
void ancs_client_register_callback(void (*handler)(ancs_event_t * event));
|
void ancs_client_register_callback(void (*handler)(ancs_event_t * event));
|
||||||
const char * ancs_client_attribute_name_for_id(int id);
|
const char * ancs_client_attribute_name_for_id(int id);
|
||||||
|
@ -217,7 +217,7 @@ void att_dump_attributes(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void att_prepare_write_reset(){
|
static void att_prepare_write_reset(void){
|
||||||
att_prepare_write_error_code = 0;
|
att_prepare_write_error_code = 0;
|
||||||
att_prepare_write_error_handle = 0x0000;
|
att_prepare_write_error_handle = 0x0000;
|
||||||
}
|
}
|
||||||
@ -1071,7 +1071,7 @@ uint16_t att_handle_request(att_connection_t * att_connection,
|
|||||||
// test profile
|
// test profile
|
||||||
#include "profile.h"
|
#include "profile.h"
|
||||||
|
|
||||||
int main(){
|
int main(void){
|
||||||
int acl_buffer_size;
|
int acl_buffer_size;
|
||||||
uint8_t acl_buffer[27];
|
uint8_t acl_buffer[27];
|
||||||
att_set_db(profile_data);
|
att_set_db(profile_data);
|
||||||
|
@ -357,7 +357,7 @@ void att_server_register_packet_handler(btstack_packet_handler_t handler){
|
|||||||
att_client_packet_handler = handler;
|
att_client_packet_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
int att_server_can_send(){
|
int att_server_can_send(void){
|
||||||
if (att_connection.con_handle == 0) return 0;
|
if (att_connection.con_handle == 0) return 0;
|
||||||
return l2cap_can_send_fixed_channel_packet_now(att_connection.con_handle);
|
return l2cap_can_send_fixed_channel_packet_now(att_connection.con_handle);
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,7 @@ static uint16_t peripheral_mtu(gatt_client_t *peripheral){
|
|||||||
return peripheral->mtu;
|
return peripheral->mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint16_t gatt_client_next_id(){
|
static uint16_t gatt_client_next_id(void){
|
||||||
if (gatt_client_id < 0xFFFF) {
|
if (gatt_client_id < 0xFFFF) {
|
||||||
gatt_client_id++;
|
gatt_client_id++;
|
||||||
} else {
|
} else {
|
||||||
@ -123,7 +123,7 @@ void gatt_client_unregister_packet_handler(uint16_t gatt_client_id){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void gatt_client_init(){
|
void gatt_client_init(void){
|
||||||
att_client_start_handle = 0x0000;
|
att_client_start_handle = 0x0000;
|
||||||
gatt_client_connections = NULL;
|
gatt_client_connections = NULL;
|
||||||
att_dispatch_register_client(gatt_client_att_packet_handler);
|
att_dispatch_register_client(gatt_client_att_packet_handler);
|
||||||
@ -702,7 +702,7 @@ static int is_value_valid(gatt_client_t *peripheral, uint8_t *packet, uint16_t s
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void gatt_client_run(){
|
static void gatt_client_run(void){
|
||||||
|
|
||||||
linked_item_t *it;
|
linked_item_t *it;
|
||||||
for (it = (linked_item_t *) gatt_client_connections; it ; it = it->next){
|
for (it = (linked_item_t *) gatt_client_connections; it ; it = it->next){
|
||||||
|
@ -60,7 +60,7 @@ static void (*packet_handler) (void * connection, uint8_t packet_type, uint16_t
|
|||||||
static btstack_packet_handler_t attribute_protocol_packet_handler;
|
static btstack_packet_handler_t attribute_protocol_packet_handler;
|
||||||
static btstack_packet_handler_t security_protocol_packet_handler;
|
static btstack_packet_handler_t security_protocol_packet_handler;
|
||||||
|
|
||||||
void l2cap_init(){
|
void l2cap_init(void){
|
||||||
|
|
||||||
packet_handler = NULL;
|
packet_handler = NULL;
|
||||||
attribute_protocol_packet_handler = NULL;
|
attribute_protocol_packet_handler = NULL;
|
||||||
@ -77,7 +77,7 @@ uint16_t l2cap_max_mtu(void){
|
|||||||
return HCI_ACL_PAYLOAD_SIZE - L2CAP_HEADER_SIZE;
|
return HCI_ACL_PAYLOAD_SIZE - L2CAP_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t l2cap_max_le_mtu(){
|
uint16_t l2cap_max_le_mtu(void){
|
||||||
return l2cap_max_mtu();
|
return l2cap_max_mtu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include "le_device_db.h"
|
#include "le_device_db.h"
|
||||||
|
|
||||||
// Central Device db interface
|
// Central Device db interface
|
||||||
void le_device_db_init(){}
|
void le_device_db_init(void){}
|
||||||
|
|
||||||
// @returns index if successful, -1 otherwise
|
// @returns index if successful, -1 otherwise
|
||||||
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk){
|
int le_device_db_add(int addr_type, bd_addr_t addr, sm_key_t irk){
|
||||||
|
@ -69,7 +69,7 @@ typedef struct le_device_memory_db {
|
|||||||
|
|
||||||
static le_device_memory_db_t le_devices[LE_DEVICE_MEMORY_SIZE];
|
static le_device_memory_db_t le_devices[LE_DEVICE_MEMORY_SIZE];
|
||||||
|
|
||||||
void le_device_db_init(){
|
void le_device_db_init(void){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
||||||
le_device_db_remove(i);
|
le_device_db_remove(i);
|
||||||
@ -177,7 +177,7 @@ void le_device_db_local_counter_set(int index, uint32_t counter){
|
|||||||
le_devices[index].local_counter = counter;
|
le_devices[index].local_counter = counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
void le_device_db_dump(){
|
void le_device_db_dump(void){
|
||||||
log_info("Central Device DB dump, devices: %u", le_device_db_count);
|
log_info("Central Device DB dump, devices: %u", le_device_db_count);
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
for (i=0;i<LE_DEVICE_MEMORY_SIZE;i++){
|
||||||
|
32
ble/sm.c
32
ble/sm.c
@ -267,7 +267,7 @@ static int sm_is_null_random(uint8_t random[8]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Key utils
|
// Key utils
|
||||||
static void sm_reset_tk(){
|
static void sm_reset_tk(void){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<16;i++){
|
for (i=0;i<16;i++){
|
||||||
setup->sm_tk[i] = 0;
|
setup->sm_tk[i] = 0;
|
||||||
@ -311,7 +311,7 @@ static void sm_timeout_start(sm_connection_t * sm_conn){
|
|||||||
linked_item_set_user((linked_item_t*) &setup->sm_timeout, sm_conn);
|
linked_item_set_user((linked_item_t*) &setup->sm_timeout, sm_conn);
|
||||||
run_loop_add_timer(&setup->sm_timeout);
|
run_loop_add_timer(&setup->sm_timeout);
|
||||||
}
|
}
|
||||||
static void sm_timeout_stop(){
|
static void sm_timeout_stop(void){
|
||||||
run_loop_remove_timer(&setup->sm_timeout);
|
run_loop_remove_timer(&setup->sm_timeout);
|
||||||
}
|
}
|
||||||
static void sm_timeout_reset(sm_connection_t * sm_conn){
|
static void sm_timeout_reset(sm_connection_t * sm_conn){
|
||||||
@ -326,7 +326,7 @@ static gap_random_address_type_t gap_random_adress_type;
|
|||||||
static timer_source_t gap_random_address_update_timer;
|
static timer_source_t gap_random_address_update_timer;
|
||||||
static uint32_t gap_random_adress_update_period;
|
static uint32_t gap_random_adress_update_period;
|
||||||
|
|
||||||
static void gap_random_address_trigger(){
|
static void gap_random_address_trigger(void){
|
||||||
if (rau_state != RAU_IDLE) return;
|
if (rau_state != RAU_IDLE) return;
|
||||||
log_info("gap_random_address_trigger");
|
log_info("gap_random_address_trigger");
|
||||||
rau_state = RAU_GET_RANDOM;
|
rau_state = RAU_GET_RANDOM;
|
||||||
@ -340,13 +340,13 @@ static void gap_random_address_update_handler(timer_source_t * timer){
|
|||||||
gap_random_address_trigger();
|
gap_random_address_trigger();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gap_random_address_update_start(){
|
static void gap_random_address_update_start(void){
|
||||||
run_loop_set_timer_handler(&gap_random_address_update_timer, gap_random_address_update_handler);
|
run_loop_set_timer_handler(&gap_random_address_update_timer, gap_random_address_update_handler);
|
||||||
run_loop_set_timer(&gap_random_address_update_timer, gap_random_adress_update_period);
|
run_loop_set_timer(&gap_random_address_update_timer, gap_random_adress_update_period);
|
||||||
run_loop_add_timer(&gap_random_address_update_timer);
|
run_loop_add_timer(&gap_random_address_update_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gap_random_address_update_stop(){
|
static void gap_random_address_update_stop(void){
|
||||||
run_loop_remove_timer(&gap_random_address_update_timer);
|
run_loop_remove_timer(&gap_random_address_update_timer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -481,7 +481,7 @@ static void sm_notify_client_authorization(uint8_t type, uint8_t addr_type, bd_a
|
|||||||
// - pairing request
|
// - pairing request
|
||||||
// - io capabilities
|
// - io capabilities
|
||||||
// - OOB data availability
|
// - OOB data availability
|
||||||
static void sm_setup_tk(){
|
static void sm_setup_tk(void){
|
||||||
|
|
||||||
// default: just works
|
// default: just works
|
||||||
setup->sm_stk_generation_method = JUST_WORKS;
|
setup->sm_stk_generation_method = JUST_WORKS;
|
||||||
@ -538,7 +538,7 @@ static void sm_setup_key_distribution(uint8_t key_set){
|
|||||||
|
|
||||||
// CSRK Key Lookup
|
// CSRK Key Lookup
|
||||||
|
|
||||||
/* static */ int sm_central_device_lookup_active(){
|
/* static */ int sm_central_device_lookup_active(void){
|
||||||
return sm_central_device_test >= 0;
|
return sm_central_device_test >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -566,16 +566,16 @@ static void sm_shift_left_by_one_bit_inplace(int len, uint8_t * data){
|
|||||||
static inline void sm_next_responding_state(sm_connection_t * sm_conn){
|
static inline void sm_next_responding_state(sm_connection_t * sm_conn){
|
||||||
sm_conn->sm_engine_state = (security_manager_state_t) (((int)sm_conn->sm_engine_state) + 1);
|
sm_conn->sm_engine_state = (security_manager_state_t) (((int)sm_conn->sm_engine_state) + 1);
|
||||||
}
|
}
|
||||||
static inline void dkg_next_state(){
|
static inline void dkg_next_state(void){
|
||||||
dkg_state = (derived_key_generation_t) (((int)dkg_state) + 1);
|
dkg_state = (derived_key_generation_t) (((int)dkg_state) + 1);
|
||||||
}
|
}
|
||||||
static inline void rau_next_state(){
|
static inline void rau_next_state(void){
|
||||||
rau_state = (random_address_update_t) (((int)rau_state) + 1);
|
rau_state = (random_address_update_t) (((int)rau_state) + 1);
|
||||||
}
|
}
|
||||||
static inline void sm_cmac_next_state(){
|
static inline void sm_cmac_next_state(void){
|
||||||
sm_cmac_state = (cmac_state_t) (((int)sm_cmac_state) + 1);
|
sm_cmac_state = (cmac_state_t) (((int)sm_cmac_state) + 1);
|
||||||
}
|
}
|
||||||
static int sm_cmac_last_block_complete(){
|
static int sm_cmac_last_block_complete(void){
|
||||||
if (sm_cmac_message_len == 0) return 0;
|
if (sm_cmac_message_len == 0) return 0;
|
||||||
return (sm_cmac_message_len & 0x0f) == 0;
|
return (sm_cmac_message_len & 0x0f) == 0;
|
||||||
}
|
}
|
||||||
@ -616,11 +616,11 @@ void sm_cmac_start(sm_key_t k, uint16_t message_len, uint8_t * message, uint32_t
|
|||||||
sm_run();
|
sm_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
int sm_cmac_ready(){
|
int sm_cmac_ready(void){
|
||||||
return sm_cmac_state == CMAC_IDLE;
|
return sm_cmac_state == CMAC_IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sm_cmac_handle_aes_engine_ready(){
|
static void sm_cmac_handle_aes_engine_ready(void){
|
||||||
switch (sm_cmac_state){
|
switch (sm_cmac_state){
|
||||||
case CMAC_CALC_SUBKEYS: {
|
case CMAC_CALC_SUBKEYS: {
|
||||||
sm_key_t const_zero;
|
sm_key_t const_zero;
|
||||||
@ -756,7 +756,7 @@ static void sm_trigger_user_response(sm_connection_t * sm_conn){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sm_key_distribution_all_received(){
|
static int sm_key_distribution_all_received(void){
|
||||||
int recv_flags = sm_key_distribution_flags_for_set(setup->sm_m_preq.initiator_key_distribution);
|
int recv_flags = sm_key_distribution_flags_for_set(setup->sm_m_preq.initiator_key_distribution);
|
||||||
return recv_flags == setup->sm_key_distribution_received_set;
|
return recv_flags == setup->sm_key_distribution_received_set;
|
||||||
}
|
}
|
||||||
@ -1741,7 +1741,7 @@ static inline int sm_calc_actual_encryption_key_size(int other){
|
|||||||
/**
|
/**
|
||||||
* @return ok
|
* @return ok
|
||||||
*/
|
*/
|
||||||
static int sm_validate_stk_generation_method(){
|
static int sm_validate_stk_generation_method(void){
|
||||||
// check if STK generation method is acceptable by client
|
// check if STK generation method is acceptable by client
|
||||||
switch (setup->sm_stk_generation_method){
|
switch (setup->sm_stk_generation_method){
|
||||||
case JUST_WORKS:
|
case JUST_WORKS:
|
||||||
@ -2024,7 +2024,7 @@ void sm_send_security_request(uint16_t handle){
|
|||||||
sm_run();
|
sm_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sm_init(){
|
void sm_init(void){
|
||||||
// set some (BTstack default) ER and IR
|
// set some (BTstack default) ER and IR
|
||||||
int i;
|
int i;
|
||||||
sm_key_t er;
|
sm_key_t er;
|
||||||
|
@ -96,7 +96,7 @@ void sm_authorization_decline(uint8_t addr_type, bd_addr_t address){}
|
|||||||
void sm_authorization_grant(uint8_t addr_type, bd_addr_t address){}
|
void sm_authorization_grant(uint8_t addr_type, bd_addr_t address){}
|
||||||
|
|
||||||
// Support for signed writes
|
// Support for signed writes
|
||||||
int sm_cmac_ready(){
|
int sm_cmac_ready(void){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ void sm_register_packet_handler(btstack_packet_handler_t handler){
|
|||||||
sm_client_packet_handler = handler;
|
sm_client_packet_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sm_pdu_received_in_wrong_state(){
|
static void sm_pdu_received_in_wrong_state(void){
|
||||||
sm_pairing_failed_reason = SM_REASON_UNSPECIFIED_REASON;
|
sm_pairing_failed_reason = SM_REASON_UNSPECIFIED_REASON;
|
||||||
sm_state_responding = SM_GENERAL_SEND_PAIRING_FAILED;
|
sm_state_responding = SM_GENERAL_SEND_PAIRING_FAILED;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ static void sm_run(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void sm_init(){
|
void sm_init(void){
|
||||||
// attach to lower layers
|
// attach to lower layers
|
||||||
l2cap_register_fixed_channel(sm_packet_handler, L2CAP_CID_SECURITY_MANAGER_PROTOCOL);
|
l2cap_register_fixed_channel(sm_packet_handler, L2CAP_CID_SECURITY_MANAGER_PROTOCOL);
|
||||||
l2cap_register_packet_handler(sm_event_packet_handler);
|
l2cap_register_packet_handler(sm_event_packet_handler);
|
||||||
|
@ -93,7 +93,7 @@ uint8_t adv_data_len = sizeof(adv_data);
|
|||||||
|
|
||||||
static uint16_t todos = 0;
|
static uint16_t todos = 0;
|
||||||
|
|
||||||
static void app_run(){
|
static void app_run(void){
|
||||||
|
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ static void fill_advertising_report_from_packet(advertising_report_t * report, u
|
|||||||
swapX(found_device_addr, report->address, 6);
|
swapX(found_device_addr, report->address, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gap_run(){
|
static void gap_run(void){
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -252,7 +252,7 @@ void handle_gatt_client_event(le_event_t * event){
|
|||||||
uint16_t value_handle = 1;
|
uint16_t value_handle = 1;
|
||||||
uint16_t attribute_size = 1;
|
uint16_t attribute_size = 1;
|
||||||
|
|
||||||
void show_usage(){
|
void show_usage(void){
|
||||||
printf("\e[1;1H\e[2J");
|
printf("\e[1;1H\e[2J");
|
||||||
printf("--- CLI for LE Central ---\n");
|
printf("--- CLI for LE Central ---\n");
|
||||||
printf("SM: %s, MITM protection %u, OOB data %u, key range [%u..16]\n",
|
printf("SM: %s, MITM protection %u, OOB data %u, key range [%u..16]\n",
|
||||||
@ -284,7 +284,7 @@ void show_usage(){
|
|||||||
printf("---\n");
|
printf("---\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_auth_req(){
|
void update_auth_req(void){
|
||||||
uint8_t auth_req = 0;
|
uint8_t auth_req = 0;
|
||||||
if (sm_mitm_protection){
|
if (sm_mitm_protection){
|
||||||
auth_req |= SM_AUTHREQ_MITM_PROTECTION;
|
auth_req |= SM_AUTHREQ_MITM_PROTECTION;
|
||||||
|
@ -74,7 +74,7 @@ typedef struct ad_event {
|
|||||||
void (*ble_client_packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = NULL;
|
void (*ble_client_packet_handler)(uint8_t packet_type, uint8_t *packet, uint16_t size) = NULL;
|
||||||
static void ble_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void ble_packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
|
|
||||||
void ble_client_init(){
|
void ble_client_init(void){
|
||||||
gatt_client_init();
|
gatt_client_init();
|
||||||
l2cap_register_packet_handler(ble_packet_handler);
|
l2cap_register_packet_handler(ble_packet_handler);
|
||||||
}
|
}
|
||||||
|
@ -220,7 +220,7 @@ static attribute_t att_write_queues[ATT_NUM_WRITE_QUEUES];
|
|||||||
#define ATT_NUM_ATTRIBUTES 10
|
#define ATT_NUM_ATTRIBUTES 10
|
||||||
static attribute_t att_attributes[ATT_NUM_ATTRIBUTES];
|
static attribute_t att_attributes[ATT_NUM_ATTRIBUTES];
|
||||||
|
|
||||||
static void att_write_queue_init(){
|
static void att_write_queue_init(void){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<ATT_NUM_WRITE_QUEUES;i++){
|
for (i=0;i<ATT_NUM_WRITE_QUEUES;i++){
|
||||||
att_write_queues[i].handle = 0;
|
att_write_queues[i].handle = 0;
|
||||||
@ -245,7 +245,7 @@ static int att_write_queue_for_handle(uint16_t handle){
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void att_attributes_init(){
|
static void att_attributes_init(void){
|
||||||
int i;
|
int i;
|
||||||
for (i=0;i<ATT_NUM_ATTRIBUTES;i++){
|
for (i=0;i<ATT_NUM_ATTRIBUTES;i++){
|
||||||
att_attributes[i].handle = 0;
|
att_attributes[i].handle = 0;
|
||||||
@ -274,7 +274,7 @@ static void heartbeat_handler(struct timer *ts){
|
|||||||
app_run();
|
app_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void app_run(){
|
static void app_run(void){
|
||||||
if (!update_client) return;
|
if (!update_client) return;
|
||||||
if (!att_server_can_send()) return;
|
if (!att_server_can_send()) return;
|
||||||
|
|
||||||
@ -464,14 +464,14 @@ static int att_write_callback(uint16_t con_handle, uint16_t attribute_handle, ui
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t gap_adv_type(){
|
static uint8_t gap_adv_type(void){
|
||||||
if (gap_scannable) return 0x02;
|
if (gap_scannable) return 0x02;
|
||||||
if (gap_directed_connectable) return 0x01;
|
if (gap_directed_connectable) return 0x01;
|
||||||
if (!gap_connectable) return 0x03;
|
if (!gap_connectable) return 0x03;
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gap_run(){
|
static void gap_run(void){
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
if (todos & DISABLE_ADVERTISEMENTS){
|
if (todos & DISABLE_ADVERTISEMENTS){
|
||||||
@ -609,7 +609,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
gap_run();
|
gap_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_usage(){
|
void show_usage(void){
|
||||||
printf("\n--- CLI for LE Peripheral ---\n");
|
printf("\n--- CLI for LE Peripheral ---\n");
|
||||||
printf("GAP: discoverable %u, connectable %u, bondable %u, directed connectable %u, random addr %u, ads enabled %u, adv type %u \n",
|
printf("GAP: discoverable %u, connectable %u, bondable %u, directed connectable %u, random addr %u, ads enabled %u, adv type %u \n",
|
||||||
gap_discoverable, gap_connectable, gap_bondable, gap_directed_connectable, gap_random, gap_advertisements, gap_adv_type());
|
gap_discoverable, gap_connectable, gap_bondable, gap_directed_connectable, gap_random, gap_advertisements, gap_adv_type());
|
||||||
@ -655,7 +655,7 @@ void show_usage(){
|
|||||||
printf("---\n");
|
printf("---\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_advertisements(){
|
void update_advertisements(void){
|
||||||
|
|
||||||
// update adv data
|
// update adv data
|
||||||
memset(adv_data, 0, 32);
|
memset(adv_data, 0, 32);
|
||||||
@ -689,7 +689,7 @@ void update_advertisements(){
|
|||||||
gap_run();
|
gap_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void update_auth_req(){
|
void update_auth_req(void){
|
||||||
uint8_t auth_req = 0;
|
uint8_t auth_req = 0;
|
||||||
if (sm_mitm_protection){
|
if (sm_mitm_protection){
|
||||||
auth_req |= SM_AUTHREQ_MITM_PROTECTION;
|
auth_req |= SM_AUTHREQ_MITM_PROTECTION;
|
||||||
|
@ -141,11 +141,11 @@ static void send_ethernet_packet(int src_compressed, int dst_compressed){
|
|||||||
send_buffer(pos);
|
send_buffer(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_network_protocol_filter() {
|
static void set_network_protocol_filter(void){
|
||||||
bnep_set_net_type_filter(bnep_cid, network_protocol_filter, 3);
|
bnep_set_net_type_filter(bnep_cid, network_protocol_filter, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_multicast_filter() {
|
static void set_multicast_filter(void){
|
||||||
bnep_set_multicast_filter(bnep_cid, multicast_filter, 1);
|
bnep_set_multicast_filter(bnep_cid, multicast_filter, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -162,7 +162,7 @@ static void set_multicast_filter() {
|
|||||||
being probed. An ARP Request constructed this way, with an all-zero
|
being probed. An ARP Request constructed this way, with an all-zero
|
||||||
'sender IP address', is referred to as an 'ARP Probe'.
|
'sender IP address', is referred to as an 'ARP Probe'.
|
||||||
*/
|
*/
|
||||||
static void send_arp_probe_ipv4(){
|
static void send_arp_probe_ipv4(void){
|
||||||
|
|
||||||
// "random address"
|
// "random address"
|
||||||
static uint8_t requested_address[4] = {169, 254, 1, 0};
|
static uint8_t requested_address[4] = {169, 254, 1, 0};
|
||||||
@ -191,25 +191,25 @@ static void send_arp_probe_ipv4(){
|
|||||||
send_buffer(pos);
|
send_buffer(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_arp_probe_ipv6(){
|
static void send_arp_probe_ipv6(void){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static void send_dhcp_discovery(){
|
static void send_dhcp_discovery(void){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_dhcp_request(){
|
static void send_dhcp_request(void){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_dns_request(){
|
static void send_dns_request(void){
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void send_some_ipv6_packet(){
|
static void send_some_ipv6_packet(void){
|
||||||
|
|
||||||
bd_addr_t an_addr = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x16};
|
bd_addr_t an_addr = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x16};
|
||||||
memcpy(other_addr, an_addr, 6);
|
memcpy(other_addr, an_addr, 6);
|
||||||
@ -228,7 +228,7 @@ static void send_some_ipv6_packet(){
|
|||||||
send_buffer(pos);
|
send_buffer(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_some_ipv6_packet_2(){
|
static void send_some_ipv6_packet_2(void){
|
||||||
|
|
||||||
bd_addr_t an_addr = { 0x33, 0x33, 0xFF, 0x60, 0x7B, 0x87};
|
bd_addr_t an_addr = { 0x33, 0x33, 0xFF, 0x60, 0x7B, 0x87};
|
||||||
memcpy(other_addr, an_addr, 6);
|
memcpy(other_addr, an_addr, 6);
|
||||||
@ -246,7 +246,7 @@ static void send_some_ipv6_packet_2(){
|
|||||||
send_buffer(pos);
|
send_buffer(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void show_usage(){
|
static void show_usage(void){
|
||||||
|
|
||||||
printf("\n--- Bluetooth BNEP Test Console ---\n");
|
printf("\n--- Bluetooth BNEP Test Console ---\n");
|
||||||
printf("Local UUID %04x, remote UUID %04x, \n", SDP_PANU, bnep_remote_uuid);
|
printf("Local UUID %04x, remote UUID %04x, \n", SDP_PANU, bnep_remote_uuid);
|
||||||
|
@ -160,7 +160,7 @@ void do_next_remote_name_request(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void continue_remote_names(){
|
static void continue_remote_names(void){
|
||||||
// don't get remote names for testing
|
// don't get remote names for testing
|
||||||
if (has_more_remote_name_requests()){
|
if (has_more_remote_name_requests()){
|
||||||
do_next_remote_name_request();
|
do_next_remote_name_request();
|
||||||
@ -382,7 +382,7 @@ static void packet_handler2 (void * connection, uint8_t packet_type, uint16_t ch
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void update_auth_req(){
|
static void update_auth_req(void){
|
||||||
gap_auth_req = 0;
|
gap_auth_req = 0;
|
||||||
if (gap_mitm_protection){
|
if (gap_mitm_protection){
|
||||||
gap_auth_req |= 1; // MITM Flag
|
gap_auth_req |= 1; // MITM Flag
|
||||||
@ -417,7 +417,7 @@ void handle_query_rfcomm_event(sdp_query_event_t * event, void * context){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void send_ucd_packet(){
|
void send_ucd_packet(void){
|
||||||
l2cap_reserve_packet_buffer();
|
l2cap_reserve_packet_buffer();
|
||||||
int ucd_size = 50;
|
int ucd_size = 50;
|
||||||
uint8_t * ucd_buffer = l2cap_get_outgoing_buffer();
|
uint8_t * ucd_buffer = l2cap_get_outgoing_buffer();
|
||||||
@ -445,7 +445,7 @@ void heartbeat_handler(struct timer *ts){
|
|||||||
run_loop_add_timer(ts);
|
run_loop_add_timer(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_usage(){
|
void show_usage(void){
|
||||||
|
|
||||||
printf("\n--- Bluetooth Classic Test Console ---\n");
|
printf("\n--- Bluetooth Classic Test Console ---\n");
|
||||||
printf("GAP: discoverable %u, connectable %u, bondable %u, MITM %u, dedicated bonding %u, auth_req 0x0%u, %s\n",
|
printf("GAP: discoverable %u, connectable %u, bondable %u, MITM %u, dedicated bonding %u, auth_req 0x0%u, %s\n",
|
||||||
|
@ -120,7 +120,7 @@ void do_next_remote_name_request(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void continue_remote_names(){
|
static void continue_remote_names(void){
|
||||||
if (has_more_remote_name_requests()){
|
if (has_more_remote_name_requests()){
|
||||||
do_next_remote_name_request();
|
do_next_remote_name_request();
|
||||||
return;
|
return;
|
||||||
|
@ -116,7 +116,7 @@ void do_next_bonding_request(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void continue_bonding(){
|
static void continue_bonding(void){
|
||||||
if (has_more_bonding_requests()){
|
if (has_more_bonding_requests()){
|
||||||
do_next_bonding_request();
|
do_next_bonding_request();
|
||||||
return;
|
return;
|
||||||
|
@ -112,7 +112,7 @@ static void handle_hci_event(void * connection, uint8_t packet_type, uint16_t ch
|
|||||||
// GAP disconnect command when the querying is done.
|
// GAP disconnect command when the querying is done.
|
||||||
void handle_gatt_client_event(le_event_t * event);
|
void handle_gatt_client_event(le_event_t * event);
|
||||||
|
|
||||||
static void gatt_client_setup(){
|
static void gatt_client_setup(void){
|
||||||
// Initialize L2CAP and register HCI event handler
|
// Initialize L2CAP and register HCI event handler
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(&handle_hci_event);
|
l2cap_register_packet_handler(&handle_hci_event);
|
||||||
|
@ -78,7 +78,7 @@ static void send_str_over_rfcomm(uint16_t cid, char * command){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_packet(){
|
static void send_packet(void){
|
||||||
switch (hfp_service_level_connection_state){
|
switch (hfp_service_level_connection_state){
|
||||||
case 1:
|
case 1:
|
||||||
send_str_over_rfcomm(rfcomm_cid, "\r\n+BRSF: 224\r\n\r\nOK\r\n");
|
send_str_over_rfcomm(rfcomm_cid, "\r\n+BRSF: 224\r\n\r\nOK\r\n");
|
||||||
@ -89,7 +89,7 @@ static void send_packet(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
static void packet_handler(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size){
|
||||||
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
// printf("packet_handler type %u, packet[0] %x\n", packet_type, packet[0]);
|
||||||
if (packet_type == RFCOMM_DATA_PACKET){
|
if (packet_type == RFCOMM_DATA_PACKET){
|
||||||
hfp_service_level_connection_state++;
|
hfp_service_level_connection_state++;
|
||||||
|
@ -227,7 +227,7 @@ int hsp_ag_send_result(char * result){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void hsp_ag_reset_state(){
|
static void hsp_ag_reset_state(void){
|
||||||
hsp_state = HSP_IDLE;
|
hsp_state = HSP_IDLE;
|
||||||
|
|
||||||
rfcomm_cid = 0;
|
rfcomm_cid = 0;
|
||||||
@ -266,7 +266,7 @@ void hsp_ag_connect(bd_addr_t bd_addr){
|
|||||||
hsp_run();
|
hsp_run();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hsp_ag_disconnect(){
|
void hsp_ag_disconnect(void){
|
||||||
switch (hsp_state){
|
switch (hsp_state){
|
||||||
case HSP_ACTIVE:
|
case HSP_ACTIVE:
|
||||||
hsp_state = HSP_W2_DISCONNECT_SCO;
|
hsp_state = HSP_W2_DISCONNECT_SCO;
|
||||||
@ -308,32 +308,32 @@ static void hsp_timeout_handler(timer_source_t * timer){
|
|||||||
ag_ring = 1;
|
ag_ring = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_timeout_start(){
|
static void hsp_timeout_start(void){
|
||||||
run_loop_remove_timer(&hs_timeout);
|
run_loop_remove_timer(&hs_timeout);
|
||||||
run_loop_set_timer_handler(&hs_timeout, hsp_timeout_handler);
|
run_loop_set_timer_handler(&hs_timeout, hsp_timeout_handler);
|
||||||
run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
run_loop_set_timer(&hs_timeout, 2000); // 2 seconds timeout
|
||||||
run_loop_add_timer(&hs_timeout);
|
run_loop_add_timer(&hs_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_timeout_stop(){
|
static void hsp_timeout_stop(void){
|
||||||
run_loop_remove_timer(&hs_timeout);
|
run_loop_remove_timer(&hs_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hsp_ag_start_ringing(){
|
void hsp_ag_start_ringing(void){
|
||||||
if (hsp_state != HSP_W2_CONNECT_SCO) return;
|
if (hsp_state != HSP_W2_CONNECT_SCO) return;
|
||||||
ag_ring = 1;
|
ag_ring = 1;
|
||||||
hsp_state = HSP_W4_RING_ANSWER;
|
hsp_state = HSP_W4_RING_ANSWER;
|
||||||
hsp_timeout_start();
|
hsp_timeout_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hsp_ag_stop_ringing(){
|
void hsp_ag_stop_ringing(void){
|
||||||
ag_ring = 0;
|
ag_ring = 0;
|
||||||
ag_num_button_press_received = 0;
|
ag_num_button_press_received = 0;
|
||||||
hsp_state = HSP_W2_CONNECT_SCO;
|
hsp_state = HSP_W2_CONNECT_SCO;
|
||||||
hsp_timeout_stop();
|
hsp_timeout_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_run(){
|
static void hsp_run(void){
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (ag_send_ok){
|
if (ag_send_ok){
|
||||||
|
@ -76,9 +76,9 @@ static bd_addr_t pts_addr = {0x00,0x1b,0xDC,0x07,0x32,0xEF};
|
|||||||
|
|
||||||
static char hs_cmd_buffer[100];
|
static char hs_cmd_buffer[100];
|
||||||
// prototypes
|
// prototypes
|
||||||
static void show_usage();
|
static void show_usage(void);
|
||||||
|
|
||||||
static void show_usage(){
|
static void show_usage(void){
|
||||||
printf("\n--- Bluetooth HSP AudioGateway Test Console ---\n");
|
printf("\n--- Bluetooth HSP AudioGateway Test Console ---\n");
|
||||||
printf("---\n");
|
printf("---\n");
|
||||||
printf("p - establish audio connection to PTS module\n");
|
printf("p - establish audio connection to PTS module\n");
|
||||||
|
@ -230,7 +230,7 @@ void hsp_hs_create_service(uint8_t * service, int rfcomm_channel_nr, const char
|
|||||||
de_add_number(service, DE_BOOL, DE_SIZE_8, have_remote_audio_control);
|
de_add_number(service, DE_BOOL, DE_SIZE_8, have_remote_audio_control);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hsp_hs_reset_state(){
|
static void hsp_hs_reset_state(void){
|
||||||
hsp_state = HSP_IDLE;
|
hsp_state = HSP_IDLE;
|
||||||
|
|
||||||
rfcomm_cid = 0;
|
rfcomm_cid = 0;
|
||||||
@ -306,7 +306,7 @@ void hsp_hs_set_speaker_gain(uint8_t gain){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void hsp_run(){
|
static void hsp_run(void){
|
||||||
int err;
|
int err;
|
||||||
if (hs_ring_received){
|
if (hs_ring_received){
|
||||||
hs_ring_received = 0;
|
hs_ring_received = 0;
|
||||||
|
@ -84,7 +84,7 @@ static void show_usage();
|
|||||||
// Testig User Interface
|
// Testig User Interface
|
||||||
static data_source_t stdin_source;
|
static data_source_t stdin_source;
|
||||||
|
|
||||||
static void show_usage(){
|
static void show_usage(void){
|
||||||
printf("\n--- Bluetooth HSP Headset Test Console ---\n");
|
printf("\n--- Bluetooth HSP Headset Test Console ---\n");
|
||||||
printf("---\n");
|
printf("---\n");
|
||||||
printf("p - establish audio connection to PTS module\n");
|
printf("p - establish audio connection to PTS module\n");
|
||||||
@ -151,7 +151,7 @@ static int stdin_process(struct data_source *ds){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void setup_cli(){
|
static void setup_cli(void){
|
||||||
struct termios term = {0};
|
struct termios term = {0};
|
||||||
if (tcgetattr(0, &term) < 0)
|
if (tcgetattr(0, &term) < 0)
|
||||||
perror("tcsetattr()");
|
perror("tcsetattr()");
|
||||||
|
@ -114,7 +114,7 @@ static void packet_handler2 (void * connection, uint8_t packet_type, uint16_t ch
|
|||||||
packet_handler(packet_type, 0, packet, size);
|
packet_handler(packet_type, 0, packet, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void show_usage(){
|
void show_usage(void){
|
||||||
printf("\n--- CLI for L2CAP TEST ---\n");
|
printf("\n--- CLI for L2CAP TEST ---\n");
|
||||||
printf("c - create connection to SDP at addr %s\n", bd_addr_to_str(remote));
|
printf("c - create connection to SDP at addr %s\n", bd_addr_to_str(remote));
|
||||||
printf("s - send data\n");
|
printf("s - send data\n");
|
||||||
|
@ -89,7 +89,7 @@ static uint16_t att_read_callback(uint16_t con_handle, uint16_t att_handle, uint
|
|||||||
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
|
static int att_write_callback(uint16_t con_handle, uint16_t att_handle, uint16_t transaction_mode, uint16_t offset, uint8_t *buffer, uint16_t buffer_size);
|
||||||
static void heartbeat_handler(struct timer *ts);
|
static void heartbeat_handler(struct timer *ts);
|
||||||
|
|
||||||
static void le_counter_setup(){
|
static void le_counter_setup(void){
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ enum {
|
|||||||
};
|
};
|
||||||
static uint16_t todos = 0;
|
static uint16_t todos = 0;
|
||||||
|
|
||||||
static void gap_run(){
|
static void gap_run(void){
|
||||||
|
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ static data_source_t tap_dev_ds;
|
|||||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
static void handle_sdp_client_query_result(sdp_query_event_t *event);
|
static void handle_sdp_client_query_result(sdp_query_event_t *event);
|
||||||
|
|
||||||
static void panu_setup(){
|
static void panu_setup(void){
|
||||||
// Initialize L2CAP
|
// Initialize L2CAP
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
|
@ -93,7 +93,7 @@ static void assertBuffer(int size){
|
|||||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
||||||
|
|
||||||
static void sdp_client_init(){
|
static void sdp_client_init(void){
|
||||||
// init L2CAP
|
// init L2CAP
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
|
@ -82,7 +82,7 @@ static const int attribute_value_buffer_size = sizeof(attribute_value);
|
|||||||
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
static void packet_handler (void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size);
|
||||||
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
static void handle_sdp_client_query_result(sdp_query_event_t * event);
|
||||||
|
|
||||||
static void sdp_client_init(){
|
static void sdp_client_init(void){
|
||||||
// init L2CAP
|
// init L2CAP
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
|
@ -93,7 +93,7 @@ void store_found_service(uint8_t * name, uint8_t port){
|
|||||||
service_index++;
|
service_index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void report_found_services(){
|
void report_found_services(void){
|
||||||
printf("\n *** Client query response done. ");
|
printf("\n *** Client query response done. ");
|
||||||
if (service_index == 0){
|
if (service_index == 0){
|
||||||
printf("No service found.\n\n");
|
printf("No service found.\n\n");
|
||||||
|
@ -111,7 +111,7 @@ enum {
|
|||||||
};
|
};
|
||||||
static uint16_t todos = 0;
|
static uint16_t todos = 0;
|
||||||
|
|
||||||
static void gap_run(){
|
static void gap_run(void){
|
||||||
|
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ static uint8_t spp_service_buffer[150];
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* LISTING_START(SPPSetup): SPP service setup */
|
/* LISTING_START(SPPSetup): SPP service setup */
|
||||||
void spp_service_setup(){
|
void spp_service_setup(void){
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
|
|
||||||
@ -144,7 +144,7 @@ static void heartbeat_handler(struct timer *ts){
|
|||||||
run_loop_add_timer(ts);
|
run_loop_add_timer(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void one_shot_timer_setup(){
|
static void one_shot_timer_setup(void){
|
||||||
// set one-shot timer
|
// set one-shot timer
|
||||||
heartbeat.process = &heartbeat_handler;
|
heartbeat.process = &heartbeat_handler;
|
||||||
run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
||||||
|
@ -79,7 +79,7 @@ static uint8_t spp_service_buffer[150];
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* LISTING_START(explicitFlowControl): Providing one initial credit during RFCOMM service initialization */
|
/* LISTING_START(explicitFlowControl): Providing one initial credit during RFCOMM service initialization */
|
||||||
static void spp_service_setup(){
|
static void spp_service_setup(void){
|
||||||
// init L2CAP
|
// init L2CAP
|
||||||
l2cap_init();
|
l2cap_init();
|
||||||
l2cap_register_packet_handler(packet_handler);
|
l2cap_register_packet_handler(packet_handler);
|
||||||
@ -125,7 +125,7 @@ static void heartbeat_handler(struct timer *ts){
|
|||||||
}
|
}
|
||||||
/* LISTING_END */
|
/* LISTING_END */
|
||||||
|
|
||||||
static void one_shot_timer_setup(){
|
static void one_shot_timer_setup(void){
|
||||||
heartbeat.process = &heartbeat_handler;
|
heartbeat.process = &heartbeat_handler;
|
||||||
run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
run_loop_set_timer(&heartbeat, HEARTBEAT_PERIOD_MS);
|
||||||
run_loop_add_timer(&heartbeat);
|
run_loop_add_timer(&heartbeat);
|
||||||
|
@ -95,7 +95,7 @@ static void create_test_data(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_packet(){
|
static void send_packet(void){
|
||||||
int err = rfcomm_send_internal(rfcomm_cid, (uint8_t*) test_data, test_data_len);
|
int err = rfcomm_send_internal(rfcomm_cid, (uint8_t*) test_data, test_data_len);
|
||||||
if (err){
|
if (err){
|
||||||
printf("rfcomm_send_internal -> error 0X%02x", err);
|
printf("rfcomm_send_internal -> error 0X%02x", err);
|
||||||
|
@ -246,7 +246,7 @@ static int nibble_for_char(const char c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// UUID class
|
/// UUID class
|
||||||
UUID::UUID(){
|
UUID::UUID(void){
|
||||||
memset(uuid, 0, 16);
|
memset(uuid, 0, 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -311,7 +311,7 @@ bool UUID::matches(UUID *other) const {
|
|||||||
|
|
||||||
|
|
||||||
// BD_ADDR class
|
// BD_ADDR class
|
||||||
BD_ADDR::BD_ADDR(){
|
BD_ADDR::BD_ADDR(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
BD_ADDR::BD_ADDR(const char * address_string, BD_ADDR_TYPE address_type ) : address_type(address_type) {
|
BD_ADDR::BD_ADDR(const char * address_string, BD_ADDR_TYPE address_type ) : address_type(address_type) {
|
||||||
@ -323,15 +323,15 @@ BD_ADDR::BD_ADDR(const uint8_t address[6], BD_ADDR_TYPE address_type) : address_
|
|||||||
memcpy(this->address, address, 6);
|
memcpy(this->address, address, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t * BD_ADDR::getAddress(){
|
const uint8_t * BD_ADDR::getAddress(void){
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char * BD_ADDR::getAddressString(){
|
const char * BD_ADDR::getAddressString(void){
|
||||||
return bd_addr_to_str(address);
|
return bd_addr_to_str(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
BD_ADDR_TYPE BD_ADDR::getAddressType(){
|
BD_ADDR_TYPE BD_ADDR::getAddressType(void){
|
||||||
return address_type;
|
return address_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ data_length(event_packet[11])
|
|||||||
memcpy(data, &event_packet[12], LE_ADVERTISING_DATA_SIZE);
|
memcpy(data, &event_packet[12], LE_ADVERTISING_DATA_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t * BLEAdvertisement::getAdvData(){
|
const uint8_t * BLEAdvertisement::getAdvData(void){
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +355,7 @@ BD_ADDR * BLEAdvertisement::getBdAddr(void){
|
|||||||
return &bd_addr;
|
return &bd_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
int BLEAdvertisement::getRssi(){
|
int BLEAdvertisement::getRssi(void){
|
||||||
return rssi > 127 ? rssi - 256 : rssi;
|
return rssi > 127 ? rssi - 256 : rssi;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,33 +368,33 @@ bool BLEAdvertisement::nameHasPrefix(const char * namePrefix){
|
|||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool BLEAdvertisement::isIBeacon(){
|
bool BLEAdvertisement::isIBeacon(void){
|
||||||
return ((memcmp(iBeaconAdvertisement01, data, sizeof(iBeaconAdvertisement01)) == 0)
|
return ((memcmp(iBeaconAdvertisement01, data, sizeof(iBeaconAdvertisement01)) == 0)
|
||||||
&& (memcmp(iBeaconAdvertisement38, &data[3], sizeof(iBeaconAdvertisement38)) == 0));
|
&& (memcmp(iBeaconAdvertisement38, &data[3], sizeof(iBeaconAdvertisement38)) == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
const UUID * BLEAdvertisement::getIBeaconUUID(){
|
const UUID * BLEAdvertisement::getIBeaconUUID(void){
|
||||||
return new UUID(&data[9]);
|
return new UUID(&data[9]);
|
||||||
};
|
};
|
||||||
uint16_t BLEAdvertisement::getIBeaconMajorID(){
|
uint16_t BLEAdvertisement::getIBeaconMajorID(void){
|
||||||
return READ_NET_16(data, 25);
|
return READ_NET_16(data, 25);
|
||||||
};
|
};
|
||||||
uint16_t BLEAdvertisement::getIBecaonMinorID(){
|
uint16_t BLEAdvertisement::getIBecaonMinorID(void){
|
||||||
return READ_NET_16(data, 27);
|
return READ_NET_16(data, 27);
|
||||||
};
|
};
|
||||||
uint8_t BLEAdvertisement::getiBeaconMeasuredPower(){
|
uint8_t BLEAdvertisement::getiBeaconMeasuredPower(void){
|
||||||
return data[29];
|
return data[29];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BLECharacteristic::BLECharacteristic() {
|
BLECharacteristic::BLECharacteristic(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
BLECharacteristic::BLECharacteristic(le_characteristic_t characteristic)
|
BLECharacteristic::BLECharacteristic(le_characteristic_t characteristic)
|
||||||
: characteristic(characteristic), uuid(characteristic.uuid128) {
|
: characteristic(characteristic), uuid(characteristic.uuid128) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const UUID * BLECharacteristic::getUUID(){
|
const UUID * BLECharacteristic::getUUID(void){
|
||||||
return &uuid;
|
return &uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -406,19 +406,19 @@ bool BLECharacteristic::isValueHandle(uint16_t value_handle){
|
|||||||
return characteristic.value_handle == value_handle;
|
return characteristic.value_handle == value_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
const le_characteristic_t * BLECharacteristic::getCharacteristic() {
|
const le_characteristic_t * BLECharacteristic::getCharacteristic(void){
|
||||||
return &characteristic;
|
return &characteristic;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BLEService::BLEService(){
|
BLEService::BLEService(void){
|
||||||
}
|
}
|
||||||
|
|
||||||
BLEService::BLEService(le_service_t service)
|
BLEService::BLEService(le_service_t service)
|
||||||
: service(service), uuid(service.uuid128){
|
: service(service), uuid(service.uuid128){
|
||||||
}
|
}
|
||||||
|
|
||||||
const UUID * BLEService::getUUID(){
|
const UUID * BLEService::getUUID(void){
|
||||||
return &uuid;
|
return &uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,20 +426,20 @@ bool BLEService::matches(UUID * uuid){
|
|||||||
return this->uuid.matches(uuid);
|
return this->uuid.matches(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
const le_service_t * BLEService::getService(){
|
const le_service_t * BLEService::getService(void){
|
||||||
return &service;
|
return &service;
|
||||||
}
|
}
|
||||||
|
|
||||||
// discovery of services and characteristics
|
// discovery of services and characteristics
|
||||||
BLEDevice::BLEDevice(){
|
BLEDevice::BLEDevice(void){
|
||||||
}
|
}
|
||||||
BLEDevice::BLEDevice(uint16_t handle)
|
BLEDevice::BLEDevice(uint16_t handle)
|
||||||
: handle(handle){
|
: handle(handle){
|
||||||
}
|
}
|
||||||
uint16_t BLEDevice::getHandle(){
|
uint16_t BLEDevice::getHandle(void){
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
int BLEDevice::discoverGATTServices(){
|
int BLEDevice::discoverGATTServices(void){
|
||||||
return BTstack.discoverGATTServices(this);
|
return BTstack.discoverGATTServices(this);
|
||||||
}
|
}
|
||||||
int BLEDevice::discoverCharacteristicsForService(BLEService * service){
|
int BLEDevice::discoverCharacteristicsForService(BLEService * service){
|
||||||
@ -468,7 +468,7 @@ int BLEDevice::unsubscribeFromIndications(BLECharacteristic * characteristic){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
BTstackManager::BTstackManager() {
|
BTstackManager::BTstackManager(void){
|
||||||
// client_packet_handler = NULL;
|
// client_packet_handler = NULL;
|
||||||
have_custom_addr = false;
|
have_custom_addr = false;
|
||||||
// reset handler
|
// reset handler
|
||||||
@ -580,7 +580,7 @@ void BTstackManager::registerPacketHandler(btstack_packet_handler_t packet_handl
|
|||||||
// client_packet_handler = packet_handler;
|
// client_packet_handler = packet_handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTstackManager::setClientMode(){
|
void BTstackManager::setClientMode(void){
|
||||||
client_mode = 1;
|
client_mode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -596,7 +596,7 @@ void BTstackManager::setPublicBdAddr(bd_addr_t addr){
|
|||||||
|
|
||||||
// static hci_uart_config_t config;
|
// static hci_uart_config_t config;
|
||||||
|
|
||||||
void BTstackManager::setup(){
|
void BTstackManager::setup(void){
|
||||||
|
|
||||||
#ifdef PIN_LED
|
#ifdef PIN_LED
|
||||||
pinMode(PIN_LED, OUTPUT);
|
pinMode(PIN_LED, OUTPUT);
|
||||||
@ -641,18 +641,18 @@ void BTstackManager::setup(){
|
|||||||
printf("--> READY <--\n");
|
printf("--> READY <--\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTstackManager::loop(){
|
void BTstackManager::loop(void){
|
||||||
// process data from/to Bluetooth module
|
// process data from/to Bluetooth module
|
||||||
hal_uart_dma_process();
|
hal_uart_dma_process();
|
||||||
// BTstack Run Loop
|
// BTstack Run Loop
|
||||||
embedded_execute_once();
|
embedded_execute_once();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BTstackManager::bleStartScanning(){
|
void BTstackManager::bleStartScanning(void){
|
||||||
printf("Start scanning\n");
|
printf("Start scanning\n");
|
||||||
le_central_start_scan();
|
le_central_start_scan();
|
||||||
}
|
}
|
||||||
void BTstackManager::bleStopScanning(){
|
void BTstackManager::bleStopScanning(void){
|
||||||
le_central_stop_scan();
|
le_central_stop_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ static void bt_power_cycle(void){
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_SHUTDOWN
|
#ifndef HAVE_SHUTDOWN
|
||||||
static void bt_send_illegal(){
|
static void bt_send_illegal(void){
|
||||||
digitalWrite(PIN_MOSI, HIGH);
|
digitalWrite(PIN_MOSI, HIGH);
|
||||||
digitalWrite(PIN_CS, LOW);
|
digitalWrite(PIN_CS, LOW);
|
||||||
printf("Illegal start\n");
|
printf("Illegal start\n");
|
||||||
@ -104,7 +104,7 @@ static void bt_send_illegal(){
|
|||||||
digitalWrite(PIN_CS, HIGH);
|
digitalWrite(PIN_CS, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bt_flush_input(){
|
static void bt_flush_input(void){
|
||||||
digitalWrite(PIN_MOSI, LOW);
|
digitalWrite(PIN_MOSI, LOW);
|
||||||
digitalWrite(PIN_CS, LOW);
|
digitalWrite(PIN_CS, LOW);
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
@ -115,7 +115,7 @@ static void bt_flush_input(){
|
|||||||
digitalWrite(PIN_CS, HIGH);
|
digitalWrite(PIN_CS, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bt_send_reset(){
|
static void bt_send_reset(void){
|
||||||
digitalWrite(PIN_MOSI, HIGH);
|
digitalWrite(PIN_MOSI, HIGH);
|
||||||
digitalWrite(PIN_CS, LOW);
|
digitalWrite(PIN_CS, LOW);
|
||||||
SPI.begin();
|
SPI.begin();
|
||||||
@ -242,14 +242,14 @@ extern "C" void hal_uart_dma_set_sleep(uint8_t sleep){
|
|||||||
// not needed for SPI (doesn't need internal clock to work)
|
// not needed for SPI (doesn't need internal clock to work)
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" void hal_uart_dma_process(){
|
extern "C" void hal_uart_dma_process(void){
|
||||||
int num_bytes_read = bt_try_read();
|
int num_bytes_read = bt_try_read();
|
||||||
if (num_bytes_read == 0){
|
if (num_bytes_read == 0){
|
||||||
bt_try_send();
|
bt_try_send();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" uint32_t hal_time_ms(){
|
extern "C" uint32_t hal_time_ms(void){
|
||||||
return millis();
|
return millis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ void ancs_callback(ancs_event_t * event){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
setup_printf();
|
setup_printf();
|
||||||
printf("Main::Setup()\n");
|
printf("Main::Setup()\n");
|
||||||
BT.setup();
|
BT.setup();
|
||||||
@ -86,6 +86,6 @@ void setup(){
|
|||||||
ancs_client_register_callback(&ancs_callback);
|
ancs_client_register_callback(&ancs_callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop(){
|
void loop(void){
|
||||||
BT.loop();
|
BT.loop();
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ static void setup_printf(int baud) {
|
|||||||
stdout = &uartout;
|
stdout = &uartout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup(void){
|
||||||
|
|
||||||
setup_printf(9600);
|
setup_printf(9600);
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop(void){
|
||||||
BTstack.loop();
|
BTstack.loop();
|
||||||
|
|
||||||
// send counter as fast as possible
|
// send counter as fast as possible
|
||||||
|
@ -16,7 +16,7 @@ static void setup_printf(int baud) {
|
|||||||
stdout = &uartout;
|
stdout = &uartout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup(void){
|
||||||
|
|
||||||
setup_printf(9600);
|
setup_printf(9600);
|
||||||
|
|
||||||
@ -40,7 +40,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop(void){
|
||||||
BTstack.loop();
|
BTstack.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@ static void setup_printf(int baud) {
|
|||||||
stdout = &uartout;
|
stdout = &uartout;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup() {
|
void setup(void){
|
||||||
setup_printf(9600);
|
setup_printf(9600);
|
||||||
|
|
||||||
BTstack.setBLEAdvertisementCallback(advertisementCallback);
|
BTstack.setBLEAdvertisementCallback(advertisementCallback);
|
||||||
@ -23,7 +23,7 @@ void setup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loop() {
|
void loop(void){
|
||||||
BTstack.loop();
|
BTstack.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ void bt_use_tcp(const char * address, uint16_t port){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// init BTstack library
|
// init BTstack library
|
||||||
int bt_open(){
|
int bt_open(void){
|
||||||
|
|
||||||
socket_connection_register_packet_callback(btstack_packet_handler);
|
socket_connection_register_packet_callback(btstack_packet_handler);
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ int bt_open(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// stop using BTstack library
|
// stop using BTstack library
|
||||||
int bt_close(){
|
int bt_close(void){
|
||||||
return socket_connection_close_tcp(btstack_connection);
|
return socket_connection_close_tcp(btstack_connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1262,7 +1262,7 @@ const uint8_t adv_data[] = {
|
|||||||
uint8_t adv_data_len = sizeof(adv_data);
|
uint8_t adv_data_len = sizeof(adv_data);
|
||||||
static uint16_t todos = 0;
|
static uint16_t todos = 0;
|
||||||
|
|
||||||
static void app_run(){
|
static void app_run(void){
|
||||||
|
|
||||||
if (!hci_can_send_command_packet_now()) return;
|
if (!hci_can_send_command_packet_now()) return;
|
||||||
|
|
||||||
|
@ -260,7 +260,7 @@ int socket_connection_hci_process(struct data_source *ds) {
|
|||||||
* if dispatch is successful, a connection is added again to run loop
|
* if dispatch is successful, a connection is added again to run loop
|
||||||
* pre: connections get parked iff packet was dispatched but could not be sent
|
* pre: connections get parked iff packet was dispatched but could not be sent
|
||||||
*/
|
*/
|
||||||
void socket_connection_retry_parked(){
|
void socket_connection_retry_parked(void){
|
||||||
// log_info("socket_connection_hci_process retry parked");
|
// log_info("socket_connection_hci_process retry parked");
|
||||||
linked_item_t *it = (linked_item_t *) &parked;
|
linked_item_t *it = (linked_item_t *) &parked;
|
||||||
while (it->next) {
|
while (it->next) {
|
||||||
@ -382,7 +382,7 @@ void socket_connection_launchd_register_fd_array(launch_data_t listening_fd_arra
|
|||||||
/**
|
/**
|
||||||
* create socket data_source for socket specified by launchd configuration
|
* create socket data_source for socket specified by launchd configuration
|
||||||
*/
|
*/
|
||||||
int socket_connection_create_launchd(){
|
int socket_connection_create_launchd(void){
|
||||||
|
|
||||||
launch_data_t sockets_dict, checkin_response;
|
launch_data_t sockets_dict, checkin_response;
|
||||||
launch_data_t checkin_request;
|
launch_data_t checkin_request;
|
||||||
@ -589,7 +589,7 @@ int socket_connection_close_tcp(connection_t * connection){
|
|||||||
/**
|
/**
|
||||||
* create socket connection to BTdaemon
|
* create socket connection to BTdaemon
|
||||||
*/
|
*/
|
||||||
connection_t * socket_connection_open_unix(){
|
connection_t * socket_connection_open_unix(void){
|
||||||
|
|
||||||
int btsocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
int btsocket = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||||
if(btsocket == -1){
|
if(btsocket == -1){
|
||||||
|
@ -80,7 +80,7 @@ static uint8_t spp_service_buffer[150];
|
|||||||
// SPP description
|
// SPP description
|
||||||
static uint8_t accel_buffer[6];
|
static uint8_t accel_buffer[6];
|
||||||
|
|
||||||
static void prepare_accel_packet(){
|
static void prepare_accel_packet(void){
|
||||||
int16_t accl_x;
|
int16_t accl_x;
|
||||||
int16_t accl_y;
|
int16_t accl_y;
|
||||||
int16_t accl_z;
|
int16_t accl_z;
|
||||||
@ -106,7 +106,7 @@ static void prepare_accel_packet(){
|
|||||||
printf("Accel: X: %04d, Y: %04d, Z: %04d\n\r", accl_x, accl_y, accl_z);
|
printf("Accel: X: %04d, Y: %04d, Z: %04d\n\r", accl_x, accl_y, accl_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_packet(){
|
static void send_packet(void){
|
||||||
int err = rfcomm_send_internal(rfcomm_channel_id, (uint8_t *)accel_buffer, sizeof(accel_buffer));
|
int err = rfcomm_send_internal(rfcomm_channel_id, (uint8_t *)accel_buffer, sizeof(accel_buffer));
|
||||||
switch(err){
|
switch(err){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -87,7 +87,7 @@ void halUsbSendChar(char character)
|
|||||||
UCA3TXBUF = character;
|
UCA3TXBUF = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
char halUsbRecvChar(){
|
char halUsbRecvChar(void){
|
||||||
while (!(UCA3IFG & UCRXIFG));
|
while (!(UCA3IFG & UCRXIFG));
|
||||||
return UCA3RXBUF;
|
return UCA3RXBUF;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
||||||
|
|
||||||
void hal_cpu_disable_irqs(){
|
void hal_cpu_disable_irqs(void){
|
||||||
|
|
||||||
// LED off
|
// LED off
|
||||||
LED1_OUT &= ~LED1_PIN;
|
LED1_OUT &= ~LED1_PIN;
|
||||||
@ -61,7 +61,7 @@ void hal_cpu_disable_irqs(){
|
|||||||
__bic_SR_register(GIE);
|
__bic_SR_register(GIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs(){
|
void hal_cpu_enable_irqs(void){
|
||||||
|
|
||||||
// enable irq
|
// enable irq
|
||||||
__bis_SR_register(GIE);
|
__bis_SR_register(GIE);
|
||||||
@ -80,7 +80,7 @@ void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){
|
|||||||
low_power_mode_for_sleep = LPM3_bits;
|
low_power_mode_for_sleep = LPM3_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs_and_sleep(){
|
void hal_cpu_enable_irqs_and_sleep(void){
|
||||||
|
|
||||||
// enable irq and enter lpm0
|
// enable irq and enter lpm0
|
||||||
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
static CFMessagePortRef springBoardAccessMessagePort = 0;
|
static CFMessagePortRef springBoardAccessMessagePort = 0;
|
||||||
|
|
||||||
|
|
||||||
static void SBA_refresh(){
|
static void SBA_refresh(void){
|
||||||
// still valid
|
// still valid
|
||||||
if (springBoardAccessMessagePort && !CFMessagePortIsValid(springBoardAccessMessagePort)){
|
if (springBoardAccessMessagePort && !CFMessagePortIsValid(springBoardAccessMessagePort)){
|
||||||
CFRelease(springBoardAccessMessagePort);
|
CFRelease(springBoardAccessMessagePort);
|
||||||
@ -55,7 +55,7 @@ static void SBA_refresh(){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int SBA_available(){
|
int SBA_available(void){
|
||||||
SBA_refresh();
|
SBA_refresh();
|
||||||
if (springBoardAccessMessagePort) return 1;
|
if (springBoardAccessMessagePort) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
@ -88,7 +88,7 @@ int SBA_removeStatusBarImage(char *name){
|
|||||||
return SBA_sendMessage(SBAC_removeStatusBarImage, strlen(name), (UInt8*) name, NULL);
|
return SBA_sendMessage(SBAC_removeStatusBarImage, strlen(name), (UInt8*) name, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SBA_getBluetoothEnabled() {
|
int SBA_getBluetoothEnabled(void){
|
||||||
CFDataRef cfData;
|
CFDataRef cfData;
|
||||||
int result = SBA_sendMessage(SBAC_getBluetoothEnabled, 0, NULL, &cfData);
|
int result = SBA_sendMessage(SBAC_getBluetoothEnabled, 0, NULL, &cfData);
|
||||||
if (result == 0){
|
if (result == 0){
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
#define kAppNetwork CFSTR("com.apple.preferences.network")
|
#define kAppNetwork CFSTR("com.apple.preferences.network")
|
||||||
#define kKeyBTNetwork CFSTR("bluetooth-network")
|
#define kKeyBTNetwork CFSTR("bluetooth-network")
|
||||||
|
|
||||||
int iphone_system_bt_enabled(){
|
int iphone_system_bt_enabled(void){
|
||||||
if ([[BluetoothManager sharedInstance] enabled]) {
|
if ([[BluetoothManager sharedInstance] enabled]) {
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
|
@ -151,14 +151,14 @@ static NSTimeInterval getTime(void){
|
|||||||
/**
|
/**
|
||||||
* check OS version for >= 4.0
|
* check OS version for >= 4.0
|
||||||
*/
|
*/
|
||||||
static int iphone_os_at_least_40(){
|
static int iphone_os_at_least_40(void){
|
||||||
return kCFCoreFoundationVersionNumber >= 550.32;
|
return kCFCoreFoundationVersionNumber >= 550.32;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check OS version for >= 6.0
|
* check OS version for >= 6.0
|
||||||
*/
|
*/
|
||||||
static int iphone_os_at_least_60(){
|
static int iphone_os_at_least_60(void){
|
||||||
return kCFCoreFoundationVersionNumber >= 788.0;
|
return kCFCoreFoundationVersionNumber >= 788.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,7 +185,7 @@ static const char * iphone_name(void *config){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get BD_ADDR from IORegistry
|
// Get BD_ADDR from IORegistry
|
||||||
static void ioregistry_get_info() {
|
static void ioregistry_get_info(void){
|
||||||
mach_port_t mp;
|
mach_port_t mp;
|
||||||
IOMasterPort(MACH_PORT_NULL,&mp);
|
IOMasterPort(MACH_PORT_NULL,&mp);
|
||||||
CFMutableDictionaryRef bt_matching = IOServiceNameMatching("bluetooth");
|
CFMutableDictionaryRef bt_matching = IOServiceNameMatching("bluetooth");
|
||||||
@ -207,7 +207,7 @@ static void ioregistry_get_info() {
|
|||||||
log_info("transport-speed: %u\n", transport_speed);
|
log_info("transport-speed: %u\n", transport_speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int iphone_has_csr(){
|
static int iphone_has_csr(void){
|
||||||
// construct script path from device name
|
// construct script path from device name
|
||||||
char *machine = get_machine_name();
|
char *machine = get_machine_name();
|
||||||
if (strncmp(machine, "iPhone1,", strlen("iPhone1,")) == 0) {
|
if (strncmp(machine, "iPhone1,", strlen("iPhone1,")) == 0) {
|
||||||
|
@ -228,7 +228,7 @@ err_out0:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h4_close(){
|
static int h4_close(void *transport_config){
|
||||||
// first remove run loop handler
|
// first remove run loop handler
|
||||||
run_loop_remove_data_source(hci_transport_h4->ds);
|
run_loop_remove_data_source(hci_transport_h4->ds);
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get h4 singleton
|
// get h4 singleton
|
||||||
hci_transport_t * hci_transport_h4_iphone_instance() {
|
hci_transport_t * hci_transport_h4_iphone_instance(void){
|
||||||
if (hci_transport_h4 == NULL) {
|
if (hci_transport_h4 == NULL) {
|
||||||
hci_transport_h4 = malloc( sizeof(hci_transport_h4_t));
|
hci_transport_h4 = malloc( sizeof(hci_transport_h4_t));
|
||||||
hci_transport_h4->ds = NULL;
|
hci_transport_h4->ds = NULL;
|
||||||
|
@ -76,7 +76,7 @@ void platform_iphone_status_handler(BLUETOOTH_STATE state){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void (*window_manager_restart_callback)() = NULL;
|
static void (*window_manager_restart_callback)() = NULL;
|
||||||
static void springBoardDidLaunch(){
|
static void springBoardDidLaunch(void){
|
||||||
NSLog(@"springBoardDidLaunch!\n");
|
NSLog(@"springBoardDidLaunch!\n");
|
||||||
if (window_manager_restart_callback) {
|
if (window_manager_restart_callback) {
|
||||||
int timer;
|
int timer;
|
||||||
@ -104,7 +104,7 @@ void platform_iphone_register_window_manager_restart(void (*callback)() ){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void (*preferences_changed_callback)() = NULL;
|
static void (*preferences_changed_callback)() = NULL;
|
||||||
static void preferencesDidChange(){
|
static void preferencesDidChange(void){
|
||||||
NSLog(@"ch.ringwald.btstack.preferences!\n");
|
NSLog(@"ch.ringwald.btstack.preferences!\n");
|
||||||
if (preferences_changed_callback) {
|
if (preferences_changed_callback) {
|
||||||
(*preferences_changed_callback)();
|
(*preferences_changed_callback)();
|
||||||
|
@ -75,7 +75,7 @@ static void sigint_handler(int param){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int led_state = 0;
|
static int led_state = 0;
|
||||||
void hal_led_toggle(){
|
void hal_led_toggle(void){
|
||||||
led_state = 1 - led_state;
|
led_state = 1 - led_state;
|
||||||
printf("LED State %u\n", led_state);
|
printf("LED State %u\n", led_state);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ static uint8_t spp_service_buffer[150];
|
|||||||
// SPP description
|
// SPP description
|
||||||
static uint8_t accel_buffer[6];
|
static uint8_t accel_buffer[6];
|
||||||
|
|
||||||
static void prepare_accel_packet(){
|
static void prepare_accel_packet(void){
|
||||||
int16_t accl_x;
|
int16_t accl_x;
|
||||||
int16_t accl_y;
|
int16_t accl_y;
|
||||||
int16_t accl_z;
|
int16_t accl_z;
|
||||||
@ -106,7 +106,7 @@ static void prepare_accel_packet(){
|
|||||||
printf("Accel: X: %04d, Y: %04d, Z: %04d\n\r", accl_x, accl_y, accl_z);
|
printf("Accel: X: %04d, Y: %04d, Z: %04d\n\r", accl_x, accl_y, accl_z);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_packet(){
|
static void send_packet(void){
|
||||||
int err = rfcomm_send_internal(rfcomm_channel_id, (uint8_t *)accel_buffer, sizeof(accel_buffer));
|
int err = rfcomm_send_internal(rfcomm_channel_id, (uint8_t *)accel_buffer, sizeof(accel_buffer));
|
||||||
switch(err){
|
switch(err){
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -79,7 +79,7 @@ void halUsbSendChar(char character)
|
|||||||
UCA1TXBUF = character;
|
UCA1TXBUF = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
char halUsbRecvChar(){
|
char halUsbRecvChar(void){
|
||||||
while (!(UCA1IFG & UCRXIFG));
|
while (!(UCA1IFG & UCRXIFG));
|
||||||
return UCA1RXBUF;
|
return UCA1RXBUF;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
||||||
|
|
||||||
void hal_cpu_disable_irqs(){
|
void hal_cpu_disable_irqs(void){
|
||||||
|
|
||||||
// LED off
|
// LED off
|
||||||
LED1_OUT &= ~LED1_PIN;
|
LED1_OUT &= ~LED1_PIN;
|
||||||
@ -61,7 +61,7 @@ void hal_cpu_disable_irqs(){
|
|||||||
__bic_SR_register(GIE);
|
__bic_SR_register(GIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs(){
|
void hal_cpu_enable_irqs(void){
|
||||||
|
|
||||||
// enable irq
|
// enable irq
|
||||||
__bis_SR_register(GIE);
|
__bis_SR_register(GIE);
|
||||||
@ -80,7 +80,7 @@ void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){
|
|||||||
low_power_mode_for_sleep = LPM3_bits;
|
low_power_mode_for_sleep = LPM3_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs_and_sleep(){
|
void hal_cpu_enable_irqs_and_sleep(void){
|
||||||
|
|
||||||
// enable irq and enter lpm0
|
// enable irq and enter lpm0
|
||||||
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
||||||
|
@ -62,7 +62,7 @@
|
|||||||
#include "remote_device_db.h"
|
#include "remote_device_db.h"
|
||||||
#include "btstack-config.h"
|
#include "btstack-config.h"
|
||||||
|
|
||||||
static void hw_setup(){
|
static void hw_setup(void){
|
||||||
// stop watchdog timer
|
// stop watchdog timer
|
||||||
WDTCTL = WDTPW + WDTHOLD;
|
WDTCTL = WDTPW + WDTHOLD;
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ static void hw_setup(){
|
|||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void btstack_setup(){
|
static void btstack_setup(void){
|
||||||
/// GET STARTED with BTstack ///
|
/// GET STARTED with BTstack ///
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
run_loop_init(RUN_LOOP_EMBEDDED);
|
run_loop_init(RUN_LOOP_EMBEDDED);
|
||||||
|
@ -70,7 +70,7 @@ void halUsbSendChar(char character)
|
|||||||
UCA1TXBUF = character;
|
UCA1TXBUF = character;
|
||||||
}
|
}
|
||||||
|
|
||||||
char halUsbRecvChar(){
|
char halUsbRecvChar(void){
|
||||||
while (!(UCA1IFG & UCRXIFG));
|
while (!(UCA1IFG & UCRXIFG));
|
||||||
return UCA1RXBUF;
|
return UCA1RXBUF;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
static uint8_t low_power_mode_for_sleep = LPM0_bits;
|
||||||
|
|
||||||
void hal_cpu_disable_irqs(){
|
void hal_cpu_disable_irqs(void){
|
||||||
|
|
||||||
// LED off
|
// LED off
|
||||||
LED1_OUT &= ~LED1_PIN;
|
LED1_OUT &= ~LED1_PIN;
|
||||||
@ -61,7 +61,7 @@ void hal_cpu_disable_irqs(){
|
|||||||
__bic_SR_register(GIE);
|
__bic_SR_register(GIE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs(){
|
void hal_cpu_enable_irqs(void){
|
||||||
|
|
||||||
// enable irq
|
// enable irq
|
||||||
__bis_SR_register(GIE);
|
__bis_SR_register(GIE);
|
||||||
@ -80,7 +80,7 @@ void hal_cpu_set_uart_needed_during_sleep(uint8_t enabled){
|
|||||||
low_power_mode_for_sleep = LPM3_bits;
|
low_power_mode_for_sleep = LPM3_bits;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs_and_sleep(){
|
void hal_cpu_enable_irqs_and_sleep(void){
|
||||||
|
|
||||||
// enable irq and enter lpm0
|
// enable irq and enter lpm0
|
||||||
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
__bis_SR_register(low_power_mode_for_sleep + GIE);
|
||||||
|
@ -63,7 +63,7 @@
|
|||||||
#include "remote_device_db.h"
|
#include "remote_device_db.h"
|
||||||
#include "btstack-config.h"
|
#include "btstack-config.h"
|
||||||
|
|
||||||
static void hw_setup(){
|
static void hw_setup(void){
|
||||||
|
|
||||||
// stop watchdog timer
|
// stop watchdog timer
|
||||||
WDTCTL = WDTPW + WDTHOLD;
|
WDTCTL = WDTPW + WDTHOLD;
|
||||||
@ -88,7 +88,7 @@ static void hw_setup(){
|
|||||||
__enable_interrupt();
|
__enable_interrupt();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void btstack_setup(){
|
static void btstack_setup(void){
|
||||||
|
|
||||||
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
hci_dump_open(NULL, HCI_DUMP_STDOUT);
|
||||||
|
|
||||||
|
@ -160,7 +160,7 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get h4 singleton
|
// get h4 singleton
|
||||||
hci_transport_t * hci_transport_h4_instance() {
|
hci_transport_t * hci_transport_h4_instance(void){
|
||||||
if (hci_transport_h4 == NULL) {
|
if (hci_transport_h4 == NULL) {
|
||||||
hci_transport_h4 = (hci_transport_h4_t*)malloc( sizeof(hci_transport_h4_t));
|
hci_transport_h4 = (hci_transport_h4_t*)malloc( sizeof(hci_transport_h4_t));
|
||||||
hci_transport_h4->ds = NULL;
|
hci_transport_h4->ds = NULL;
|
||||||
|
@ -18,7 +18,7 @@ void _mon_putc (char c)
|
|||||||
PLIB_USART_TransmitterByteSend(APP_DEBUG_USART_ID, c);;
|
PLIB_USART_TransmitterByteSend(APP_DEBUG_USART_ID, c);;
|
||||||
}
|
}
|
||||||
|
|
||||||
void APP_Debug_Initialize(){
|
void APP_Debug_Initialize(void){
|
||||||
|
|
||||||
// PPS Output Mapping:
|
// PPS Output Mapping:
|
||||||
PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_U1TX, OUTPUT_PIN_RPD3 );
|
PLIB_PORTS_RemapOutput(PORTS_ID_0, OUTPUT_FUNC_U1TX, OUTPUT_PIN_RPD3 );
|
||||||
|
@ -87,15 +87,15 @@ static void msleep(uint32_t delay) {
|
|||||||
/// HAL CPU ///
|
/// HAL CPU ///
|
||||||
#include <btstack/hal_cpu.h>
|
#include <btstack/hal_cpu.h>
|
||||||
|
|
||||||
void hal_cpu_disable_irqs(){
|
void hal_cpu_disable_irqs(void){
|
||||||
// TODO implement
|
// TODO implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs(){
|
void hal_cpu_enable_irqs(void){
|
||||||
// TODO implement
|
// TODO implement
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs_and_sleep(){
|
void hal_cpu_enable_irqs_and_sleep(void){
|
||||||
// TODO implement
|
// TODO implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,7 +232,7 @@ void BTSTACK_Initialize ( void )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void BTSTACK_Tasks(){
|
void BTSTACK_Tasks(void){
|
||||||
if (bytes_to_read && PLIB_USART_ReceiverDataIsAvailable(BT_USART_ID)) {
|
if (bytes_to_read && PLIB_USART_ReceiverDataIsAvailable(BT_USART_ID)) {
|
||||||
*rx_buffer_ptr++ = PLIB_USART_ReceiverByteReceive(BT_USART_ID);
|
*rx_buffer_ptr++ = PLIB_USART_ReceiverByteReceive(BT_USART_ID);
|
||||||
bytes_to_read--;
|
bytes_to_read--;
|
||||||
|
@ -79,8 +79,8 @@ static void sigint_handler(int param){
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static led_state = 0;
|
static int led_state = 0;
|
||||||
void hal_led_toggle(){
|
void hal_led_toggle(void){
|
||||||
led_state = 1 - led_state;
|
led_state = 1 - led_state;
|
||||||
printf("LED State %u\n", led_state);
|
printf("LED State %u\n", led_state);
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@ static void sigint_handler(int param){
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int led_state = 0;
|
static int led_state = 0;
|
||||||
void hal_led_toggle(){
|
void hal_led_toggle(void){
|
||||||
led_state = 1 - led_state;
|
led_state = 1 - led_state;
|
||||||
printf("LED State %u\n", led_state);
|
printf("LED State %u\n", led_state);
|
||||||
}
|
}
|
||||||
|
@ -79,8 +79,8 @@ static void sigint_handler(int param){
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static led_state = 0;
|
static int led_state = 0;
|
||||||
void hal_led_toggle(){
|
void hal_led_toggle(void){
|
||||||
led_state = 1 - led_state;
|
led_state = 1 - led_state;
|
||||||
printf("LED State %u\n", led_state);
|
printf("LED State %u\n", led_state);
|
||||||
}
|
}
|
||||||
|
@ -198,7 +198,7 @@ static void async_callback(struct libusb_transfer *transfer)
|
|||||||
// log_info("end async_callback");
|
// log_info("end async_callback");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sco_state_machine_init(){
|
static void sco_state_machine_init(void){
|
||||||
sco_state = H2_W4_SCO_HEADER;
|
sco_state = H2_W4_SCO_HEADER;
|
||||||
sco_read_pos = 0;
|
sco_read_pos = 0;
|
||||||
sco_bytes_to_read = 3;
|
sco_bytes_to_read = 3;
|
||||||
|
@ -159,7 +159,7 @@ static int h5_open(void *transport_config){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h5_close(){
|
static int h5_close(void *transport_config){
|
||||||
// first remove run loop handler
|
// first remove run loop handler
|
||||||
run_loop_remove_data_source(hci_transport_h5->ds);
|
run_loop_remove_data_source(hci_transport_h5->ds);
|
||||||
|
|
||||||
@ -285,7 +285,7 @@ static int h5_process(struct data_source *ds) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * h5_get_transport_name(){
|
static const char * h5_get_transport_name(void){
|
||||||
return "H5";
|
return "H5";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +155,6 @@ const remote_device_db_t remote_device_db_fs = {
|
|||||||
delete_name
|
delete_name
|
||||||
};
|
};
|
||||||
|
|
||||||
const remote_device_db_t * remote_device_db_fs_instance(){
|
const remote_device_db_t * remote_device_db_fs_instance(void){
|
||||||
return &remote_device_db_fs;
|
return &remote_device_db_fs;
|
||||||
}
|
}
|
||||||
|
@ -134,15 +134,15 @@ void hal_led_toggle(void){
|
|||||||
// hal_cpu.h implementation
|
// hal_cpu.h implementation
|
||||||
#include <btstack/hal_cpu.h>
|
#include <btstack/hal_cpu.h>
|
||||||
|
|
||||||
void hal_cpu_disable_irqs(){
|
void hal_cpu_disable_irqs(void){
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs(){
|
void hal_cpu_enable_irqs(void){
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hal_cpu_enable_irqs_and_sleep(){
|
void hal_cpu_enable_irqs_and_sleep(void){
|
||||||
hal_led_off();
|
hal_led_off();
|
||||||
__enable_irq();
|
__enable_irq();
|
||||||
__asm__("wfe"); // go to sleep if event flag isn't set. if set, just clear it. IRQs set event flag
|
__asm__("wfe"); // go to sleep if event flag isn't set. if set, just clear it. IRQs set event flag
|
||||||
@ -159,11 +159,11 @@ static void (*rx_done_handler)(void) = dummy_handler;
|
|||||||
static void (*tx_done_handler)(void) = dummy_handler;
|
static void (*tx_done_handler)(void) = dummy_handler;
|
||||||
static void (*cts_irq_handler)(void) = dummy_handler;
|
static void (*cts_irq_handler)(void) = dummy_handler;
|
||||||
|
|
||||||
static void hal_uart_manual_rts_set(){
|
static void hal_uart_manual_rts_set(void){
|
||||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_USART3_RTS);
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO_USART3_RTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hal_uart_manual_rts_clear(){
|
static void hal_uart_manual_rts_clear(void){
|
||||||
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART3_RTS);
|
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ, GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, GPIO_USART3_RTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
src/hci.c
34
src/hci.c
@ -124,7 +124,7 @@ static hci_connection_t * create_connection_for_bd_addr_and_type(bd_addr_t addr,
|
|||||||
*
|
*
|
||||||
* @return le connection parameter range struct
|
* @return le connection parameter range struct
|
||||||
*/
|
*/
|
||||||
le_connection_parameter_range_t gap_le_get_connection_parameter_range(){
|
le_connection_parameter_range_t gap_le_get_connection_parameter_range(void){
|
||||||
return hci_stack->le_connection_parameter_range;
|
return hci_stack->le_connection_parameter_range;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -833,12 +833,12 @@ static void hci_initialization_timeout_handler(timer_source_t * ds){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_initializing_next_state(){
|
static void hci_initializing_next_state(void){
|
||||||
hci_stack->substate = (hci_substate_t )( ((int) hci_stack->substate) + 1);
|
hci_stack->substate = (hci_substate_t )( ((int) hci_stack->substate) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// assumption: hci_can_send_command_packet_now() == true
|
// assumption: hci_can_send_command_packet_now() == true
|
||||||
static void hci_initializing_run(){
|
static void hci_initializing_run(void){
|
||||||
log_info("hci_initializing_run: substate %u", hci_stack->substate);
|
log_info("hci_initializing_run: substate %u", hci_stack->substate);
|
||||||
switch (hci_stack->substate){
|
switch (hci_stack->substate){
|
||||||
case HCI_INIT_SEND_RESET:
|
case HCI_INIT_SEND_RESET:
|
||||||
@ -1646,7 +1646,7 @@ void hci_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *p
|
|||||||
hci_stack->packet_handler = handler;
|
hci_stack->packet_handler = handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void hci_state_reset(){
|
static void hci_state_reset(void){
|
||||||
// no connections yet
|
// no connections yet
|
||||||
hci_stack->connections = NULL;
|
hci_stack->connections = NULL;
|
||||||
|
|
||||||
@ -1727,7 +1727,7 @@ void hci_init(hci_transport_t *transport, void *config, bt_control_t *control, r
|
|||||||
hci_state_reset();
|
hci_state_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_close(){
|
void hci_close(void){
|
||||||
// close remote device db
|
// close remote device db
|
||||||
if (hci_stack->remote_device_db) {
|
if (hci_stack->remote_device_db) {
|
||||||
hci_stack->remote_device_db->close();
|
hci_stack->remote_device_db->close();
|
||||||
@ -1755,7 +1755,7 @@ void hci_set_bd_addr(bd_addr_t addr){
|
|||||||
hci_stack->custom_bd_addr_set = 1;
|
hci_stack->custom_bd_addr_set = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_disable_l2cap_timeout_check(){
|
void hci_disable_l2cap_timeout_check(void){
|
||||||
disable_l2cap_timeouts = 1;
|
disable_l2cap_timeouts = 1;
|
||||||
}
|
}
|
||||||
// State-Module-Driver overview
|
// State-Module-Driver overview
|
||||||
@ -2031,7 +2031,7 @@ void hci_local_bd_addr(bd_addr_t address_buffer){
|
|||||||
memcpy(address_buffer, hci_stack->local_bd_addr, 6);
|
memcpy(address_buffer, hci_stack->local_bd_addr, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_run(){
|
void hci_run(void){
|
||||||
|
|
||||||
// log_info("hci_run: entered");
|
// log_info("hci_run: entered");
|
||||||
hci_connection_t * connection;
|
hci_connection_t * connection;
|
||||||
@ -2457,7 +2457,7 @@ void hci_ssp_set_enable(int enable){
|
|||||||
hci_stack->ssp_enable = enable;
|
hci_stack->ssp_enable = enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
int hci_local_ssp_activated(){
|
int hci_local_ssp_activated(void){
|
||||||
return hci_ssp_supported() && hci_stack->ssp_enable;
|
return hci_ssp_supported() && hci_stack->ssp_enable;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2502,7 +2502,7 @@ int hci_send_cmd(const hci_cmd_t *cmd, ...){
|
|||||||
// Create various non-HCI events.
|
// Create various non-HCI events.
|
||||||
// TODO: generalize, use table similar to hci_create_command
|
// TODO: generalize, use table similar to hci_create_command
|
||||||
|
|
||||||
void hci_emit_state(){
|
void hci_emit_state(void){
|
||||||
log_info("BTSTACK_EVENT_STATE %u", hci_stack->state);
|
log_info("BTSTACK_EVENT_STATE %u", hci_stack->state);
|
||||||
uint8_t event[3];
|
uint8_t event[3];
|
||||||
event[0] = BTSTACK_EVENT_STATE;
|
event[0] = BTSTACK_EVENT_STATE;
|
||||||
@ -2565,7 +2565,7 @@ void hci_emit_l2cap_check_timeout(hci_connection_t *conn){
|
|||||||
hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
|
hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_emit_nr_connections_changed(){
|
void hci_emit_nr_connections_changed(void){
|
||||||
log_info("BTSTACK_EVENT_NR_CONNECTIONS_CHANGED %u", nr_hci_connections());
|
log_info("BTSTACK_EVENT_NR_CONNECTIONS_CHANGED %u", nr_hci_connections());
|
||||||
uint8_t event[3];
|
uint8_t event[3];
|
||||||
event[0] = BTSTACK_EVENT_NR_CONNECTIONS_CHANGED;
|
event[0] = BTSTACK_EVENT_NR_CONNECTIONS_CHANGED;
|
||||||
@ -2575,7 +2575,7 @@ void hci_emit_nr_connections_changed(){
|
|||||||
hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
|
hci_stack->packet_handler(HCI_EVENT_PACKET, event, sizeof(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_emit_hci_open_failed(){
|
void hci_emit_hci_open_failed(void){
|
||||||
log_info("BTSTACK_EVENT_POWERON_FAILED");
|
log_info("BTSTACK_EVENT_POWERON_FAILED");
|
||||||
uint8_t event[2];
|
uint8_t event[2];
|
||||||
event[0] = BTSTACK_EVENT_POWERON_FAILED;
|
event[0] = BTSTACK_EVENT_POWERON_FAILED;
|
||||||
@ -2585,7 +2585,7 @@ void hci_emit_hci_open_failed(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifndef EMBEDDED
|
#ifndef EMBEDDED
|
||||||
void hci_emit_btstack_version() {
|
void hci_emit_btstack_version(void){
|
||||||
log_info("BTSTACK_EVENT_VERSION %u.%u", BTSTACK_MAJOR, BTSTACK_MINOR);
|
log_info("BTSTACK_EVENT_VERSION %u.%u", BTSTACK_MAJOR, BTSTACK_MINOR);
|
||||||
uint8_t event[6];
|
uint8_t event[6];
|
||||||
event[0] = BTSTACK_EVENT_VERSION;
|
event[0] = BTSTACK_EVENT_VERSION;
|
||||||
@ -2795,14 +2795,14 @@ void gap_set_local_name(const char * local_name){
|
|||||||
hci_stack->local_name = local_name;
|
hci_stack->local_name = local_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
le_command_status_t le_central_start_scan(){
|
le_command_status_t le_central_start_scan(void){
|
||||||
if (hci_stack->le_scanning_state == LE_SCANNING) return BLE_PERIPHERAL_OK;
|
if (hci_stack->le_scanning_state == LE_SCANNING) return BLE_PERIPHERAL_OK;
|
||||||
hci_stack->le_scanning_state = LE_START_SCAN;
|
hci_stack->le_scanning_state = LE_START_SCAN;
|
||||||
hci_run();
|
hci_run();
|
||||||
return BLE_PERIPHERAL_OK;
|
return BLE_PERIPHERAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
le_command_status_t le_central_stop_scan(){
|
le_command_status_t le_central_stop_scan(void){
|
||||||
if ( hci_stack->le_scanning_state == LE_SCAN_IDLE) return BLE_PERIPHERAL_OK;
|
if ( hci_stack->le_scanning_state == LE_SCAN_IDLE) return BLE_PERIPHERAL_OK;
|
||||||
hci_stack->le_scanning_state = LE_STOP_SCAN;
|
hci_stack->le_scanning_state = LE_STOP_SCAN;
|
||||||
hci_run();
|
hci_run();
|
||||||
@ -2848,7 +2848,7 @@ le_command_status_t le_central_connect(bd_addr_t addr, bd_addr_type_t addr_type
|
|||||||
}
|
}
|
||||||
|
|
||||||
// @assumption: only a single outgoing LE Connection exists
|
// @assumption: only a single outgoing LE Connection exists
|
||||||
static hci_connection_t * le_central_get_outgoing_connection(){
|
static hci_connection_t * le_central_get_outgoing_connection(void){
|
||||||
linked_item_t *it;
|
linked_item_t *it;
|
||||||
for (it = (linked_item_t *) hci_stack->connections; it ; it = it->next){
|
for (it = (linked_item_t *) hci_stack->connections; it ; it = it->next){
|
||||||
hci_connection_t * conn = (hci_connection_t *) it;
|
hci_connection_t * conn = (hci_connection_t *) it;
|
||||||
@ -2864,7 +2864,7 @@ static hci_connection_t * le_central_get_outgoing_connection(){
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
le_command_status_t le_central_connect_cancel(){
|
le_command_status_t le_central_connect_cancel(void){
|
||||||
hci_connection_t * conn = le_central_get_outgoing_connection();
|
hci_connection_t * conn = le_central_get_outgoing_connection();
|
||||||
switch (conn->state){
|
switch (conn->state){
|
||||||
case SEND_CREATE_CONNECTION:
|
case SEND_CREATE_CONNECTION:
|
||||||
@ -2915,7 +2915,7 @@ le_command_status_t gap_disconnect(hci_con_handle_t handle){
|
|||||||
return BLE_PERIPHERAL_OK;
|
return BLE_PERIPHERAL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
void hci_disconnect_all(){
|
void hci_disconnect_all(void){
|
||||||
linked_list_iterator_t it;
|
linked_list_iterator_t it;
|
||||||
linked_list_iterator_init(&it, &hci_stack->connections);
|
linked_list_iterator_init(&it, &hci_stack->connections);
|
||||||
while (linked_list_iterator_has_next(&it)){
|
while (linked_list_iterator_has_next(&it)){
|
||||||
|
@ -765,7 +765,7 @@ int hci_send_cmd_packet(uint8_t *packet, int size);
|
|||||||
|
|
||||||
/* API_START */
|
/* API_START */
|
||||||
|
|
||||||
le_connection_parameter_range_t gap_le_get_connection_parameter_range();
|
le_connection_parameter_range_t gap_le_get_connection_parameter_range(void);
|
||||||
void gap_le_set_connection_parameter_range(le_connection_parameter_range_t range);
|
void gap_le_set_connection_parameter_range(le_connection_parameter_range_t range);
|
||||||
|
|
||||||
/* LE Client Start */
|
/* LE Client Start */
|
||||||
|
@ -270,7 +270,7 @@ void hci_dump_log_P(PGM_P format, ...){
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void hci_dump_close(){
|
void hci_dump_close(void){
|
||||||
#ifndef EMBEDDED
|
#ifndef EMBEDDED
|
||||||
close(dump_file);
|
close(dump_file);
|
||||||
dump_file = -1;
|
dump_file = -1;
|
||||||
|
@ -79,10 +79,10 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
|||||||
static void h4_block_received(void);
|
static void h4_block_received(void);
|
||||||
static void h4_block_sent(void);
|
static void h4_block_sent(void);
|
||||||
static int h4_open(void *transport_config);
|
static int h4_open(void *transport_config);
|
||||||
static int h4_close();
|
static int h4_close(void *transport_config);
|
||||||
static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
||||||
static int h4_send_packet(uint8_t packet_type, uint8_t *packet, int size);
|
static int h4_send_packet(uint8_t packet_type, uint8_t *packet, int size);
|
||||||
static const char * h4_get_transport_name();
|
static const char * h4_get_transport_name(void);
|
||||||
static int h4_set_baudrate(uint32_t baudrate);
|
static int h4_set_baudrate(uint32_t baudrate);
|
||||||
static int h4_can_send_packet_now(uint8_t packet_type);
|
static int h4_can_send_packet_now(uint8_t packet_type);
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ static int h4_open(void *transport_config){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h4_close(){
|
static int h4_close(void *transport_config){
|
||||||
// first remove run loop handler
|
// first remove run loop handler
|
||||||
run_loop_remove_data_source(&hci_transport_h4_dma_ds);
|
run_loop_remove_data_source(&hci_transport_h4_dma_ds);
|
||||||
|
|
||||||
@ -286,7 +286,7 @@ static int h4_can_send_packet_now(uint8_t packet_type){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * h4_get_transport_name(){
|
static const char * h4_get_transport_name(void){
|
||||||
return "H4_DMA";
|
return "H4_DMA";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -294,6 +294,6 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get h4 singleton
|
// get h4 singleton
|
||||||
hci_transport_t * hci_transport_h4_dma_instance() {
|
hci_transport_t * hci_transport_h4_dma_instance(void){
|
||||||
return (hci_transport_t *) &hci_transport_h4_dma;
|
return (hci_transport_t *) &hci_transport_h4_dma;
|
||||||
}
|
}
|
||||||
|
@ -106,9 +106,9 @@ static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size);
|
|||||||
static void h4_block_received(void);
|
static void h4_block_received(void);
|
||||||
static void h4_block_sent(void);
|
static void h4_block_sent(void);
|
||||||
static int h4_open(void *transport_config);
|
static int h4_open(void *transport_config);
|
||||||
static int h4_close();
|
static int h4_close(void *transport_config);
|
||||||
static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
static void h4_register_packet_handler(void (*handler)(uint8_t packet_type, uint8_t *packet, uint16_t size));
|
||||||
static const char * h4_get_transport_name();
|
static const char * h4_get_transport_name(void);
|
||||||
static int h4_set_baudrate(uint32_t baudrate);
|
static int h4_set_baudrate(uint32_t baudrate);
|
||||||
static int h4_can_send_packet_now(uint8_t packet_type);
|
static int h4_can_send_packet_now(uint8_t packet_type);
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ static int ehcill_send_packet(uint8_t packet_type, uint8_t *packet, int size);
|
|||||||
static void ehcill_uart_dma_receive_block(uint8_t *buffer, uint16_t size);
|
static void ehcill_uart_dma_receive_block(uint8_t *buffer, uint16_t size);
|
||||||
static int ehcill_sleep_mode_active(void);
|
static int ehcill_sleep_mode_active(void);
|
||||||
static void ehcill_handle(uint8_t action);
|
static void ehcill_handle(uint8_t action);
|
||||||
static void ehcill_cts_irq_handler();
|
static void ehcill_cts_irq_handler(void);
|
||||||
|
|
||||||
// eCHILL: state machine
|
// eCHILL: state machine
|
||||||
static EHCILL_STATE ehcill_state = EHCILL_STATE_AWAKE;
|
static EHCILL_STATE ehcill_state = EHCILL_STATE_AWAKE;
|
||||||
@ -170,12 +170,12 @@ static const hci_transport_h4_t hci_transport_h4_ehcill_dma = {
|
|||||||
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
static void dummy_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char * h4_get_transport_name(){
|
static const char * h4_get_transport_name(void){
|
||||||
return "H4_EHCILL_DMA";
|
return "H4_EHCILL_DMA";
|
||||||
}
|
}
|
||||||
|
|
||||||
// get h4 singleton
|
// get h4 singleton
|
||||||
hci_transport_t * hci_transport_h4_dma_instance() {
|
hci_transport_t * hci_transport_h4_dma_instance(void){
|
||||||
return (hci_transport_t *) &hci_transport_h4_ehcill_dma;
|
return (hci_transport_t *) &hci_transport_h4_ehcill_dma;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +213,7 @@ static int h4_set_baudrate(uint32_t baudrate){
|
|||||||
return hal_uart_dma_set_baud(baudrate);
|
return hal_uart_dma_set_baud(baudrate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int h4_close(){
|
static int h4_close(void *transport_config){
|
||||||
// first remove run loop handler
|
// first remove run loop handler
|
||||||
run_loop_remove_data_source(&hci_transport_h4_dma_ds);
|
run_loop_remove_data_source(&hci_transport_h4_dma_ds);
|
||||||
|
|
||||||
@ -308,7 +308,7 @@ static void ehcill_sleep_ack_timer_handler(timer_source_t * timer){
|
|||||||
hal_uart_dma_send_block(&ehcill_command_to_send, 1);
|
hal_uart_dma_send_block(&ehcill_command_to_send, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ehcill_sleep_ack_timer_setup(){
|
static void ehcill_sleep_ack_timer_setup(void){
|
||||||
// setup timer
|
// setup timer
|
||||||
ehcill_sleep_ack_timer.process = &ehcill_sleep_ack_timer_handler;
|
ehcill_sleep_ack_timer.process = &ehcill_sleep_ack_timer_handler;
|
||||||
run_loop_set_timer(&ehcill_sleep_ack_timer, 50);
|
run_loop_set_timer(&ehcill_sleep_ack_timer, 50);
|
||||||
@ -390,7 +390,7 @@ int ehcill_sleep_mode_active(void){
|
|||||||
return ehcill_state == EHCILL_STATE_SLEEP;
|
return ehcill_state == EHCILL_STATE_SLEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ehcill_cts_irq_handler(){
|
static void ehcill_cts_irq_handler(void){
|
||||||
ehcill_handle(EHCILL_CTS_SIGNAL);
|
ehcill_handle(EHCILL_CTS_SIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +92,7 @@ static void l2cap_emit_connection_request(l2cap_channel_t *channel);
|
|||||||
static int l2cap_channel_ready_for_open(l2cap_channel_t *channel);
|
static int l2cap_channel_ready_for_open(l2cap_channel_t *channel);
|
||||||
|
|
||||||
|
|
||||||
void l2cap_init(){
|
void l2cap_init(void){
|
||||||
new_credits_blocked = 0;
|
new_credits_blocked = 0;
|
||||||
signaling_responses_pending = 0;
|
signaling_responses_pending = 0;
|
||||||
|
|
||||||
@ -318,7 +318,7 @@ static void l2cap_start_ertx(l2cap_channel_t * channel){
|
|||||||
run_loop_add_timer(&channel->rtx);
|
run_loop_add_timer(&channel->rtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void l2cap_require_security_level_2_for_outgoing_sdp(){
|
void l2cap_require_security_level_2_for_outgoing_sdp(void){
|
||||||
require_security_level2_for_outgoing_sdp = 1;
|
require_security_level2_for_outgoing_sdp = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -736,7 +736,7 @@ uint16_t l2cap_max_mtu(void){
|
|||||||
return HCI_ACL_PAYLOAD_SIZE - L2CAP_HEADER_SIZE;
|
return HCI_ACL_PAYLOAD_SIZE - L2CAP_HEADER_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t l2cap_max_le_mtu(){
|
uint16_t l2cap_max_le_mtu(void){
|
||||||
return l2cap_max_mtu();
|
return l2cap_max_mtu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ int run_loop_remove_timer(timer_source_t *ts){
|
|||||||
return the_run_loop->remove_timer(ts);
|
return the_run_loop->remove_timer(ts);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run_loop_timer_dump(){
|
void run_loop_timer_dump(void){
|
||||||
run_loop_assert();
|
run_loop_assert();
|
||||||
the_run_loop->dump_timer();
|
the_run_loop->dump_timer();
|
||||||
}
|
}
|
||||||
@ -128,7 +128,7 @@ void run_loop_timer_dump(){
|
|||||||
/**
|
/**
|
||||||
* Execute run_loop
|
* Execute run_loop
|
||||||
*/
|
*/
|
||||||
void run_loop_execute() {
|
void run_loop_execute(void){
|
||||||
run_loop_assert();
|
run_loop_assert();
|
||||||
the_run_loop->execute();
|
the_run_loop->execute();
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ static void (*app_packet_handler)(void * connection, uint8_t packet_type,
|
|||||||
static uint16_t l2cap_cid = 0;
|
static uint16_t l2cap_cid = 0;
|
||||||
static uint16_t sdp_response_size = 0;
|
static uint16_t sdp_response_size = 0;
|
||||||
|
|
||||||
void sdp_init(){
|
void sdp_init(void){
|
||||||
// register with l2cap psm sevices - max MTU
|
// register with l2cap psm sevices - max MTU
|
||||||
l2cap_register_service_internal(NULL, sdp_packet_handler, PSM_SDP, 0xffff, LEVEL_0);
|
l2cap_register_service_internal(NULL, sdp_packet_handler, PSM_SDP, 0xffff, LEVEL_0);
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ static void (*sdp_app_callback)(sdp_query_event_t * event, void * context) = dum
|
|||||||
|
|
||||||
static void dummy_notify_app(sdp_query_event_t* event, void * context){}
|
static void dummy_notify_app(sdp_query_event_t* event, void * context){}
|
||||||
|
|
||||||
static void emit_service(){
|
static void emit_service(void){
|
||||||
sdp_query_rfcomm_service_event_t value_event = {
|
sdp_query_rfcomm_service_event_t value_event = {
|
||||||
SDP_QUERY_RFCOMM_SERVICE,
|
SDP_QUERY_RFCOMM_SERVICE,
|
||||||
sdp_rfcomm_channel_nr,
|
sdp_rfcomm_channel_nr,
|
||||||
@ -289,7 +289,7 @@ static void handle_sdp_parser_event(sdp_query_event_t * event){
|
|||||||
// insert higher level code HERE
|
// insert higher level code HERE
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdp_query_rfcomm_init(){
|
void sdp_query_rfcomm_init(void){
|
||||||
// init
|
// init
|
||||||
de_state_init(&de_header_state);
|
de_state_init(&de_header_state);
|
||||||
de_state_init(&sn_de_header_state);
|
de_state_init(&sn_de_header_state);
|
||||||
@ -312,7 +312,7 @@ void sdp_query_rfcomm_channel_and_name_for_uuid(bd_addr_t remote, uint16_t uuid)
|
|||||||
sdp_query_rfcomm_channel_and_name_for_search_pattern(remote, (uint8_t*)des_serviceSearchPattern);
|
sdp_query_rfcomm_channel_and_name_for_search_pattern(remote, (uint8_t*)des_serviceSearchPattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
void sdp_query_rfcomm_deregister_callback(){
|
void sdp_query_rfcomm_deregister_callback(void){
|
||||||
sdp_query_rfcomm_init();
|
sdp_query_rfcomm_init();
|
||||||
sdp_app_callback = dummy_notify_app;
|
sdp_app_callback = dummy_notify_app;
|
||||||
sdp_app_context = NULL;
|
sdp_app_context = NULL;
|
||||||
|
@ -96,7 +96,7 @@ static uint8_t num_completed_evt[] ={
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int dummy_callback(){
|
int dummy_callback(void){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ void packet_handler(uint8_t packet_type, uint8_t *packet, uint16_t size){
|
|||||||
|
|
||||||
|
|
||||||
TEST_GROUP(ADParser){
|
TEST_GROUP(ADParser){
|
||||||
void setup(){
|
void setup(void){
|
||||||
hci_init(&dummy_transport, NULL, NULL, NULL);
|
hci_init(&dummy_transport, NULL, NULL, NULL);
|
||||||
hci_register_packet_handler(packet_handler);
|
hci_register_packet_handler(packet_handler);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ TEST_GROUP(DESParser){
|
|||||||
int value_index;
|
int value_index;
|
||||||
des_iterator_t des_list_it;
|
des_iterator_t des_list_it;
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
value_index = 0;
|
value_index = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,37 +103,37 @@ void CHECK_EQUAL_GATT_ATTRIBUTE(const uint8_t * exp_uuid, const uint8_t * exp_ha
|
|||||||
|
|
||||||
// -----------------------------------------------------
|
// -----------------------------------------------------
|
||||||
|
|
||||||
static void verify_primary_services_with_uuid16(){
|
static void verify_primary_services_with_uuid16(void){
|
||||||
CHECK_EQUAL(1, result_index);
|
CHECK_EQUAL(1, result_index);
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuid16, primary_service_uuid16_handles, services[0].uuid128, services[0].start_group_handle, services[0].end_group_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuid16, primary_service_uuid16_handles, services[0].uuid128, services[0].start_group_handle, services[0].end_group_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void verify_primary_services_with_uuid128(){
|
static void verify_primary_services_with_uuid128(void){
|
||||||
CHECK_EQUAL(1, result_index);
|
CHECK_EQUAL(1, result_index);
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuid128, primary_service_uuid128_handles, services[0].uuid128, services[0].start_group_handle, services[0].end_group_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuid128, primary_service_uuid128_handles, services[0].uuid128, services[0].start_group_handle, services[0].end_group_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_primary_services(){
|
static void verify_primary_services(void){
|
||||||
CHECK_EQUAL(6, result_index);
|
CHECK_EQUAL(6, result_index);
|
||||||
for (int i=0; i<result_index; i++){
|
for (int i=0; i<result_index; i++){
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuids[i], NULL, services[i].uuid128, services[i].start_group_handle, services[i].end_group_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(primary_service_uuids[i], NULL, services[i].uuid128, services[i].start_group_handle, services[i].end_group_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_included_services_uuid16(){
|
static void verify_included_services_uuid16(void){
|
||||||
CHECK_EQUAL(1, result_index);
|
CHECK_EQUAL(1, result_index);
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(included_services_uuid16, included_services_uuid16_handles, included_services[0].uuid128, included_services[0].start_group_handle, included_services[0].end_group_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(included_services_uuid16, included_services_uuid16_handles, included_services[0].uuid128, included_services[0].start_group_handle, included_services[0].end_group_handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_included_services_uuid128(){
|
static void verify_included_services_uuid128(void){
|
||||||
CHECK_EQUAL(2, result_index);
|
CHECK_EQUAL(2, result_index);
|
||||||
for (int i=0; i<result_index; i++){
|
for (int i=0; i<result_index; i++){
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(included_services_uuid128[i], included_services_uuid128_handles[i], included_services[i].uuid128, included_services[i].start_group_handle, included_services[i].end_group_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(included_services_uuid128[i], included_services_uuid128_handles[i], included_services[i].uuid128, included_services[i].start_group_handle, included_services[i].end_group_handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void verify_charasteristics(){
|
static void verify_charasteristics(void){
|
||||||
CHECK_EQUAL(14, result_index);
|
CHECK_EQUAL(14, result_index);
|
||||||
for (int i=0; i<result_index; i++){
|
for (int i=0; i<result_index; i++){
|
||||||
CHECK_EQUAL_GATT_ATTRIBUTE(characteristic_uuids[i], characteristic_handles[i], characteristics[i].uuid128, characteristics[i].start_handle, characteristics[i].end_handle);
|
CHECK_EQUAL_GATT_ATTRIBUTE(characteristic_uuids[i], characteristic_handles[i], characteristics[i].uuid128, characteristics[i].start_handle, characteristics[i].end_handle);
|
||||||
@ -288,13 +288,13 @@ TEST_GROUP(GATTClient){
|
|||||||
uint8_t acl_buffer[27];
|
uint8_t acl_buffer[27];
|
||||||
le_command_status_t status;
|
le_command_status_t status;
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
result_counter = 0;
|
result_counter = 0;
|
||||||
result_index = 0;
|
result_index = 0;
|
||||||
test = IDLE;
|
test = IDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_query_state(){
|
void reset_query_state(void){
|
||||||
gatt_query_complete = 0;
|
gatt_query_complete = 0;
|
||||||
result_counter = 0;
|
result_counter = 0;
|
||||||
result_index = 0;
|
result_index = 0;
|
||||||
|
@ -78,13 +78,13 @@ static void handle_le_client_event(le_event_t * event){
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_GROUP(LECentral){
|
TEST_GROUP(LECentral){
|
||||||
void connect(){
|
void connect(void){
|
||||||
le_central_connect(test_device_addr, BD_ADDR_TYPE_LE_PUBLIC);
|
le_central_connect(test_device_addr, BD_ADDR_TYPE_LE_PUBLIC);
|
||||||
mock_simulate_connected();
|
mock_simulate_connected();
|
||||||
CHECK(connected);
|
CHECK(connected);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
advertisement_received = 0;
|
advertisement_received = 0;
|
||||||
connected = 0;
|
connected = 0;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ TEST_GROUP(LECentral){
|
|||||||
// connect();
|
// connect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown(){
|
void teardown(void){
|
||||||
mock().clear();
|
mock().clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -114,7 +114,7 @@ TEST_GROUP(LECentral){
|
|||||||
// CHECK(advertisement_received);
|
// CHECK(advertisement_received);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
int productionCode(){
|
int productionCode(void){
|
||||||
printf("productionCode 20\n");
|
printf("productionCode 20\n");
|
||||||
mock().actualCall("productionCode");
|
mock().actualCall("productionCode");
|
||||||
return 20;
|
return 20;
|
||||||
|
@ -19,7 +19,7 @@ static const uint16_t max_mtu = 23;
|
|||||||
static uint8_t l2cap_stack_buffer[max_mtu];
|
static uint8_t l2cap_stack_buffer[max_mtu];
|
||||||
uint16_t gatt_client_handle = 0x40;
|
uint16_t gatt_client_handle = 0x40;
|
||||||
|
|
||||||
uint16_t get_gatt_client_handle(){
|
uint16_t get_gatt_client_handle(void){
|
||||||
return gatt_client_handle;
|
return gatt_client_handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -28,18 +28,18 @@ void mock_simulate_command_complete(const hci_cmd_t *cmd){
|
|||||||
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mock_simulate_hci_state_working(){
|
void mock_simulate_hci_state_working(void){
|
||||||
uint8_t packet[3] = {BTSTACK_EVENT_STATE, 0, HCI_STATE_WORKING};
|
uint8_t packet[3] = {BTSTACK_EVENT_STATE, 0, HCI_STATE_WORKING};
|
||||||
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, 3);
|
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mock_simulate_connected(){
|
void mock_simulate_connected(void){
|
||||||
uint8_t packet[] = {0x3E, 0x13, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x9B, 0x77, 0xD1, 0xF7, 0xB1, 0x34, 0x50, 0x00, 0x00, 0x00, 0xD0, 0x07, 0x05};
|
uint8_t packet[] = {0x3E, 0x13, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x9B, 0x77, 0xD1, 0xF7, 0xB1, 0x34, 0x50, 0x00, 0x00, 0x00, 0xD0, 0x07, 0x05};
|
||||||
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void mock_simulate_scan_response(){
|
void mock_simulate_scan_response(void){
|
||||||
uint8_t packet[] = {0x3E, 0x0F, 0x02, 0x01, 0x00, 0x00, 0x9B, 0x77, 0xD1, 0xF7, 0xB1, 0x34, 0x03, 0x02, 0x01, 0x05, 0xBC};
|
uint8_t packet[] = {0x3E, 0x0F, 0x02, 0x01, 0x00, 0x00, 0x9B, 0x77, 0xD1, 0xF7, 0xB1, 0x34, 0x03, 0x02, 0x01, 0x05, 0xBC};
|
||||||
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
gatt_central_packet_handler(NULL, HCI_EVENT_PACKET, NULL, (uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ static void att_init_connection(att_connection_t * att_connection){
|
|||||||
att_connection->authorized = 0;
|
att_connection->authorized = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int l2cap_can_send_connectionless_packet_now(){
|
int l2cap_can_send_connectionless_packet_now(void){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,7 +98,7 @@ int l2cap_send_prepared_connectionless(uint16_t handle, uint16_t cid, uint16_t l
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sm_cmac_ready(){
|
int sm_cmac_ready(void){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
void sm_cmac_start(sm_key_t k, uint16_t message_len, uint8_t * message, void (*done_handler)(uint8_t hash[8])){
|
void sm_cmac_start(sm_key_t k, uint16_t message_len, uint8_t * message, void (*done_handler)(uint8_t hash[8])){
|
||||||
|
@ -9,7 +9,7 @@ linked_item_t itemC;
|
|||||||
linked_item_t itemD;
|
linked_item_t itemD;
|
||||||
|
|
||||||
TEST_GROUP(LinkedList){
|
TEST_GROUP(LinkedList){
|
||||||
void setup(){
|
void setup(void){
|
||||||
testList = NULL;
|
testList = NULL;
|
||||||
linked_list_add(&testList, &itemD);
|
linked_list_add(&testList, &itemD);
|
||||||
linked_list_add(&testList, &itemC);
|
linked_list_add(&testList, &itemC);
|
||||||
|
@ -15,7 +15,7 @@ TEST_GROUP(RemoteDeviceDB){
|
|||||||
link_key_t link_key;
|
link_key_t link_key;
|
||||||
link_key_type_t link_key_type;
|
link_key_type_t link_key_type;
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
bd_addr_t addr_1 = {0x00, 0x01, 0x02, 0x03, 0x04, 0x01 };
|
bd_addr_t addr_1 = {0x00, 0x01, 0x02, 0x03, 0x04, 0x01 };
|
||||||
BD_ADDR_COPY(bd_addr, addr_1);
|
BD_ADDR_COPY(bd_addr, addr_1);
|
||||||
|
|
||||||
@ -23,7 +23,7 @@ TEST_GROUP(RemoteDeviceDB){
|
|||||||
sprintf((char*)link_key, "%d", 100);
|
sprintf((char*)link_key, "%d", 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown(){}
|
void teardown(void){}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ TEST_GROUP(RemoteDeviceDB){
|
|||||||
link_key_t link_key;
|
link_key_t link_key;
|
||||||
link_key_type_t link_key_type;
|
link_key_type_t link_key_type;
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
|
|
||||||
bd_addr_t addr_1 = {0x00, 0x01, 0x02, 0x03, 0x04, 0x01 };
|
bd_addr_t addr_1 = {0x00, 0x01, 0x02, 0x03, 0x04, 0x01 };
|
||||||
@ -47,7 +47,7 @@ TEST_GROUP(RemoteDeviceDB){
|
|||||||
sprintf((char*)link_key, "%d", 100);
|
sprintf((char*)link_key, "%d", 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
void teardown(){}
|
void teardown(void){}
|
||||||
};
|
};
|
||||||
|
|
||||||
TEST(RemoteDeviceDB, MemoryPool){
|
TEST(RemoteDeviceDB, MemoryPool){
|
||||||
|
@ -171,7 +171,7 @@ static void handle_sdp_parser_event(sdp_query_event_t * event){
|
|||||||
|
|
||||||
|
|
||||||
TEST_GROUP(SDPClient){
|
TEST_GROUP(SDPClient){
|
||||||
void setup(){
|
void setup(void){
|
||||||
attribute_value_buffer_size = 1000;
|
attribute_value_buffer_size = 1000;
|
||||||
attribute_value = (uint8_t*) malloc(attribute_value_buffer_size);
|
attribute_value = (uint8_t*) malloc(attribute_value_buffer_size);
|
||||||
record_id = -1;
|
record_id = -1;
|
||||||
|
@ -114,7 +114,7 @@ void handle_query_rfcomm_event(sdp_query_event_t * event, void * context){
|
|||||||
TEST_GROUP(SDPClient){
|
TEST_GROUP(SDPClient){
|
||||||
uint8_t spp_buffer[sizeof(sdp_test_record_list)];
|
uint8_t spp_buffer[sizeof(sdp_test_record_list)];
|
||||||
|
|
||||||
void setup(){
|
void setup(void){
|
||||||
service_index = 0;
|
service_index = 0;
|
||||||
sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL);
|
sdp_query_rfcomm_register_callback(handle_query_rfcomm_event, NULL);
|
||||||
sdp_parser_init();
|
sdp_parser_init();
|
||||||
|
@ -116,7 +116,7 @@ static void handle_sdp_parser_event(sdp_query_event_t * event){
|
|||||||
|
|
||||||
|
|
||||||
TEST_GROUP(SDPClient){
|
TEST_GROUP(SDPClient){
|
||||||
void setup(){
|
void setup(void){
|
||||||
attribute_value_buffer_size = 1000;
|
attribute_value_buffer_size = 1000;
|
||||||
attribute_value = (uint8_t*) malloc(attribute_value_buffer_size);
|
attribute_value = (uint8_t*) malloc(attribute_value_buffer_size);
|
||||||
record_id = -1;
|
record_id = -1;
|
||||||
|
@ -63,7 +63,7 @@ static void handle_sdp_parser_event(sdp_query_event_t * event){
|
|||||||
|
|
||||||
|
|
||||||
TEST_GROUP(SDPClient){
|
TEST_GROUP(SDPClient){
|
||||||
void setup(){
|
void setup(void){
|
||||||
sdp_parser_init_service_search();
|
sdp_parser_init_service_search();
|
||||||
sdp_parser_register_callback(handle_sdp_parser_event);
|
sdp_parser_register_callback(handle_sdp_parser_event);
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ static void hexdump2(void *data, int size){
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(){
|
int main(void){
|
||||||
uint8_t key[16];
|
uint8_t key[16];
|
||||||
uint8_t plaintext[16];
|
uint8_t plaintext[16];
|
||||||
bzero(key, 16);
|
bzero(key, 16);
|
||||||
|
@ -59,7 +59,7 @@ void mock_simulate_hci_event(uint8_t * packet, uint16_t size){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void aes128_report_result(){
|
void aes128_report_result(void){
|
||||||
uint8_t le_enc_result[22];
|
uint8_t le_enc_result[22];
|
||||||
uint8_t enc1_data[] = { 0x0e, 0x14, 0x01, 0x17, 0x20, 0x00 };
|
uint8_t enc1_data[] = { 0x0e, 0x14, 0x01, 0x17, 0x20, 0x00 };
|
||||||
memcpy (le_enc_result, enc1_data, 6);
|
memcpy (le_enc_result, enc1_data, 6);
|
||||||
@ -94,12 +94,12 @@ void mock_simulate_command_complete(const hci_cmd_t *cmd){
|
|||||||
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mock_simulate_hci_state_working(){
|
void mock_simulate_hci_state_working(void){
|
||||||
uint8_t packet[] = {BTSTACK_EVENT_STATE, 0, HCI_STATE_WORKING};
|
uint8_t packet[] = {BTSTACK_EVENT_STATE, 0, HCI_STATE_WORKING};
|
||||||
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mock_simulate_connected(){
|
void mock_simulate_connected(void){
|
||||||
uint8_t packet[] = { 0x3e, 0x13, 0x01, 0x00, 0x40, 0x00, 0x01, 0x01, 0x18, 0x12, 0x5e, 0x68, 0xc9, 0x73, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05};
|
uint8_t packet[] = { 0x3e, 0x13, 0x01, 0x00, 0x40, 0x00, 0x01, 0x01, 0x18, 0x12, 0x5e, 0x68, 0xc9, 0x73, 0x18, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05};
|
||||||
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
mock_simulate_hci_event((uint8_t *)&packet, sizeof(packet));
|
||||||
}
|
}
|
||||||
@ -200,7 +200,7 @@ void hci_disconnect_security_block(hci_con_handle_t con_handle){
|
|||||||
printf("hci_disconnect_security_block \n");
|
printf("hci_disconnect_security_block \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int hci_non_flushable_packet_boundary_flag_supported(){
|
int hci_non_flushable_packet_boundary_flag_supported(void){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
typedef uint32_t u32;
|
typedef uint32_t u32;
|
||||||
typedef uint8_t u8;
|
typedef uint8_t u8;
|
||||||
|
|
||||||
int rijndaelStartOfCode(){
|
int rijndaelStartOfCode(void){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,6 +1223,6 @@ u32 s0, s1, s2, s3, t0, t1, t2, t3;
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int rijndaelEndOfCode(){
|
int rijndaelEndOfCode(void){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ void CHECK_EQUAL_ARRAY(uint8_t * expected, uint8_t * actual, int size){
|
|||||||
|
|
||||||
|
|
||||||
TEST_GROUP(GATTClient){
|
TEST_GROUP(GATTClient){
|
||||||
void setup(){
|
void setup(void){
|
||||||
btstack_memory_init();
|
btstack_memory_init();
|
||||||
run_loop_init(RUN_LOOP_POSIX);
|
run_loop_init(RUN_LOOP_POSIX);
|
||||||
sm_init();
|
sm_init();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user