Skip to content

Instantly share code, notes, and snippets.

@jareddlc
Created June 12, 2014 05:50
Show Gist options
  • Save jareddlc/04850d3a9a919b1429ed to your computer and use it in GitHub Desktop.
Save jareddlc/04850d3a9a919b1429ed to your computer and use it in GitHub Desktop.
/** TurquoiseBicuspid.c
* @file
*
* This file has been automatically generated by the WICED Smart Designer.
* Device configuration and functions required for the BLE device.
*
*/
#include "bleprofile.h"
#include "bleapp.h"
#include "gpiodriver.h"
#include "string.h"
#include "stdio.h"
#include "platform.h"
#include "turquoisebicuspid_db.h"
/******************************************************
* Constants
******************************************************/
#define TURQUOISEBICUSPID_FINE_TIMER 1000
#define TURQUOISEBICUSPID_DEVICE_NAME "TurquoiseBicuspid"
#define TURQUOISEBICUSPID_DEVICE_APPEARENCE 0
#define TURQUOISEBICUSPID_MAIN_SERVICE_UUID 0
#define TURQUOISEBICUSPID_MAIN_CHAR_UUID 0
#define TURQUOISEBICUSPID_MAIN_CHAR_HANDLE 0
// TurquoiseBicuspid Constants
#define TURQUOISEBICUSPID_LED1_GPIO (26)
/******************************************************
* Structures
******************************************************/
#pragma pack(1)
//host information for NVRAM
typedef PACKED struct
{
//part of HOSTINFO generated by wizard
__HOSTINFO generated;
// ToDo: add your variables here which need to be saved in the NVRAM
} HOSTINFO;
#pragma pack()
/******************************************************
* Function Prototypes
******************************************************/
static void turquoisebicuspid_create(void);
static void turquoisebicuspid_connection_up( void );
static void turquoisebicuspid_connection_down( void );
static void turquoisebicuspid_advertisement_stopped( void );
static void turquoisebicuspid_smp_bond_result( LESMP_PARING_RESULT result );
static void turquoisebicuspid_encryption_changed( HCI_EVT_HDR *evt );
static int turquoisebicuspid_write_handler( LEGATTDB_ENTRY_HDR *p );
static void turquoisebicuspid_interrupt_handler( UINT8 value );
// TurquoiseBicuspid Function Prototypes
static void turquoisebicuspid_blink_led1(void);
/******************************************************
* Variables Definitions
******************************************************/
const BLE_PROFILE_CFG turquoisebicuspid_cfg =
{
/*.fine_timer_interval =*/ TURQUOISEBICUSPID_FINE_TIMER, // ms
/*.default_adv =*/ 4, // HIGH_UNDIRECTED_DISCOVERABLE
/*.button_adv_toggle =*/ 0, // pairing button make adv toggle (if 1) or always on (if 0)
/*.high_undirect_adv_interval =*/ 32, // slots
/*.low_undirect_adv_interval =*/ 1024, // slots
/*.high_undirect_adv_duration =*/ 30, // seconds
/*.low_undirect_adv_duration =*/ 300, // seconds
/*.high_direct_adv_interval =*/ 0, // seconds
/*.low_direct_adv_interval =*/ 0, // seconds
/*.high_direct_adv_duration =*/ 0, // seconds
/*.low_direct_adv_duration =*/ 0, // seconds
/*.local_name =*/ TURQUOISEBICUSPID_DEVICE_NAME, // [LOCAL_NAME_LEN_MAX];
/*.cod =*/ BIT16_TO_8(TURQUOISEBICUSPID_DEVICE_APPEARENCE),0x00, // [COD_LEN];
/*.ver =*/ "1.00", // [VERSION_LEN];
/*.encr_required =*/ 0, //(SECURITY_ENABLED | SECURITY_REQUEST), // data encrypted and device sends security request on every connection
/*.disc_required =*/ 0, // if 1, disconnection after confirmation
/*.test_enable =*/ 1, // TEST MODE is enabled when 1
/*.tx_power_level =*/ 0x04, // dbm
/*.con_idle_timeout =*/ 10, // second 0-> no timeout
/*.powersave_timeout =*/ 0, // second 0-> no timeout
/*.hdl =*/ {TURQUOISEBICUSPID_MAIN_CHAR_HANDLE, 0x00, 0x00, 0x00, 0x00}, // [HANDLE_NUM_MAX];
/*.serv =*/ {TURQUOISEBICUSPID_MAIN_SERVICE_UUID, 0x00, 0x00, 0x00, 0x00},
/*.cha =*/ {TURQUOISEBICUSPID_MAIN_CHAR_UUID, 0x00, 0x00, 0x00, 0x00},
/*.findme_locator_enable =*/ 0, // if 1 Find me locator is enable
/*.findme_alert_level =*/ 0, // alert level of find me
/*.client_grouptype_enable =*/ 0, // if 1 grouptype read can be used
/*.linkloss_button_enable =*/ 0, // if 1 linkloss button is enable
/*.pathloss_check_interval =*/ 0, // second
/*.alert_interval =*/ 0, // interval of alert
/*.high_alert_num =*/ 0, // number of alert for each interval
/*.mild_alert_num =*/ 0, // number of alert for each interval
/*.status_led_enable =*/ 1, // if 1 status LED is enable
/*.status_led_interval =*/ 0, // second
/*.status_led_con_blink =*/ 0, // blink num of connection
/*.status_led_dir_adv_blink =*/ 0, // blink num of dir adv
/*.status_led_un_adv_blink =*/ 0, // blink num of undir adv
/*.led_on_ms =*/ 0, // led blink on duration in ms
/*.led_off_ms =*/ 0, // led blink off duration in ms
/*.buz_on_ms =*/ 100, // buzzer on duration in ms
/*.button_power_timeout =*/ 0, // seconds
/*.button_client_timeout =*/ 0, // seconds
/*.button_discover_timeout =*/ 0, // seconds
/*.button_filter_timeout =*/ 0, // seconds
#ifdef BLE_UART_LOOPBACK_TRACE
/*.button_uart_timeout =*/ 15, // seconds
#endif
};
// Following structure defines UART configuration
const BLE_PROFILE_PUART_CFG turquoisebicuspid_puart_cfg =
{
/*.baudrate =*/ 115200,
#ifdef GATT_DB_ENABLE_UART
/*.txpin =*/ GPIO_PIN_UART_TX,
/*.rxpin =*/ GPIO_PIN_UART_RX,
#else
/*.txpin =*/ PUARTDISABLE | GPIO_PIN_UART_TX,
/*.rxpin =*/ PUARTDISABLE | GPIO_PIN_UART_RX,
#endif
};
// NVRAM save area
HOSTINFO turquoisebicuspid_hostinfo;
//pointer to the generated part of hostinfo assuming it is the beginning of the hostinfo
__HOSTINFO *p_hostinfo_generated = &turquoisebicuspid_hostinfo.generated;
UINT16 turquoisebicuspid_connection_handle = 0; // HCI handle of connection, not zero when connected
BD_ADDR turquoisebicuspid_remote_addr = {0, 0, 0, 0, 0, 0}; // Address of currently connected client
// ToDo: Add your static variables here
/******************************************************
* Function Definitions
******************************************************/
// Application initialization
APPLICATION_INIT()
{
bleapp_set_cfg((UINT8 *)gatt_database,
gatt_database_len,
(void *)&turquoisebicuspid_cfg,
(void *)&turquoisebicuspid_puart_cfg,
(void *)&turquoisebicuspid_gpio_cfg,
turquoisebicuspid_create);
}
// Create device
void turquoisebicuspid_create(void)
{
extern UINT32 blecm_configFlag ;
blecm_configFlag |= BLECM_DBGUART_LOG | BLECM_DBGUART_LOG_L2CAP | BLECM_DBGUART_LOG_SMP;
lesmpkeys_removeAllBondInfo();
ble_trace0("create()");
ble_trace0(bleprofile_p_cfg->ver);
// dump the database to debug uart.
legattdb_dumpDb();
bleprofile_Init(bleprofile_p_cfg);
bleprofile_GPIOInit(bleprofile_gpio_p_cfg);
// Initialized ROM code which will monitor the battery
blebat_Init();
// Read NVRAM
bleprofile_ReadNVRAM(VS_BLE_HOST_LIST, sizeof(turquoisebicuspid_hostinfo), (UINT8 *)&turquoisebicuspid_hostinfo);
// register connection up and connection down handler.
bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_UP, turquoisebicuspid_connection_up);
bleprofile_regAppEvtHandler(BLECM_APP_EVT_LINK_DOWN, turquoisebicuspid_connection_down);
bleprofile_regAppEvtHandler(BLECM_APP_EVT_ADV_TIMEOUT, turquoisebicuspid_advertisement_stopped);
// handler for Encryption changed.
blecm_regEncryptionChangedHandler(turquoisebicuspid_encryption_changed);
// handler for Bond result
lesmp_regSMPResultCb((LESMP_SINGLE_PARAM_CB) turquoisebicuspid_smp_bond_result);
// register to process client writes
legattdb_regWriteHandleCb((LEGATTDB_WRITE_CB)turquoisebicuspid_write_handler);
// register interrupt handler
bleprofile_regIntCb((BLEPROFILE_SINGLE_PARAM_CB) turquoisebicuspid_interrupt_handler);
//registers timer
turquoisebicuspid_reg_timer();
// advertise first vendor specific service
if(sizeof(turquoisebicuspid_uuid_main_vsc_service) == 16)
{
// total length should be less than 31 bytes
BLE_ADV_FIELD adv[3];
// flags
adv[0].len = 1 + 1;
adv[0].val = ADV_FLAGS;
adv[0].data[0] = LE_LIMITED_DISCOVERABLE | BR_EDR_NOT_SUPPORTED;
adv[1].len = 16 + 1;
adv[1].val = ADV_SERVICE_UUID128_COMP;
memcpy(adv[1].data, &turquoisebicuspid_uuid_main_vsc_service[0], 16);
// name
adv[2].len = strlen(bleprofile_p_cfg->local_name) + 1;
adv[2].val = ADV_LOCAL_NAME_COMP;
memcpy(adv[2].data, bleprofile_p_cfg->local_name, adv[2].len - 1);
bleprofile_GenerateADVData(adv, 3);
}
blecm_setTxPowerInADV(0);
bleprofile_Discoverable(HIGH_UNDIRECTED_DISCOVERABLE, NULL);
// ToDo: Do your initialization on app startup
// start device advertisements. By default Advertisements will contain flags, device name,
// appearance and main service UUID.
}
// Connection up callback function is called on every connection establishment
void turquoisebicuspid_connection_up(void)
{
turquoisebicuspid_connection_handle = (UINT16)emconinfo_getConnHandle();
UINT8 *bda = (UINT8 *)emconninfo_getPeerPubAddr();
// Save address of the connected device and print it out.
memcpy(turquoisebicuspid_remote_addr, bda, sizeof(turquoisebicuspid_remote_addr));
ble_trace3("connection_up: %08x%04x h=%d",
(turquoisebicuspid_remote_addr[5] << 24) + (turquoisebicuspid_remote_addr[4] << 16) +
(turquoisebicuspid_remote_addr[3] << 8) + turquoisebicuspid_remote_addr[2],
(turquoisebicuspid_remote_addr[1] << 8) + turquoisebicuspid_remote_addr[0],
turquoisebicuspid_connection_handle);
// Prepare generated code for connection - write persistent values from __HOSTINFO to GATT DB
__on_connection_up();
// ToDo: Write custom persistent values into GATT database using functions
// changed_<service_name>_<char_name>() generated by smart disigner
// If device supports a single connection, stop advertising
bleprofile_Discoverable(NO_DISCOVERABLE, NULL);
// If security is required for every connection following function will start bonding or
// will setup encryption. No indications or notifications should be sent until
// encryption is not done.
if (bleprofile_p_cfg->encr_required & SECURITY_REQUEST)
lesmp_sendSecurityRequest();
}
// Connection down callback
void turquoisebicuspid_connection_down(void)
{
ble_trace1("connection_down:handle:%d", turquoisebicuspid_connection_handle);
turquoisebicuspid_connection_handle = 0;
// If disconnection was caused by the peer, start low advertisements
bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);
ble_trace2("ADV start: %08x%04x",
(turquoisebicuspid_remote_addr[5] << 24 ) + (turquoisebicuspid_remote_addr[4] <<16) +
(turquoisebicuspid_remote_addr[3] << 8 ) + turquoisebicuspid_remote_addr[2],
(turquoisebicuspid_remote_addr[1] << 8 ) + turquoisebicuspid_remote_addr[0]);
}
// Callback function indicates to the application that advertising has stopped.
// restart advertisement if needed
void turquoisebicuspid_advertisement_stopped(void)
{
ble_trace0("ADV stop!!!!");
// If disconnection was caused by the peer, start low advertisements
bleprofile_Discoverable(LOW_UNDIRECTED_DISCOVERABLE, NULL);
}
// Process SMP bonding result. If pairing is successful with the central device,
// save its BDADDR in the NVRAM and initialize associated data
void turquoisebicuspid_smp_bond_result(LESMP_PARING_RESULT result)
{
ble_trace1("smp_bond_result %02x", result);
if (result == LESMP_PAIRING_RESULT_BONDED)
{
// saving bd_addr in nvram
UINT8 *bda;
UINT8 writtenbyte;
bda = (UINT8 *)emconninfo_getPeerPubAddr();
// initialize persistent values in the hostinfo to add bonded peer
turquoisebicuspid_add_bond(bda);
// ToDo: initialize persistent variables in HOSTINFO
//now write hostinfo into NVRAM
writtenbyte = bleprofile_WriteNVRAM(VS_BLE_HOST_LIST, sizeof(turquoisebicuspid_hostinfo), (UINT8 *)&turquoisebicuspid_hostinfo);
ble_trace1("NVRAM write:%04x", writtenbyte);
}
}
// Notification from the stack that encryption has been set.
void turquoisebicuspid_encryption_changed(HCI_EVT_HDR *evt)
{
UINT8 *bda = emconninfo_getPeerPubAddr();
ble_trace2("encryption changed %08x%04x",
(bda[5] << 24) + (bda[4] << 16) +
(bda[3] << 8) + bda[2],
(bda[1] << 8) + bda[0]);
// ToDo: do your on-encryption-change actions here.
// Slow down the pace of master polls to save power. Following request asks
// host to setup polling every 100-500 msec, with link supervision timeout 5 seconds.
bleprofile_SendConnParamUpdateReq(80, 400, 0, 500);
}
// Process write request or command from peer device
int turquoisebicuspid_write_handler(LEGATTDB_ENTRY_HDR *p)
{
UINT8 writtenbyte;
UINT16 handle = legattdb_getHandle(p);
int len = legattdb_getAttrValueLen(p);
UINT8 *attrPtr = legattdb_getAttrValue(p);
BOOL changed;
ble_trace1("write_handler: handle %04x", handle);
changed = __write_handler(handle, len, attrPtr);
// Save update to NVRAM if it has been changed.
if (changed)
{
writtenbyte = bleprofile_WriteNVRAM(VS_BLE_HOST_LIST, sizeof(turquoisebicuspid_hostinfo), (UINT8 *)&turquoisebicuspid_hostinfo);
ble_trace1("NVRAM write:%04x", writtenbyte);
}
return 0;
}
// Three Interrupt inputs (Buttons) can be handled here.
// If the following value == 1, Button is pressed. Different than initial value.
// If the following value == 0, Button is depressed. Same as initial value.
// Button1 : value&0x01
// Button2 : (value&0x02)>>1
// Button3 : (value&0x04)>>2
void turquoisebicuspid_interrupt_handler(UINT8 value)
{
// On press.
if(value & 1)
{
ble_trace0("turquoisebicuspid_interrupt_handler()");
turquoisebicuspid_blink_led1();
}
}
// Process indication confirmation. if client service indication, each indication
// should be acknowledged before the next one can be sent.
void turquoisebicuspid_indication_cfm(void)
{
}
//------ generated code
void turquoisebicuspid_blink_led1(void)
{
ble_trace0("turquoisebicuspid_blink_led1()");
bleprofile_LEDBlink(250, 250, 2);
gpio_configurePin((TURQUOISEBICUSPID_LED1_GPIO) / 16, (TURQUOISEBICUSPID_LED1_GPIO) % 16, GPIO_OUTPUT_ENABLE, 1);
gpio_setPinOutput((TURQUOISEBICUSPID_LED1_GPIO) / 16, (TURQUOISEBICUSPID_LED1_GPIO) % 16, 1);
}
//***************************************************************
/** TurquoiseBicuspid_db.h
/*
* This file has been automatically generated by the WICED Smart Designer.
* Definitions for constants used in the device's GATT database and function
* prototypes that can be used to send notifications
*
*/
// TurquoiseBicuspid_db.h
#define GATT_DB_ENABLE_UART //UART is enabled in wic file
// ***** Primary service 'Generic Access'
#define HDLS_GENERIC_ACCESS 0x0100
#define UUID_SERVICE_GAP 0x1800
// ----- Characteristic 'Device Name'
#define HDLC_GENERIC_ACCESS_DEVICE_NAME 0x0110
#define HDLC_GENERIC_ACCESS_DEVICE_NAME_VALUE 0x0111
#define UUID_CHARACTERISTIC_DEVICE_NAME 0x2A00
// ----- Characteristic 'Appearance'
#define HDLC_GENERIC_ACCESS_APPEARANCE 0x0120
#define HDLC_GENERIC_ACCESS_APPEARANCE_VALUE 0x0121
#define UUID_CHARACTERISTIC_APPEARANCE 0x2A01
// ***** Primary service 'Generic Attribute'
#define HDLS_GENERIC_ATTRIBUTE 0x0200
#define UUID_SERVICE_GATT 0x1801
#pragma pack(1)
// Host information for NVRAM
typedef PACKED struct
{
// BD address of the bonded host
BD_ADDR bdaddr;
} __HOSTINFO;
#pragma pack()
// External definitions
extern const UINT8 gatt_database[];
extern const UINT16 gatt_database_len;
extern UINT16 turquoisebicuspid_connection_handle; // HCI handle of connection, not zero when connected
extern const BLE_PROFILE_GPIO_CFG
turquoisebicuspid_gpio_cfg; // Defines GPIO configuration used by the application
extern BD_ADDR turquoisebicuspid_remote_addr; // Address of currently connected client
extern UINT8 turquoisebicuspid_uuid_main_vsc_service[1]; // main vendor specific service. 1 byte length means no such service
// Pointer to the generated part of hostinfo
extern __HOSTINFO *p_hostinfo_generated;
// Functions definitions
// Will be called on indication conformation
// Registers timer. Should be called from turquoisebicuspid_create()
extern void turquoisebicuspid_reg_timer();
// Initializes persistent values in the hostinfo to add bonded peer
extern void turquoisebicuspid_add_bond(UINT8 *bda);
// Prepares generated code for connection - writes persistent values from __HOSTINFO to GATT DB
extern void __on_connection_up();
// Sends notifications or/and indications for every client configuration descriptor
// Updates __HOSTINFO by the value written by peer.
// Returns true if any persistent value is changed
extern BOOL __write_handler(UINT16 handle, int len, UINT8 *attrPtr);
// ------------------- You have to implement these functions ----------------
// ------------------- You can call these functions ----------------
// It should be called when 'Device Name' is changed
extern BOOL store_in_db_generic_access_device_name(UINT8* p_value, UINT8 value_len);
// It should be called when 'Appearance' is changed
extern BOOL store_in_db_generic_access_appearance(UINT8* p_value, UINT8 value_len);
//***************************************************************
/** TurquoiseBicuspid_db.c
/*
* This file has been automatically generated by the WICED Smart Designer.
* BLE device's GATT database, device configuration, function that can be used
* to send notifications and indications.
*
*/
// TurquoiseBicuspid_db.c
#include "bleprofile.h"
#include "bleapp.h"
#include "gpiodriver.h"
#include "string.h"
#include "stdio.h"
#include "platform.h"
#include "TurquoiseBicuspid_db.h"
const UINT8 gatt_database[]= // Define GATT database
{
// ***** Primary service 'Generic Access'
//<Name>Generic Access</Name>
//<Uuid>1800</Uuid>
//Service handle: HDLS_GENERIC_ACCESS
//Service UUID: UUID_SERVICE_GAP
PRIMARY_SERVICE_UUID16 (HDLS_GENERIC_ACCESS, UUID_SERVICE_GAP),
//<Name>Device Name</Name>
//<Uuid>2A00</Uuid>
CHARACTERISTIC_UUID16 (HDLC_GENERIC_ACCESS_DEVICE_NAME,
HDLC_GENERIC_ACCESS_DEVICE_NAME_VALUE,
UUID_CHARACTERISTIC_DEVICE_NAME,
LEGATTDB_CHAR_PROP_READ,
LEGATTDB_PERM_READABLE,
17),
'T','u','r','q','u','o','i','s','e','B','i','c','u','s','p','i','d',
//<Name>Appearance</Name>
//<Uuid>2A01</Uuid>
CHARACTERISTIC_UUID16 (HDLC_GENERIC_ACCESS_APPEARANCE,
HDLC_GENERIC_ACCESS_APPEARANCE_VALUE,
UUID_CHARACTERISTIC_APPEARANCE,
LEGATTDB_CHAR_PROP_READ,
LEGATTDB_PERM_READABLE,
2),
0x00,0x00,
// ***** Primary service 'Generic Attribute'
//<Name>Generic Attribute</Name>
//<Uuid>1801</Uuid>
//Service handle: HDLS_GENERIC_ATTRIBUTE
//Service UUID: UUID_SERVICE_GATT
PRIMARY_SERVICE_UUID16 (HDLS_GENERIC_ATTRIBUTE, UUID_SERVICE_GATT),
};
// Length of the GATT database
const UINT16 gatt_database_len = sizeof(gatt_database);
// Pointer to the bonded peer info or NULL if not bonded
__HOSTINFO *p_bonded = NULL;
// Following structure defines GPIO configuration used by the application
const BLE_PROFILE_GPIO_CFG turquoisebicuspid_gpio_cfg =
{
{
GPIO_PIN_WP, // This need to be used to enable/disable NVRAM write protect
GPIO_PIN_BUTTON, GPIO_PIN_LED, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // Other GPIOs are not used
},
/*.gpio_flag =*/
{
GPIO_SETTINGS_WP,
GPIO_SETTINGS_BUTTON, GPIO_SETTINGS_LED, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
}
};
// Main vendor specific service. 1 byte length means no such service
UINT8 turquoisebicuspid_uuid_main_vsc_service[1] = {0};
// Registers timer. Should be called from turquoisebicuspid_create()
void turquoisebicuspid_reg_timer()
{
}
// Finds bonded peer in the hostinfo. On exit p_bonded points on bonded peer or NULL
__HOSTINFO *__find_bonded_peer(UINT8 *bda)
{
int i;
p_bonded = NULL;
if (0 == memcmp(bda, p_hostinfo_generated->bdaddr, 6))
{
p_bonded = p_hostinfo_generated;
}
return p_bonded;
}
// initializes persistent values in the hostinfo to add bonded peer
void turquoisebicuspid_add_bond(UINT8 *bda)
{
// Find this peer among bonded peers in the p_hostinfo_generated
if (!__find_bonded_peer(bda));
{
// Peer is not found. Remember new one.
p_bonded = p_hostinfo_generated;
memcpy(p_bonded->bdaddr, bda, 6);
}
// Clear persistent generated values in the hostinfo for just bonded peer
}
// Prepares generated code for connection - writes persistent values from __HOSTINFO to GATT DB
void __on_connection_up()
{
// Find this peer among bonded peers in the p_hostinfo_generated
if (__find_bonded_peer(turquoisebicuspid_remote_addr))
{
BLEPROFILE_DB_PDU db_pdu;
}
}
// Updates __HOSTINFO by the value written by peer.
// Returns true if any persistent value is changed
BOOL __write_handler(UINT16 handle, int len, UINT8 *attrPtr)
{
BOOL res = FALSE;
return res;
}
// It should be called when 'Device Name' is changed.
BOOL store_in_db_generic_access_device_name(UINT8* p_value, UINT8 value_len)
{
BLEPROFILE_DB_PDU db_pdu;
// Write value to the GATT DB
ble_trace2("write len:%d handle:%02x", value_len, HDLC_GENERIC_ACCESS_DEVICE_NAME_VALUE);
memcpy(&db_pdu.pdu[0], p_value, value_len);
db_pdu.len = value_len;
bleprofile_WriteHandle(HDLC_GENERIC_ACCESS_DEVICE_NAME_VALUE, &db_pdu);
return TRUE;
}
// It should be called when 'Appearance' is changed.
BOOL store_in_db_generic_access_appearance(UINT8* p_value, UINT8 value_len)
{
BLEPROFILE_DB_PDU db_pdu;
// Write value to the GATT DB
ble_trace2("write len:%d handle:%02x", value_len, HDLC_GENERIC_ACCESS_APPEARANCE_VALUE);
memcpy(&db_pdu.pdu[0], p_value, value_len);
db_pdu.len = value_len;
bleprofile_WriteHandle(HDLC_GENERIC_ACCESS_APPEARANCE_VALUE, &db_pdu);
return TRUE;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment