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
/**
 * \internal
 * \brief This function extracts the MLME SAP Get.Request.
 *
 * \note This function extracts the MLME SAP Get.Request from the
 * received packet and stores the data in the circular buffer if possible.
 *
 * \retval 0 primitive stored
 * \retval -1 primitive could not be stored
 */
static int _serial_if_mlme_unpack_get_req(void)
{
	uint8_t *puc_rx_buff;
	uint16_t us_pib_attr;

	/* Extract MLME primitive */
	puc_rx_buff = puc_rx;
	us_pib_attr = (((uint16_t)puc_rx_buff[0]) << 8) + (uint16_t)puc_rx_buff[1];

	/* Store the primitive in the circular buffer */
	return(prime_MLME_GET_request(us_pib_attr));
}