openbeacon: send nickname in special packets
This commit is contained in:
parent
6e93dd4002
commit
f56d4f3ef0
|
@ -5,6 +5,7 @@
|
||||||
#include "sysdefs.h"
|
#include "sysdefs.h"
|
||||||
#include "filesystem/ff.h"
|
#include "filesystem/ff.h"
|
||||||
#include "basic/uuid.h"
|
#include "basic/uuid.h"
|
||||||
|
#include "basic/config.h"
|
||||||
|
|
||||||
#include "SECRETS"
|
#include "SECRETS"
|
||||||
|
|
||||||
|
@ -77,31 +78,56 @@ void openbeaconSetup(void)
|
||||||
#endif
|
#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 flags, uint8_t strength)
|
||||||
{
|
{
|
||||||
uint8_t buf[32];
|
uint8_t buf[16];
|
||||||
|
uint8_t proto = 0x17; //Tracking
|
||||||
|
|
||||||
volatile uint16_t i;
|
volatile uint16_t i;
|
||||||
i = getRandom()&0xfff;
|
i = (getRandom()&0xfff)+1;
|
||||||
while(i--);
|
while(i--);
|
||||||
|
|
||||||
|
static uint32_t n = 0;
|
||||||
|
if( --n == 0 ){
|
||||||
|
n = 123;
|
||||||
|
proto = 0x23; //Nick name
|
||||||
|
}
|
||||||
|
|
||||||
buf[0]=0x10; // Length: 16 bytes
|
buf[0]=0x10; // Length: 16 bytes
|
||||||
buf[1]=0x17; // Proto - fixed at 0x17?
|
buf[1]=proto;
|
||||||
buf[2]=flags;
|
if( proto == 0x17 ){
|
||||||
buf[3]=strength*85; // Send intensity
|
buf[2]=flags;
|
||||||
|
buf[3]=strength*85; // Send intensity
|
||||||
|
|
||||||
uint32touint8p(seq, buf+4);
|
uint32touint8p(seq, buf+4);
|
||||||
uint32touint8p(id, buf+8);
|
uint32touint8p(id, buf+8);
|
||||||
|
|
||||||
buf[12]=0xff; // salt (0xffff always?)
|
|
||||||
buf[13]=0xff;
|
|
||||||
|
|
||||||
|
buf[12]=0xff; // salt (0xffff always?)
|
||||||
|
buf[13]=0xff;
|
||||||
#if ENCRYPT_OPENBEACON
|
#if ENCRYPT_OPENBEACON
|
||||||
return nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
|
nrf_snd_pkt_crc_encr(16,buf,openbeaconkey);
|
||||||
#else
|
#else
|
||||||
return nrf_snd_pkt_crc_encr(16,buf,NULL);
|
nrf_snd_pkt_crc_encr(16,buf,NULL);
|
||||||
#endif
|
#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)
|
void openbeaconSend(void)
|
||||||
|
|
Loading…
Reference in New Issue