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