43 lines
		
	
	
		
			948 B
		
	
	
	
		
			C
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			948 B
		
	
	
	
		
			C
		
	
	
	
	
	
#include "mesh_ota.h"
 | 
						|
 | 
						|
 | 
						|
 | 
						|
/*
 | 
						|
 * 999.999.999
 | 
						|
 * Return true if remote version is newer (higher) than local version
 | 
						|
*/
 | 
						|
bool bNewerVersion(const char* pu8Local, const  char* pu8Remote){
 | 
						|
    
 | 
						|
    char u8LocalTmp[12];
 | 
						|
    char u8RemoteTmp[12];
 | 
						|
    
 | 
						|
    char* pu8saveptrLocal;
 | 
						|
    char* pu8saveptrRemote;
 | 
						|
    
 | 
						|
    strcpy(u8LocalTmp, pu8Local);
 | 
						|
    strcpy(u8RemoteTmp, pu8Remote);
 | 
						|
    
 | 
						|
    char* pu8TokenLocal = strtok_r(u8LocalTmp, ".", &pu8saveptrLocal);
 | 
						|
    char* pu8TokenRemote = strtok_r(u8RemoteTmp, ".", &pu8saveptrRemote) ;
 | 
						|
 | 
						|
    
 | 
						|
    bool bReturn = false;
 | 
						|
    
 | 
						|
    uint8_t u8Index = 0;
 | 
						|
    
 | 
						|
    while( (u8Index <= 2) && (bReturn == false)){
 | 
						|
    
 | 
						|
        u8Index++;
 | 
						|
        
 | 
						|
        if(atoi(pu8TokenLocal) < atoi(pu8TokenRemote))
 | 
						|
        {
 | 
						|
            bReturn = true;
 | 
						|
        }
 | 
						|
        
 | 
						|
        pu8TokenLocal = strtok_r(NULL, ".", &pu8saveptrLocal);
 | 
						|
        pu8TokenRemote = strtok_r(NULL, ".", &pu8saveptrRemote) ;
 | 
						|
    }
 | 
						|
    
 | 
						|
    return bReturn;
 | 
						|
}
 |