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,6 +6,8 @@
#include "core/iap/iap.h" #include "core/iap/iap.h"
uint32_t GetUUID32(void){ uint32_t GetUUID32(void){
static uint32_t uuid = 0;
if( uuid == 0){
IAP_return_t iap_return; IAP_return_t iap_return;
iap_return = iapReadSerialNumber(); iap_return = iapReadSerialNumber();
if (iap_return.ReturnCode == 0){ if (iap_return.ReturnCode == 0){
@ -15,9 +17,10 @@ uint32_t GetUUID32(void){
for(i=0; i<4; i++) for(i=0; i<4; i++)
block[i] = iap_return.Result[i]; block[i] = iap_return.Result[i];
xxtea_encode_words(block, 4, k); xxtea_encode_words(block, 4, k);
return block[0]; uuid = block[0];
} }
return 0; }
return uuid;
}; };
// What OpenBeacon used. Do we want this? // What OpenBeacon used. Do we want this?