Beispiel #1
0
avb_status_t avb_1722_1_adp_advertising_periodic(chanend c_tx, chanend ptp)
{
	guid_t ptp_current;

	switch (adp_advertise_state)
	{
		case ADP_ADVERTISE_IDLE:
			break;

		case ADP_ADVERTISE_WAITING:
			if (avb_timer_expired(&adp_readvertise_timer))
			{
				adp_advertise_state = ADP_ADVERTISE_ADVERTISE_1;
			}
			break;

		case ADP_ADVERTISE_ADVERTISE_0:
			avb_1722_1_adp_change_ptp_grandmaster(ptp_current.c);
			start_avb_timer(&ptp_monitor_timer, 1); //Every second
			adp_advertise_state = ADP_ADVERTISE_ADVERTISE_1;
			// Fall through and send immediately

		case ADP_ADVERTISE_ADVERTISE_1:
			avb_1722_1_create_adp_packet(ENTITY_AVAILABLE, my_guid);
			mac_tx(c_tx, avb_1722_1_buf, AVB_1722_1_ADP_PACKET_SIZE, ETH_BROADCAST);

			start_avb_timer(&adp_readvertise_timer, AVB_1722_1_ADP_REPEAT_TIME);
			adp_advertise_state = ADP_ADVERTISE_WAITING;
			avb_1722_1_available_index++;
			break;

		case ADP_ADVERTISE_DEPARTING:
			avb_1722_1_create_adp_packet(ENTITY_DEPARTING, my_guid);
			mac_tx(c_tx, avb_1722_1_buf, AVB_1722_1_ADP_PACKET_SIZE, ETH_BROADCAST);

			adp_advertise_state = ADP_ADVERTISE_IDLE;
			avb_1722_1_available_index = 0;

			break;

		default:
			break;
	}

	if (ADP_ADVERTISE_IDLE != adp_advertise_state)
	{
		if(avb_timer_expired(&ptp_monitor_timer))
		{
			ptp_get_current_grandmaster(ptp, ptp_current.c);
			if(as_grandmaster_id.l != ptp_current.l)
			{
				avb_1722_1_adp_change_ptp_grandmaster(ptp_current.c);
				adp_advertise_state = ADP_ADVERTISE_ADVERTISE_1;
			}
			start_avb_timer(&ptp_monitor_timer, 1); //Every second
		}
	}

	return AVB_NO_STATUS;
}
Beispiel #2
0
void acmp_progress_inflight_timer(int entity_type)
{
    if (avb_timer_expired(&acmp_inflight_timer[entity_type]))
    {
        acmp_centisecond_counter[entity_type]++;
        start_avb_timer(&acmp_inflight_timer[entity_type], 1);
    }
}
Beispiel #3
0
avb_status_t avb_1722_1_adp_discovery_periodic(chanend c_tx)
{
	switch (adp_discovery_state)
	{
		case ADP_DISCOVERY_IDLE:
			break;

		case ADP_DISCOVERY_WAITING:
		{
			unsigned lost=0;
			if (avb_timer_expired(&adp_discovery_timer))
			{
				adp_two_second_counter++;
				lost = avb_1722_1_entity_database_check_timeout();
				start_avb_timer(&adp_discovery_timer, 1);
			}
			return (lost > 0) ? AVB_1722_1_ENTITY_REMOVED : AVB_NO_STATUS;
		}
		case ADP_DISCOVERY_DISCOVER:
		{
				avb_1722_1_create_adp_packet(ENTITY_DISCOVER, discover_guid);
				mac_tx(c_tx, avb_1722_1_buf, AVB_1722_1_ADP_PACKET_SIZE, ETH_BROADCAST);
				adp_discovery_state = ADP_DISCOVERY_WAITING;
				break;
		}
		case ADP_DISCOVERY_ADDED:
		{
			adp_discovery_state = ADP_DISCOVERY_WAITING;
			return AVB_1722_1_ENTITY_ADDED;
		}
		case ADP_DISCOVERY_REMOVED:
		{
			adp_discovery_state = ADP_DISCOVERY_WAITING;
			return AVB_1722_1_ENTITY_REMOVED;
		}
	}

	return AVB_NO_STATUS;
}