Esempio n. 1
0
extern void GapHandleAccessWrite(GATT_ACCESS_IND_T *p_ind)
{
    sys_status rc = sys_status_success;

    switch(p_ind->handle)
    {

        case HANDLE_DEVICE_NAME:
            /* Update device name */
            updateDeviceName(p_ind->size_value, p_ind->value);
        break;

#ifdef __GAP_PRIVACY_SUPPORT__

        case HANDLE_PERIPHERAL_PRIVACY_FLAG:
            GapSetPeripheralPrivacyFlag(BufReadUint8(&p_ind->value));
        break;

        case HANDLE_RECONNECTION_ADDRESS:
            /* There is no specific application error code when the remote
             * device writes to the reconnection address when peripheral
             * privacy flag is disabled. So, send a success write response
             * but don't update the reconnection address.
             */
            if(g_gap_data.peripheral_privacy_flag)
            {
                /* Store the re-connection address only if it is valid. */
                if(GapIsReconnectionAddressValid())
                {
                    GapSetReconnectionAddress(p_ind->value);
                }
            }
        break;
            
#endif /* __GAP_PRIVACY_SUPPORT__ */

        default:
        {
            /* No more IRQ characteristics */
            rc = gatt_status_write_not_permitted;
        }
        break;

    }

    GattAccessRsp(p_ind->cid, p_ind->handle, rc, 0, NULL);

}
Esempio n. 2
0
extern void GapHandleAccessWrite(GATT_ACCESS_IND_T *p_ind)
{
    sys_status rc = sys_status_success;

    switch(p_ind->handle)
    {

        case HANDLE_DEVICE_NAME:
            /* Update device name */
            updateDeviceName(p_ind->size_value, p_ind->value);
        break;

        default:
            /* No more IRQ characteristics */
            rc = gatt_status_write_not_permitted;
        break;

    }

    GattAccessRsp(p_ind->cid, p_ind->handle, rc, 0, NULL);

}
Esempio n. 3
0
extern void GapReadDataFromNVM(uint16 *p_offset)
{
    g_gap_data.nvm_offset = *p_offset;

    /* Read Device Length */
    Nvm_Read(&g_gap_data.length, sizeof(g_gap_data.length), 
             *p_offset + 
             GAP_NVM_DEVICE_LENGTH_OFFSET);

    /* If the dev name length read from the NVM is incorrect then better update
     * the NVM with the correct device name and its length.
     */
    if(g_gap_data.length > DEVICE_NAME_MAX_LENGTH)
    {
        g_gap_data.p_dev_name = (g_device_name + 1);
        g_gap_data.length = StrLen((char *)g_gap_data.p_dev_name);
        updateDeviceName(g_gap_data.length, g_gap_data.p_dev_name);
    }
    else
    {
        /* Read Device Name 
         * Typecast of uint8 to uint16 or vice-versa shall not have any side 
         * affects as both types (uint8 and uint16) take one word memory on XAP
         */
        Nvm_Read((uint16*)g_gap_data.p_dev_name, g_gap_data.length, 
                 *p_offset + 
                 GAP_NVM_DEVICE_NAME_OFFSET);

        /* Add NULL character to terminate the device name string */
        g_gap_data.p_dev_name[g_gap_data.length] = '\0';
    }
    /* Increase NVM offset for maximum device name length. Add 1 for
     * 'device name length' field as well
     */
    *p_offset += DEVICE_NAME_MAX_LENGTH + 1;
}