Merge branch 'master' of github.com:r0ket/r0ket

Conflicts:
	firmware/basic/uuid.c
This commit is contained in:
schneider 2012-04-02 14:13:48 +02:00
commit b58166a771
1 changed files with 36 additions and 16 deletions

View File

@ -5,27 +5,47 @@
#include "core/iap/iap.h"
uint32_t GetUUID32(void){
static uint32_t uuid = 0;
if( uuid == 0){
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
if (iap_return.ReturnCode == 0){
uint32_t block[4];
uint32_t k[4] = {0,0,0,0};
int i;
for(i=0; i<4; i++)
block[i] = iap_return.Result[i];
xxtea_encode_words(block, 4, k);
uuid = block[0];
}
uint32_t uuid32=0;
uint16_t uuid16=0;
uint32_t __GetUUID32(void){
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
if (iap_return.ReturnCode == 0){
uint32_t block[4];
uint32_t k[4] = {0,0,0,0};
int i;
for(i=0; i<4; i++)
block[i] = iap_return.Result[i];
xxtea_encode_words(block, 4, k);
return block[0];
}
return uuid;
return 0;
};
// What OpenBeacon used. Do we want this?
uint16_t GetUUID16(void){
uint16_t __GetUUID16(void){
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
return crc16 ((uint8_t *) iap_return.Result, sizeof (iap_return.Result));
};
uint32_t initUUID(void){
uuid32=__GetUUID32();
uuid16=__GetUUID16();
};
uint32_t GetUUID32(void){
if(uuid32==0){
initUUID();
};
return uuid32;
};
uint16_t GetUUID16(void){
if(uuid32==0){
initUUID();
};
return uuid16;
};