Example #1
0
static int _mlme_get_var(uint16_t us_var, uint8_t *puc_result)
{
	uint16_t pibAttrib;
	int l_result = 0;

	switch (uc_mlme_get_var_st) {
	case MLMEGET_SEND_REQUEST:
		if (prime_MLME_GET_request(us_var) == 0) {
			uc_mlme_get_var_st = MLMEGET_WAIT_ANSWER;
		}

		break;

	case MLMEGET_WAIT_ANSWER:
		if (prime_MLME_callback(puc_result)) {
			/* Check cmd and result */
			if ((puc_result[0] == PRIME_MLME_GET_CONFIRM) && (puc_result[1] == PRIME_MLME_RESULT_SUCCESS)) {
				pibAttrib = (uint16_t)(puc_result[2] << 8) + (uint16_t)puc_result[3];
				if (pibAttrib == us_var) {
					l_result = 1;
				}
			}

			/* Next time we start again in MLMEGET_SEND_REQUEST or retry now */
			uc_mlme_get_var_st = MLMEGET_SEND_REQUEST;
		}

		break;
	}
	return l_result;
}
Example #2
0
/**
 * \brief Function to encapsulate MLME Tx Control Process
 *
 * \note This function will be called using a pointer
 *
 * \retval 0 if the request has been sent
 * \retval -1 if the request has not been sent
 */
int8_t serial_if_mlme_process(void)
{
	int l_len, l_packet_len;
	int8_t c_result = -1;
	x_usi_serial_cmd_params_t x_pkt_usi;

	l_len = prime_MLME_callback(NewMlmeCallBackCmd);
	if (l_len > 0) {
		l_packet_len = _serial_if_mlme_pack_mlme_callback(NewMlmeCallBackCmd, l_len);
		/* pack and send the primitive */
		x_pkt_usi.uc_protocol_type = PROTOCOL_MLME_PRIME;
		x_pkt_usi.ptr_buf = &NewMlmeCallBackCmd[0];
		x_pkt_usi.us_len = l_packet_len;
		c_result = usi_send_cmd(&x_pkt_usi);
	}

	return(c_result);
}