Changeset - 9e3e1986377f
[Not reviewed]
default
0 1 0
ethanzonca@CL-ENS241-08.cedarville.edu - 12 years ago 2013-01-18 17:02:35
ethanzonca@CL-ENS241-08.cedarville.edu
Fixed LED for AT mode OK identification
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
master/master/lib/slavesensors.c
Show inline comments
 
@@ -50,97 +50,97 @@ void slavesensors_setup()
 
	slaves[1][2] = TEMPERATURE;
 
	slaves[1][3] = PRESSURE;
 
	slaves[1][4] = AMBIENTLIGHT;
 
	
 
	// slave 2
 
	slaves[2][0] = BOARDTEMP;
 
	slaves[2][1] = GEIGER;
 
	
 
	// slave 3
 
	slaves[3][0] = BOARDTEMP;
 
	slaves[3][1] = CAMERA;
 
	
 
}
 

	
 
 
#define DEBUG_NETWORKSCAN
 
 
char* bufPtr = 0x00;
 
char debugBuf[64];
 
char slaveAddressLow[6][9];
 
char slaveAddressHigh[6][9];
 
uint8_t loggerIndex = 255;
 

	
 
void slavesensors_network_scan() {
 
	serial0_ioff();
 
	
 
	int atOK;
 
	
 
	#ifdef DEBUG_OUTPUT
 
	serial0_sendString("Beginning network scan...\r\n\r\n");
 
	#endif
 
	
 
	_delay_ms(500); // xbee warmup
 
	wdt_reset();
 
	
 
	led_on(LED_ACTIVITY);
 
	atOK = slavesensors_enterAT();
 

	
 
	char nameString[20] = "NONE";
 
	
 
	char slaveNames[6][16]; // Hold 16-char addresses of max 6 nodes, we only need them for debug so they are local 
 
	
 
	uint8_t nodeCount = 0;
 
	
 
	// wait for OK
 
	//todo
 
	if(atOK == 0)
 
	{
 
		led_on(LED_STATUS);
 
		led_on(LED_CYCLE);
 
		serial0_sendString("ATND");
 
		serial0_sendChar(0x0D);
 
		
 
		// wait for scan to complete
 
		uint16_t scanStart = time_millis(); 		
 
		while(!serial0_hasChar()) {
 
			if(time_millis() - scanStart > 5000) {
 
				led_errorcode(ERROR_XBEETIMEOUT);
 
				return;
 
			}
 
			wdt_reset();
 
		}
 
		// Scan data end when newline by itself ("")	
 
		int lineCount = 0;	
 
	
 
		while(1) {
 
			bufPtr = serial0_readLine();
 

	
 
			// If we're starting a new block but got a newline instead, we're done!
 
			if(lineCount == 0 && strcmp(bufPtr, "") == 0) {
 
				break;			
 
			}
 
			
 
			if(lineCount == 1) {
 
				strcpy(slaveAddressHigh[nodeCount], bufPtr);
 
			}
 
			else if(lineCount == 2) {
 
				strcpy(slaveAddressLow[nodeCount], bufPtr);
 
			}
 
			else if(lineCount == 3) {
 
				strcpy(nameString, bufPtr);
 
				strcpy(slaveNames[nodeCount], bufPtr);
 
			}
 
			
 
			// If we've finished one chunk (including the newline after it). Can't be else if because it controls increment.
 
			if(lineCount == 9) {
 
				// bufPtr should be null at this point, because we read in a newlinem after one chunk
 
				nodeCount++;
 
				lineCount = 0;
 
			}
 
			else {
 
				lineCount++;
 
			}
 

	
 
		}		
 

	
 
		slavesensors_exitAT();
 

	
0 comments (0 inline, 0 general)