Last active
August 29, 2015 14:10
-
-
Save Mithrandir0x/829aa2f0ffb0d4261490 to your computer and use it in GitHub Desktop.
Trames de capa de control d'enllaç
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "lc_protocol.h" | |
/** | |
* Link Control Packet Definitions | |
*/ | |
#define LC_PCK_BROADCAST_REQUEST 0xFF | |
#define LC_PCK_NODE_RESPONSE 0x0F | |
#define LC_PCK_START_VRT 0xAE | |
#define LC_PCK_VRT_STARTED 0xAA | |
#define LC_PCK_DATA_REQUEST 0x13 | |
#define LC_PCK_DATA_RESPONSE 0x14 | |
void lc_set_tx_broadcast_request(BASIC_RF_TX_INFO *tx) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = FALSE; | |
tx->destAddr = 0xFFFF; | |
tx->length = 1; | |
tx->pPayload[0] = LC_PCK_BROADCAST_REQUEST; | |
} | |
void lc_set_tx_node_response(BASIC_RF_TX_INFO *tx, UINT16 destAddr) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = TRUE; | |
tx->destAddr = destAddr; | |
tx->length = 1; | |
tx->pPayload[0] = LC_PCK_NODE_RESPONSE; | |
} | |
void lc_set_tx_start_vrt(BASIC_RF_TX_INFO *tx, UINT16 destAddr) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = TRUE; | |
tx->destAddr = destAddr; | |
tx->length = 1; | |
tx->pPayload[0] = LC_PCK_START_VRT; | |
} | |
void lc_set_tx_vrt_started(BASIC_RF_TX_INFO *tx, UINT16 destAddr) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = TRUE; | |
tx->destAddr = destAddr; | |
tx->length = 1; | |
tx->pPayload[0] = LC_PCK_VRT_STARTED; | |
} | |
void lc_set_tx_data_request(BASIC_RF_TX_INFO *tx, UINT16 destAddr) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = FALSE; | |
tx->destAddr = destAddr; | |
tx->length = 1; | |
tx->pPayload[0] = LC_PCK_DATA_REQUEST; | |
} | |
void lc_set_tx_data_response(BASIC_RF_TX_INFO *tx, UINT16 destAddr, UINT16 temperature) | |
{ | |
tx->destPanId = rfSettings.panId; | |
tx->ackRequest = TRUE; | |
tx->destAddr = destAddr; | |
tx->length = 3; | |
tx->pPayload[0] = LC_PCK_DATA_RESPONSE; | |
tx->pPayload[1] = temperature >> 8; | |
tx->pPayload[2] = temperature; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment