openbeacon: send nickname in special packets

This commit is contained in:
schneider 2011-12-22 13:39:14 +01:00
parent 6e93dd4002
commit f56d4f3ef0
1 changed files with 39 additions and 13 deletions

View File

@ -5,6 +5,7 @@
#include "sysdefs.h"
#include "filesystem/ff.h"
#include "basic/uuid.h"
#include "basic/config.h"
#include "SECRETS"
@ -77,17 +78,25 @@ void openbeaconSetup(void)
#endif
}
static uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq,
static void openbeaconSendPacket(uint32_t id, uint32_t seq,
uint8_t flags, uint8_t strength)
{
uint8_t buf[32];
uint8_t buf[16];
uint8_t proto = 0x17; //Tracking
volatile uint16_t i;
i = getRandom()&0xfff;
i = (getRandom()&0xfff)+1;
while(i--);
static uint32_t n = 0;
if( --n == 0 ){
n = 123;
proto = 0x23; //Nick name
}
buf[0]=0x10; // Length: 16 bytes
buf[1]=0x17; // Proto - fixed at 0x17?
buf[1]=proto;
if( proto == 0x17 ){
buf[2]=flags;
buf[3]=strength*85; // Send intensity
@ -96,12 +105,29 @@ static uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq,
buf[12]=0xff; // salt (0xffff always?)
buf[13]=0xff;
#if ENCRYPT_OPENBEACON
return nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
#else
return nrf_snd_pkt_crc_encr(16,buf,NULL);
nrf_snd_pkt_crc_encr(16,buf,NULL);
#endif
}else{
uint32touint8p(id, buf+2);
memcpy(buf+6, GLOBAL(nickname), 8);
#if ENCRYPT_OPENBEACON
nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
#else
nrf_snd_pkt_crc_encr(16,buf,NULL);
#endif
if( strlen(GLOBAL(nickname)) < 9 )
return;
buf[1]=0x24;
memcpy(buf+6, GLOBAL(nickname)+8, 8);
#if ENCRYPT_OPENBEACON
nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
#else
nrf_snd_pkt_crc_encr(16,buf,NULL);
#endif
}
}
void openbeaconSend(void)