/* * File: biscuit_central.c * Author: Red Bear Labs * modified by Brandon and Nick * Comments: Sets up opcodes to be sent out to HCI Bluetooth module * * Revision history: Last Updated 12/13/15 * Changed to C file and updated dependecies * modified write byte and enable notification function to * allow different connection handlers a.k.a. target devices */ #include "typedef.h" #include "central.h" #include "ble_hci.h" #include // Discovey mode (limited, general, all) #define DEFAULT_DISCOVERY_MODE DEVDISC_MODE_ALL // TRUE to use active scan #define DEFAULT_DISCOVERY_ACTIVE_SCAN 1 // TRUE to use white list during discovery #define DEFAULT_DISCOVERY_WHITE_LIST 0 // TRUE to use high scan duty cycle when creating link #define DEFAULT_LINK_HIGH_DUTY_CYCLE 0 // TRUE to use white list when creating link #define DEFAULT_LINK_WHITE_LIST 0 void biscuit_central_init() { GAPCentralRole_StartDevice(); } void biscuit_central_start_discovery() { GAPCentralRole_StartDiscovery( DEFAULT_DISCOVERY_MODE, DEFAULT_DISCOVERY_ACTIVE_SCAN, DEFAULT_DISCOVERY_WHITE_LIST ); } void biscuit_central_connect(uint8 *address) { GAPCentralRole_EstablishLink( DEFAULT_LINK_HIGH_DUTY_CYCLE, DEFAULT_LINK_WHITE_LIST, 0, address ); } //modified to write to different handles void biscuit_central_write_bytes(uint16 connHandle, uint8 *buf, uint8 len) { attWriteReq_t writeReq; writeReq.handle = 0x0016; writeReq.len = len; memcpy(writeReq.value, buf, len); GATT_WriteCharValue( connHandle, &writeReq, 0 ); } //modified to write to different handles void biscuit_central_enable_notification(uint16 connHandle) { attWriteReq_t writeReq; writeReq.handle = 0x0013; writeReq.len = 2; writeReq.value[0] = 0x01; writeReq.value[1] = 0x00; GATT_WriteCharValue( connHandle, &writeReq, 0 ); } void biscuit_central_disconnect(uint16 connHandle) { GAP_TerminateLinkReq( connHandle, 0xFFFE ); }