uuid: cache uuid to improve stability and performance

This commit is contained in:
schneider 2012-04-02 13:41:48 +02:00
parent a25e3e00fd
commit 10f4015583
1 changed files with 14 additions and 11 deletions

View File

@ -6,18 +6,21 @@
#include "core/iap/iap.h"
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];
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];
}
}
return 0;
return uuid;
};
// What OpenBeacon used. Do we want this?