openbeacon: fixes
This commit is contained in:
parent
c14b529742
commit
30900a87ba
|
@ -7,7 +7,7 @@ OBJS =
|
||||||
OBJS += nrf24l01p.o
|
OBJS += nrf24l01p.o
|
||||||
OBJS += rftransfer.o
|
OBJS += rftransfer.o
|
||||||
OBJS += filetransfer.o
|
OBJS += filetransfer.o
|
||||||
OBJS += openbeacon.h
|
OBJS += openbeacon.o
|
||||||
|
|
||||||
LIBNAME=funk
|
LIBNAME=funk
|
||||||
|
|
||||||
|
|
|
@ -1,18 +1,29 @@
|
||||||
#include "openbeacon.h"
|
#include <stdint.h>
|
||||||
#include "nrf24l01p.h"
|
#include "funk/openbeacon.h"
|
||||||
|
#include "funk/nrf24l01p.h"
|
||||||
#include "basic/byteorder.h"
|
#include "basic/byteorder.h"
|
||||||
|
#include "sysdefs.h"
|
||||||
|
|
||||||
const uint32_t key = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
|
const uint32_t key[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
|
||||||
const uint8_t enctoggle = 0;
|
const uint8_t enctoggle = 0;
|
||||||
uint32_t mid = 0;
|
uint32_t oid = 0;
|
||||||
uint32_t mctr = 0;
|
uint32_t ctr = 0;
|
||||||
uint8_t strength = 0;
|
uint8_t strength = 0;
|
||||||
|
|
||||||
void openbeaconSetup(uint32_t id, uint32_t ctr)
|
void openbeaconSave()
|
||||||
{
|
{
|
||||||
mid = id;
|
}
|
||||||
mctr = ctr;
|
|
||||||
|
void openbeaconRead()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void openbeaconSetup(uint32_t id)
|
||||||
|
{
|
||||||
|
oid = id;
|
||||||
strength = 0;
|
strength = 0;
|
||||||
|
openbeaconRead();
|
||||||
}
|
}
|
||||||
|
|
||||||
void openbeaconSendPacket(uint32_t id, uint32_t ctr, uint8_t flags, uint8_t strength)
|
void openbeaconSendPacket(uint32_t id, uint32_t ctr, uint8_t flags, uint8_t strength)
|
||||||
|
@ -25,22 +36,24 @@ void openbeaconSendPacket(uint32_t id, uint32_t ctr, uint8_t flags, uint8_t stre
|
||||||
buf[2]=flags;
|
buf[2]=flags;
|
||||||
buf[3]=strength*85; // Send intensity
|
buf[3]=strength*85; // Send intensity
|
||||||
|
|
||||||
uint322uint8p(ctr, buf+4);
|
uint32touint8p(ctr, buf+4);
|
||||||
uint322uint8p(id, buf+8);
|
uint32touint8p(id, buf+8);
|
||||||
|
|
||||||
buf[12]=0xff; // salt (0xffff always?)
|
buf[12]=0xff; // salt (0xffff always?)
|
||||||
buf[13]=0xff;
|
buf[13]=0xff;
|
||||||
|
|
||||||
status=nrf_snd_pkt_crc_encr(16,buf,enctoggle?testkey:NULL);
|
status=nrf_snd_pkt_crc_encr(16,buf,enctoggle?key:NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void openbeaconSend(void)
|
void openbeaconSend(void)
|
||||||
{
|
{
|
||||||
//uint8_t tmp = nrfgetstrength();
|
//uint8_t tmp = nrfgetstrength();
|
||||||
//nrfsetstrength(strength);
|
//nrfsetstrength(strength);
|
||||||
openbeaconSendPacket(mid, ctr++, 0xFF, strength++);
|
openbeaconSendPacket(oid, ctr++, 0xFF, strength++);
|
||||||
if( strength == 4 )
|
if( strength == 4 )
|
||||||
strength = 0;
|
strength = 0;
|
||||||
|
if( ctr % OPENBEACON_SAVECOUNTER == 0 )
|
||||||
|
openbeaconSave();
|
||||||
//maybe this produces timing problems?
|
//maybe this produces timing problems?
|
||||||
//nrfsetstrength(tmp);
|
//nrfsetstrength(tmp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,16 @@
|
||||||
#ifndef _OPENBEACON_H_
|
#ifndef _OPENBEACON_H_
|
||||||
#define _OPENBEACON_H_
|
#define _OPENBEACON_H_
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "funk/openbeacon.h"
|
||||||
|
#include "funk/nrf24l01p.h"
|
||||||
|
#include "basic/byteorder.h"
|
||||||
|
|
||||||
void openbeaconSetup(uint32_t id, uint32_t ctr);
|
#define OPENBEACON_SAVECOUNTER (1024*8)
|
||||||
|
void openbeaconSave();
|
||||||
|
void openbeaconRead();
|
||||||
|
void openbeaconSetup(uint32_t id);
|
||||||
void openbeaconSendPacket(uint32_t id, uint32_t ctr,
|
void openbeaconSendPacket(uint32_t id, uint32_t ctr,
|
||||||
uint8_t flags, uint8_t strength);
|
uint8_t flags, uint8_t strength);
|
||||||
void openbeaconSend(void);
|
void openbeaconSend(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue