main/ims_tcp.c
/*
 * initialise variables from flash. Store default variables if not present.
 */
initialise variables from flash. Store default variables if not present.
initialise variables from flash . Store default variables if not present .
void init_flash_variables(globalptrs_t *arg){
	if( !get_flash_uint32( &globalIpInfo.localIpInfo.ip.addr, "localip") ){
		inet_pton(AF_INET, DEFAULT_LOCALIP, &globalIpInfo.localIpInfo.ip);
		set_flash_uint32(globalIpInfo.localIpInfo.ip.addr, "localip");
	}
	if( !get_flash_uint32( &globalIpInfo.localIpInfo.netmask.addr, "netmask") ){
		inet_pton(AF_INET, DEFAULT_NETMASK, &globalIpInfo.localIpInfo.netmask);
		set_flash_uint32(globalIpInfo.localIpInfo.netmask.addr, "netmask");
	}
	if( !get_flash_uint32( &globalIpInfo.localIpInfo.gw.addr, "gateway") ){
		inet_pton(AF_INET, DEFAULT_GATEWAY, &globalIpInfo.localIpInfo.gw);
		set_flash_uint32(globalIpInfo.localIpInfo.gw.addr, "gateway");
	}
	if( !get_flash_uint32( &globalIpInfo.remotes[0].ip.addr, "remoteip0") ){
		inet_pton(AF_INET, DEFAULT_REMOTEIP, &globalIpInfo.remotes[0].ip);
		set_flash_uint32(globalIpInfo.remotes[0].ip.addr, "remoteip0");
	}
	if( !get_flash_uint32( &globalIpInfo.remotes[0].localPort, "localport0") ){
		globalIpInfo.remotes[0].localPort = DEFAULT_LOCALPORT;
		set_flash_uint32( DEFAULT_LOCALPORT, "localport0");
	}
	if( !get_flash_uint32( &globalIpInfo.remotes[0].remotePort, "remoteport0") ){
		globalIpInfo.remotes[0].remotePort = DEFAULT_REMOTEPORT;
		set_flash_uint32( DEFAULT_REMOTEPORT, "remoteport0");
	}
	if( !get_flash_uint8( &nodeid, "nodeid") ){
		nodeid = (uint8_t) DEFAULT_NODEID;
		set_flash_uint8( DEFAULT_NODEID, "nodeid");
	}
	if( !get_flash_uint8( &threshold, "threshold") ){
		threshold = (uint8_t) DEFAULT_THRESHOLD;
		set_flash_uint8( DEFAULT_THRESHOLD, "threshold");
	}
}
void init_flash_variables ( globalptrs_t * arg ) { if ( ! get_flash_uint32 ( & globalIpInfo . localIpInfo . ip . addr , " " ) ) { inet_pton ( AF_INET , DEFAULT_LOCALIP , & globalIpInfo . localIpInfo . ip ) ; set_flash_uint32 ( globalIpInfo . localIpInfo . ip . addr , " " ) ; } if ( ! get_flash_uint32 ( & globalIpInfo . localIpInfo . netmask . addr , " " ) ) { inet_pton ( AF_INET , DEFAULT_NETMASK , & globalIpInfo . localIpInfo . netmask ) ; set_flash_uint32 ( globalIpInfo . localIpInfo . netmask . addr , " " ) ; } if ( ! get_flash_uint32 ( & globalIpInfo . localIpInfo . gw . addr , " " ) ) { inet_pton ( AF_INET , DEFAULT_GATEWAY , & globalIpInfo . localIpInfo . gw ) ; set_flash_uint32 ( globalIpInfo . localIpInfo . gw . addr , " " ) ; } if ( ! get_flash_uint32 ( & globalIpInfo . remotes [ 0 ] . ip . addr , " " ) ) { inet_pton ( AF_INET , DEFAULT_REMOTEIP , & globalIpInfo . remotes [ 0 ] . ip ) ; set_flash_uint32 ( globalIpInfo . remotes [ 0 ] . ip . addr , " " ) ; } if ( ! get_flash_uint32 ( & globalIpInfo . remotes [ 0 ] . localPort , " " ) ) { globalIpInfo . remotes [ 0 ] . localPort = DEFAULT_LOCALPORT ; set_flash_uint32 ( DEFAULT_LOCALPORT , " " ) ; } if ( ! get_flash_uint32 ( & globalIpInfo . remotes [ 0 ] . remotePort , " " ) ) { globalIpInfo . remotes [ 0 ] . remotePort = DEFAULT_REMOTEPORT ; set_flash_uint32 ( DEFAULT_REMOTEPORT , " " ) ; } if ( ! get_flash_uint8 ( & nodeid , " " ) ) { nodeid = ( uint8_t ) DEFAULT_NODEID ; set_flash_uint8 ( DEFAULT_NODEID , " " ) ; } if ( ! get_flash_uint8 ( & threshold , " " ) ) { threshold = ( uint8_t ) DEFAULT_THRESHOLD ; set_flash_uint8 ( DEFAULT_THRESHOLD , " " ) ; } }
initialise variables from flash.
initialise variables from flash .
//set local ip info //set first remote port with default values