Skip to content

Commit

Permalink
#484 radiolink setup function to send p2p broadcast packets to nrf
Browse files Browse the repository at this point in the history
  • Loading branch information
knmcguire committed Oct 11, 2019
1 parent 947a702 commit 2996447
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/hal/interface/radiolink.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,21 @@
#include <stdbool.h>
#include "syslink.h"

#define P2P_MAX_DATA_SIZE 61

typedef struct _P2PPacket
{
uint8_t size; //< Size of data
uint8_t rssi; //< Received Signal Strength Intensity
union {
struct {
uint8_t port; //< Header selecting channel and port
uint8_t data[P2P_MAX_DATA_SIZE]; //< Data
};
uint8_t raw[P2P_MAX_DATA_SIZE+1]; //< The full packet "raw"
};
} __attribute__((packed)) P2PPacket;

void radiolinkInit(void);
bool radiolinkTest(void);
void radiolinkSetChannel(uint8_t channel);
Expand All @@ -39,6 +54,7 @@ void radiolinkSetAddress(uint64_t address);
void radiolinkSetPowerDbm(int8_t powerDbm);
void radiolinkSyslinkDispatch(SyslinkPacket *slp);
struct crtpLinkOperations * radiolinkGetLink();
bool radiolinkSendP2PPacketBroadcast(P2PPacket *p2pp);


#endif //__RADIO_H__
16 changes: 16 additions & 0 deletions src/hal/src/radiolink.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,22 @@ static int radiolinkSendCRTPPacket(CRTPPacket *p)
return false;
}

bool radiolinkSendP2PPacketBroadcast(P2PPacket *p)
{
static SyslinkPacket slp;

ASSERT(p->size <= CRTP_MAX_DATA_SIZE);

slp.type = SYSLINK_RADIO_P2P_BROADCAST;
slp.length = p->size + 1;
memcpy(slp.data, p->raw, p->size + 1);

syslinkSendPacket(&slp);

return true;
}


struct crtpLinkOperations * radiolinkGetLink()
{
return &radiolinkOp;
Expand Down

0 comments on commit 2996447

Please sign in to comment.