Jump to content
43oh

kstuart

Members
  • Content Count

    3
  • Joined

  • Last visited

Reputation Activity

  1. Like
    kstuart reacted to CorB in Anaren TI CC110L RF AIR Booster Pack   
    This link shows how I uses packages to send information around:
    http://forum.43oh.com/topic/1433-anaren-ti-cc110l-rf-air-booster-pack/?p=17770
     
    Below a bit more on the secrets You can define the payload any way you wish with any data you want to transfer. As you can see my setup uses ACKs and also nodeIDs but you could do that completely different. The only mandatory thing (at least its wise) is to start with an addr part in your payloadframe since the receivers can check automatically for this. I am using 2 payload variables In_Payload and Out_Payload to do all the exchanges, next to that there are 2 buffers declared for receiving/sending payloads. Makes sure they are large enough.
     
    After receiving a package I use the following code to decipher the package into to In_Payload variable
    LoadRxBuffer((char *)&In_Payload,len); // translate rxBuffferdata into In_Payload
     
    Sending a package is simple, you first set your packagedata in the Out_Payload structure and then call
    send_Msg(xxxx)  where xxxx is a command you want to send around. 
     
    Have fun !
     
    CorB
     
     
     
     
     
    //PAYLOADS typedef volatile struct StatusStruct { enum TxACKMessageType { //!< Flags to ACK transfer REQUEST_NO_ACK = 0, REQUEST_ACK = 1 } TxACKMessageType; enum RxACKMessageType { //!< Flags to ACK transfer RECEIVED_NO_ACK = 0, RECEIVED_ACK = 1 } RxACKMessageType; char channel; char power; char RSSI; unsigned int msgNodeId; } StatusStruct; typedef struct PayloadFrame { char addr; // payloads need to start with char addr as the receiver can check this ! char msg; // messagetype 0x00 - 0xFF options char msgdata0; // var1 that belongs to the message char msgdata1; // var2 that belongs to the message StatusStruct Status; // USER DESIGNED PAYLOAD SECTION unsigned int data1; //unsigned int data2; char DataUnit; } PayloadFrame; PayloadFrame In_Payload; // receiving payload PayloadFrame Out_Payload; // sending payload #define maxPayload 40 // reserve space for the payloadsize in the buffers char txBuffer[maxPayload]; // sizeof(PayloadFrame) !! char rxBuffer[maxPayload]; // this routine sets default settings for payloads that will be send PayloadFrame * DefaultPayload () { Out_Payload.addr=0x01; // force adress Out_Payload.msg=DATA_PAYLOAD; Out_Payload.msgdata0=0; Out_Payload.msgdata1=0; Out_Payload.DataUnit='_'; Out_Payload.Status.RxACKMessageType=RECEIVED_NO_ACK ; Out_Payload.Status.TxACKMessageType= REQUEST_ACK; Out_Payload.Status.msgNodeId=NodeId; return &Out_Payload; } // transfer of a payload PayloadFrame * MakeTxPayload () { Out_Payload.Status.msgNodeId=NodeId; // always enforce ! return &Out_Payload; } // load a payload into the RxBuffer char LoadRxBuffer (char *buffer, char len) { int i = 0; for (i = len; i >= 0; i--) { buffer[i] = rxBuffer[i]; // Recreate Payload from received data } return 0; } // load a payload into the TxBuffer char PreparetxBuffer (char *payload, char len) { int i = 0; for (i = len; i >= 0; i--) { txBuffer[i+1] = payload[i]; // Create DataPacket from Payload } txBuffer[0]=len; // byte 0 in the pack should be the package length return 0; } // Send a payload void send_Msg(char message) { Out_Payload.addr=0x01;//force address Out_Payload.msg=message; PreparetxBuffer( (char *)(MakeTxPayload()), sizeof(PayloadFrame)); RFSendPacket(txBuffer, txBuffer[0]+1); // 1 byte larger than payloadframe due to the packagesize byte __delay_cycles(5000); //5ms waiting }
×
×
  • Create New...