Example #1
1
/**
 * \brief Timer Callback function  if identify command is received on air
 *        by a node in reflector configuration. This is used to blink the LED
 *        and thus identify itself
 *
 * \param parameter pass parameters to timer handler
 */
void led_blinker_timer_handler_cb(void *parameter)
{
#if (LED_COUNT > 0)
	static uint8_t led_count;
	parameter = parameter;
	/* LED Blinking sequence is completed */
	if (led_count > LED_BLINK_COUNT_FOR_IDENTIFY) {
		led_count = 0;
		app_led_event(LED_EVENT_PEER_SEARCH_DONE);
	} else { /* Blink count is not completed  */
		 /* For every timeout switch off and on all LEDs alternatively
		 **/
		if (led_count & 0x01) {
			led_count++;
			app_led_event(LED_EVENT_ALL_OFF);
			sw_timer_stop(APP_TIMER_TO_TX);
		} else {
			led_count++;
			app_led_event(LED_EVENT_ALL_ON);
		}

		sw_timer_start(APP_TIMER_TO_TX,
				LED_BLINK_RATE_IN_MICRO_SEC,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_blinker_timer_handler_cb,
				NULL);
	}
#endif
	return;
}
Example #2
0
/**
 * \brief This function is called to abort the packet streaming mode inprogress
 */
void stop_pkt_streaming(void * parameter)
{
	pkt_stream_stop = true;
	sw_timer_stop(T_APP_TIMER);
	if(sw_timer_is_running(CW_TX_TIMER))
	{
		sw_timer_stop(CW_TX_TIMER);
	}			
	usr_pkt_stream_confirm(MAC_SUCCESS,false);
	if(node_info.main_state == PER_TEST_RECEPTOR)
	{
		sw_timer_start(T_APP_TIMER,
		LED_BLINK_RATE_IN_MICRO_SEC,
		SW_TIMEOUT_RELATIVE,
		(FUNC_PTR)led_blinker_timer_handler_cb,
		NULL);
	}
}
Example #3
0
/**
 * \brief This function initiates packet streaming test.
 * \param gap_time Gap to be provided between consecutive frames 
 *  in terms of milliseconds
 * \timeout : This parameter is used by the receptor node to 
 *   timeout/stop the packet streaming 
 * \param frame_len Length of the Data frame to be streamed
 */
void pktstream_test(uint16_t gap_time,uint16_t timeout,bool start_stop,uint16_t frame_len)
{
	pkt_stream_gap_time = gap_time;
	/*Return if the frame length is less than 127(Max MPDU Length)*/
	if(frame_len<=127)
	{
		usr_pkt_stream_confirm(MAC_SUCCESS,start_stop);
	}
	else
	{
		usr_pkt_stream_confirm(INVALID_ARGUMENT,start_stop);
	}
	
/*  Send the Packet Stream Start Confirm in case of Receptor before beginning
 *  packet streaming.Serial Handler will take care in sending the confirmation
 *   over the air to the Host*/
	if((node_info.main_state == PER_TEST_RECEPTOR))
	{
		serial_data_handler();
	}
	if(start_stop)
	{
		/*Configure the frame for streaming*/
		configure_pkt_stream_frames(frame_len);
		
		op_mode=PKT_STREAM_MODE;
		
		/*Start the gap timer*/
		if(pkt_stream_gap_time)
		{
			sw_timer_start(T_APP_TIMER,pkt_stream_gap_time*1E3,SW_TIMEOUT_RELATIVE,(FUNC_PTR)pkt_stream_gap_timer,NULL);
		}
		else
		{
			rdy_to_tx = true;
		}
		pkt_stream_stop = false;
		
		if((node_info.main_state == PER_TEST_RECEPTOR) && 1 <= timeout )
		{
			sw_timer_start(CW_TX_TIMER,
			(uint32_t)timeout * 1E6,
			SW_TIMEOUT_RELATIVE,
			(FUNC_PTR)stop_pkt_streaming,
			NULL);
		}
	}
	else
	{
	/*stop packet streaming once the current packet transmission is completed*/
		pkt_stream_stop = true;
		sw_timer_stop(T_APP_TIMER);
		 op_mode=TX_OP_MODE;
	}
	
	
}
Example #4
0
retval_t pal_timer_stop(uint8_t timer_id)
{
	uint8_t status;

	status = sw_timer_stop(timer_id);

	if (STATUS_OK == (status_code_genare_t)status) {
		return MAC_SUCCESS;
	} else if (ERR_TIMER_NOT_RUNNING == (status_code_t)status) {
		return PAL_TMR_NOT_RUNNING;
	} else {
		return PAL_TMR_INVALID_ID;
	}
}
Example #5
0
/**
 * @brief Function to handle the LED States based on application state.
 *
 *
 * @param callback_parameter  callback parameter if any.
 */
static void led_handling(void *callback_parameter)
{
	switch (node_status) {
	case ZID_CONNECTING:
	case ALL_IN_ONE_START:
		sw_timer_start(APP_TIMER,
				PAIR_WAIT_PERIOD,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_handling,
				NULL);
		LED_Toggle(LED_NWK_SETUP);
		break;

	default:
		sw_timer_stop(APP_TIMER);
		break;
	}

	/* Keep compiler happy */
	callback_parameter = callback_parameter;
}
Example #6
0
/**
 * @brief LED handling including timer control .
 */
static void led_handling(void *callback_parameter)
{
	switch (node_status) {
	case PUSH_BUTTON_PAIRING:
	case ALL_IN_ONE_START:
		sw_timer_start(led_timer,
				500000,
				SW_TIMEOUT_RELATIVE,
				(FUNC_PTR)led_handling,
				NULL);
		LED_Toggle(LED_NWK_SETUP);
		break;

	default:
		sw_timer_stop(led_timer);
		LED_Off(LED_DATA);
		LED_Off(LED_NWK_SETUP);
		break;
	}

	/* Keep compiler happy */
	callback_parameter = callback_parameter;
}
Example #7
0
/**
 * \brief function to exit peer req send state
 */
static void peer_req_send_exit()
{
    /* Off timer as node leaves this sub state */
    sw_timer_stop(APP_TIMER_TO_TX);
}
/**
 * \brief Function to exit wait for peer search conf state.
 *
 * This function
 * - Implements the peer search state machine.
 */
static void wait_for_conf_exit(void)
{
	/* stop the timer as node leaves this sub state */
	sw_timer_stop(APP_TIMER_TO_TX);
}
Example #9
0
/*
 * \brief To exit the Application task from RANGE_TEST_TX_ON state,
 *
 * where both TX and RX is enabled
 */
void range_test_tx_on_exit(void)
{
    print_event(PRINT_RANGE_MEASURE_TX_STOP);
    /* Off timer as node leaves this sub state */
    sw_timer_stop(APP_TIMER_TO_TX);
}