Exemplo n.º 1
0
extern app_time_error_code ConfigureCTSNotification(bool disable_notify)
{
    if(g_time_serv_data.notify_configured == TRUE)
    {
        return error_success;
    }

    /* if current time service supported by the server enable
     * for notifications.
     */
    if(g_time_serv_data.connected_device_services & cts_supported)
    {
        sys_status ret = sys_status_success;

        /* Set the value to disable notification on the client config handle */
        uint8 notification_enabled[2] =
                        { WORD_LSB(gatt_client_config_none),
                          WORD_MSB(gatt_client_config_none)};

        if(g_time_serv_data.conf_handle_ptr)
        {
            /* since it is already busy */
            return error_cmd_inprogress;
        }

        /* enable the notification if disabling is set to false. normally
         * it will be enabled.
         */
        if(disable_notify == FALSE)
        {
            notification_enabled[0] = WORD_LSB(gatt_client_config_notification);
            notification_enabled[1] = WORD_MSB(gatt_client_config_notification);
        }

        /* Start with enabling notifications on client configuration
         * descriptors of current time characteristic.
         */
        g_time_serv_data.conf_handle_ptr = &g_time_serv_data.cur_time_ccd_hndl;

        /* Send the write request */
        ret = GattWriteCharValueReq(GetConnectionID(),
                              GATT_WRITE_REQUEST,
                              g_time_serv_data.cur_time_ccd_hndl,
                              sizeof(notification_enabled) /*size_value*/,
                              notification_enabled);
        if(ret != sys_status_success)
        {
            g_time_serv_data.conf_handle_ptr = NULL;
            return error_not_ready;
        }
    }

    return error_success;
}
Exemplo n.º 2
0
// Получение последних событий.
String meth::GetActions(LogicalConnections::iterator conn, SOCKET sd) {
	String response = "";

	response = GetMessagesByConnection(GetConnectionID(conn));

	if (response.IsEmpty()) {
		SetConnectionSocket(conn, sd);
		SetConnectionActionsGet(conn, true);
	}

	return response;
}
Exemplo n.º 3
0
extern void HandleGattDiscServCharComplete(void)
{
    /* Descriptors are supported only for cts hence request for the same */
    if(g_time_serv_data.connected_device_services & cts_supported)
    {
        /* Discover characteristic descriptors of CTS characteristic
         */
        GattDiscoverAllCharDescriptors(GetConnectionID(),
                                   g_time_serv_data.cur_time_handle,
                                   g_time_serv_data.cts_end_handle);

        g_time_serv_data.conf_handle_ptr = &g_time_serv_data.cur_time_ccd_hndl;
    }
}
Exemplo n.º 4
0
extern app_time_error_code TimeReadCurrentTime(void)
{
    if(g_time_serv_data.conf_handle_ptr)
    {
        /* since it is already busy */
        return error_cmd_inprogress;
    }

    g_time_serv_data.conf_handle_ptr = &g_time_serv_data.cur_time_handle;

    sys_status ret = GattReadCharValue(GetConnectionID(),
                          g_time_serv_data.cur_time_handle);

    if(ret != sys_status_success)
    {
        g_time_serv_data.conf_handle_ptr = NULL;
        return error_not_ready;
    }
    return error_success;
}
Exemplo n.º 5
0
extern app_time_error_code TimeReadRefTimeInfo(void)
{
    if((g_time_serv_data.conf_handle_ptr) ||
        (!g_time_serv_data.local_time_info_handle))
    {
        /* since it is already busy */
        return error_cmd_inprogress;
    }

    g_time_serv_data.conf_handle_ptr = &g_time_serv_data.ref_time_info_handle;

    sys_status ret = GattReadCharValue(GetConnectionID(),
                          g_time_serv_data.ref_time_info_handle);

    if(ret != sys_status_success)
    {
        g_time_serv_data.conf_handle_ptr = NULL;
        return error_not_ready;
    }
      return error_success;
}
Exemplo n.º 6
0
extern app_time_error_code TimeUpdateControlPoint(uint8 ctrl)
{
    if((g_time_serv_data.conf_handle_ptr) ||
        (!g_time_serv_data.local_time_info_handle))
    {
        /* since it is already busy */
        return error_cmd_inprogress;
    }

    sys_status ret = GattWriteCharValueReq(GetConnectionID(),
                          GATT_WRITE_COMMAND,
                          g_time_serv_data.time_update_cp_handle,
                          sizeof(ctrl) /*size_value*/,
                          &ctrl);

    if(ret != sys_status_success)
    {
        g_time_serv_data.conf_handle_ptr = NULL;
        return error_not_ready;
    }
    return error_success;
}
Exemplo n.º 7
0
void ConnectionsManager::RemoveConnection(Connection c) {
    RemoveConnection(GetConnectionID(c));
}
Exemplo n.º 8
0
bool ConnectionsManager::IsKnownConnection(Connection c) {
    return GetConnectionID(c) != 0;
}