Updating ACE from AWS pages

Has anyone put together a set of basic pages and code to view and update ACE parameters that they could share? My target device will be soldered onto a circuit board by the vendor, so the serial port is dedicated to the terminal, and not accessible for configuration chores. Once my code is installed and the dgdiscvr utility is no longer usable, I still will need to be able to make adjustments.

I am not a C or Digi Connect ME professional, but this code works for me. I use basic HTTP server API. I started my code of NAHTTPS example application.

The first file shows the current IP configuration (dynamic or static) in a web form, the second file updates modules configuration according to form data and restarts the module.

I configured NAHTTPS to get initial IP parameters from DHCP. It seems that this is the most easy way to get module up on network, but sometimes this might not be the most convenient way to do it. Therefore I plan to work on utility that would work similar to Discovery Utility.

mik

_ip.c =======================

#include

// includes for IP etc.
#include
#include
#include
#include
#include
#include

#define WEB_TO_C

void Send_function_8(unsigned long handle)
{

	// HTML header and JavaScript for form checking

HSSend (handle, "

");
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, "camera
");
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, "
");

	// variables defined
int result;
BOOLEAN static_enabl;
	aceConfigInfo sp; // type that contains all the IP information of module
	struct in_addr stat_ip, stat_mask, stat_gate; // will hold IP addresses
	char line[100];

	// get IP configuration
result = customizeAceGetConfig(&sp);

if (result == BP_SUCCESS)
{
		// is static IP enabled?
	static_enabl = sp.ace_interface_info[0].static_config.isEnabled;
	if (static_enabl==true) {
		// static IP active
		// getting addreses    		
			stat_ip.s_addr = sp.ace_interface_info[0].static_config.ip_address;
			stat_mask.s_addr = sp.ace_interface_info[0].static_config.subnet_mask;
			stat_gate.s_addr = sp.ace_interface_info[0].static_config.gateway;
	}

		// web form starts here
		// shows the current IP settings
		// and allows to change these
    HSSend (handle, "

");

}
else
{
	// This would never happen
	HSSend (handle, "Error! No IP config!

");
}

HSSend (handle, "

");
HSSend (handle, "
");
HSSend (handle, “”);

}

_ip.c EOF ==================

_ipset.c ===================

#include

// IP includes
#include
#include
#include

#define WEB_TO_C

void Send_function_9(unsigned long handle)
{
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, "camera
");
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, "Changing IP setting and restarting!
");
HSSend (handle, "
");
HSSend (handle, "
");
HSSend (handle, “”);

// get data from form
char ipmode[32];
	HSGetValue(handle, "ipmode", ipmode, 32);

	// static		
	if (strcmp(ipmode,"static")==0) {

		// get new static adresses, that were submitted
		char ip[32], mask[32], gate[32];
		HSGetValue(handle, "ip", ip, 32);
		HSGetValue(handle, "mask", mask, 32);
		HSGetValue(handle, "gate", gate, 32);
		
		// convert adresses to byte format
		unsigned long addr1, addr2, addr3;
		addr1 = fns_inet_addr(ip);
		addr2 = fns_inet_addr(mask);
		addr3 = fns_inet_addr(gate);

		// setting new static IP settings			
		customizeSaveIPParameters(addr1, addr2, addr3);
					
	}
	
	// dynamic
	if (strcmp(ipmode,"dynamic")==0) {

    int result;
		aceConfigInfo sp; // for IP data
		
		// get current config
    result = customizeAceGetConfig(&sp);
    if (result == BP_SUCCESS)
    {
    	// disable static config
			sp.ace_interface_info[0].static_config.isEnabled = false;
			sp.ace_interface_info[0].static_config.auto_assign = false;
			// write config back to NVRAM
			customizeAceSetConfig(&sp);
		}
		
	}
	
	// restart the module
	NAReset();

}

_ipset.c EOF

Message was edited by: mikelis