Beispiel #1
0
void setupGPS(){
    mrtDelay(5000);
    //Turning off all GPS NMEA strings apart on the uBlox module
    // Taken from Project Swift (rather than the old way of sending ascii text)
    // Had problems with memcpy (or the lack of) - solution here: http://www.utasker.com/forum/index.php?topic=1750.0;wap2
    static uint8_t setNMEAoff[] = {0xB5, 0x62, 0x06, 0x00, 0x14, 0x00, 0x01, 0x00, 0x00, 0x00, 0xD0, 0x08, 0x00, 0x00, 0x80, 0x25, 0x00, 0x00, 0x07, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xA9};
    sendUBX(setNMEAoff, 28);
    
    mrtDelay(1000);
    
    // Check and set the navigation mode (Airborne, 1G)
    static uint8_t setNav[] = {0xB5, 0x62, 0x06, 0x24, 0x24, 0x00, 0xFF, 0xFF, 0x06, 0x03, 0x00, 0x00, 0x00, 0x00, 0x10, 0x27, 0x00, 0x00, 0x05, 0x00, 0xFA, 0x00, 0xFA, 0x00, 0x64, 0x00, 0x2C, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x16, 0xDC};
    sendUBX(setNav, 44);
}
Beispiel #2
0
void GSM_On() {
    //Check if modem is on
    //uint8_t x = 0;

    //while((GSM_AT() == 0) && (x < 3)){

    LPC_GPIO_PORT->SET0 = 1 << GSM_PWR;
    mrtDelay(2000); //Wait for modem to boot
    LPC_GPIO_PORT->CLR0 = 1 << GSM_PWR;
    mrtDelay(2000);

    //  x++;
    //}
    //printf("GSM Booted");
}
Beispiel #3
0
/**
 * It processing incoming data by the radio or serial connection. This function
 * has to be continously called to keep the node running. This function also
 * adds a delay which is specified as 100ms per unit. Therefore 1000 = 100 sec
 * @param countdown delay added to this function
 */
void awaitData(int countdown) {

    uint8_t rx_len;

    //Clear buffer
    data_temp[0] = '\0';

    RFM69_setMode(RFM69_MODE_RX);

    while(countdown > 0) {

        // Check rx buffer
        if(RFM69_checkRx() == 1) {
            RFM69_recv(data_temp,  &rx_len);
            data_temp[rx_len - 1] = '\0';
            #ifdef DEBUG
                //rssi = RFM69_lastRssi();
                printf("rx: %s\r\n",data_temp);
                //printf("RSSI: %d\r\n, rssi");
            #endif
            processData(rx_len);
        }

        #ifdef SERIAL_IN
                // Check tx buffer
                checkTxBuffer();
        #endif

        countdown--;
        mrtDelay(100);
    }
}
Beispiel #4
0
/**
 * This function is called when a packet is received by the radio. It will
 * process the packet.
 */
inline void processData(uint32_t len) {
    uint8_t i, packet_len;
    
    for(i=0; i<len; i++) {
        if(data_temp[i] != ']')
            continue;
        
        //Print the string
        data_temp[i+1] = '\0';
        
        if(data_temp[0] <= '0')
            break;
        
        //Reduce the repeat value
        data_temp[0] = data_temp[0] - 1;
        //Now add , and end line and let string functions do the rest
        data_temp[i] = ',';
        data_temp[i+1] = '\0';
        
        if(strstr(data_temp, NODE_ID) != 0)
            break;
        
        strcat(data_temp, NODE_ID); // Add ID
        strcat(data_temp, "]"); // Add ending
        
        packet_len = strlen(data_temp);
        mrtDelay(random_output); // Random delay to try and avoid packet collision
        
        rx_packets++;
        
        transmitData(packet_len);
        break;
    }
}
Beispiel #5
0
void gps_get_data(){
    uint8_t i;
    mrtDelay(1000);
    if(UART0_available() > 0){
        for(i=0; i<serialBuffer_write; i++){
            gps_buf[i] = serialBuffer[i];
        }
    }
    serialBuffer_write = 0;
}
Beispiel #6
0
uint8_t RFM69_init()
{
    mrtDelay(12);
    
    //Configure SPI
    spiInit(LPC_SPI0,24,0);
    
    mrtDelay(100);
    
    // Set up device
    uint8_t i;
    for (i = 0; CONFIG[i][0] != 255; i++)
        spiWrite(CONFIG[i][0], CONFIG[i][1]);
    
    RFM69_setMode(_mode);
    
    // Clear TX/RX Buffer
    _bufLen = 0;
    
    return 1;
}
Beispiel #7
0
/**
 * This function is called when a packet is received by the radio. It will
 * process the packet.
 */
inline void processData(uint32_t len) {
    uint8_t i, packet_len;

    for(i=0; i<len; i++) {
        //finds the end of the packet
        if(data_temp[i] != ']')
            continue;

        //then terminates the string, ignore everything afterwards
        data_temp[i+1] = '\0';

        //Check validity of string
        // 1) is the first position in array a number
        //printf("%d\r\n", data_temp[0]);
        if((int)data_temp[0] <= 48 || (int)data_temp[0] > 57) {
            //printf("Error1\r\n");
            break;
        }

        // 2) is the second position in array a letter
        //      < 'a' or > 'z' then break
        //printf("%d\r\n", data_temp[1]);
        if((int)data_temp[1] < 97 || (int)data_temp[1] > 122) {
            //printf("Error2\r\n");
            break;
        }

#ifdef GATEWAY
        printf("rx: %s|%d\r\n",data_temp, RFM69_lastRssi());
#endif
        //Reduce the repeat value
        data_temp[0] = data_temp[0] - 1;
        //Now add , and end line and let string functions do the rest
        data_temp[i] = ',';
        data_temp[i+1] = '\0';

        if(strstr(data_temp, NODE_ID) != 0)
            break;

        strcat(data_temp, NODE_ID); // Add ID
        strcat(data_temp, "]"); // Add ending

        packet_len = strlen(data_temp);
        mrtDelay(random_output); // Random delay to try and avoid packet collision

        rx_packets++;

        transmitData(packet_len);
        break;
    }
}
Beispiel #8
0
/**
 * It processing incoming data by the radio or serial connection. This function
 * has to be continously called to keep the node running. This function also
 * adds a delay which is specified as 100ms per unit. Therefore 1000 = 100 sec
 * @param countdown delay added to this function
 */
void awaitData(int countdown) {

    uint8_t rx_len, flags1, old_flags1 = 0x90;

    //Clear buffer
    data_temp[0] = '\0';

    RFM69_setMode(RFM69_MODE_RX);

    rx_restarts = 0;

    while(countdown > 0) {

        flags1 = spiRead(RFM69_REG_27_IRQ_FLAGS1);
#ifdef DEBUG
        if (flags1 != old_flags1) {
            printf("f1: %02x\r\n", flags1);
            old_flags1 = flags1;
        }
#endif
        if (flags1 & RF_IRQFLAGS1_TIMEOUT) {
            // restart the Rx process
            spiWrite(RFM69_REG_3D_PACKET_CONFIG2, spiRead(RFM69_REG_3D_PACKET_CONFIG2) | RF_PACKET2_RXRESTART);
            rx_restarts++;
            // reset the RSSI threshold
            floor_rssi = RFM69_sampleRssi();
#ifdef DEBUG
            // and print threshold
            printf("Restart Rx %d\r\n", RFM69_lastRssiThreshold());
#endif
        }
        // Check rx buffer
        if(RFM69_checkRx() == 1) {
            RFM69_recv(data_temp,  &rx_len);
            data_temp[rx_len - 1] = '\0';
            processData(rx_len);
        }

        countdown--;
        mrtDelay(100);
    }
}
Beispiel #9
0
//GSM Code **********************************************
void GSM_get_data(uint16_t timeout) {
    uint8_t i;
    uint16_t x = 0;

    while (x < timeout) {
        if(UART1_available() > 0) {
            for(i=0; i<serial1Buffer_write; i++) {
                //gsm_buf[i] = serial1Buffer[i];
                uart0SendChar(serial1Buffer[i]);

                //if (gsm_buf[i] == '\r'){
                //    printf("%s", gsm_buf);
                //    return;
                //}
            }
            serial1Buffer_write = 0;
        }
        mrtDelay(1);
        x++;
    }
}
Beispiel #10
0
int
main(void)
{
	int i, j, k, l;
	unsigned button[3];
	unsigned steps[3];
	unsigned hz;

	/*-------------------------------------------------------------
	 * First things first:  Start the watchdog
	 */

	fido_setup(0x1000);

	/*-------------------------------------------------------------
	 * Setup GPIO
	 */

	LPC_SYSCON->SYSAHBCLKCTRL |=  (1 << 6);			// GPIO
	LPC_SYSCON->PRESETCTRL    &= ~(1 << 10);		// GPIO reset
	LPC_SYSCON->PRESETCTRL    |= (1 << 10);

	LPC_IOCON->PIO0_0 = 0
		| (1 << 3)					// Pull down
		| (1 << 5)					// Hysteresis
		;

	LPC_IOCON->PIO0_1 = 0
		| (2 << 3)					// Pull up
		| (1 << 5)					// Hysteresis
		;

	LPC_IOCON->PIO0_2 = 0
		| (2 << 3)					// Pull up
		| (1 << 5)					// Hysteresis
		;

	LPC_IOCON->PIO0_3 = 0
		| (2 << 3)					// Pull up
		| (1 << 5)					// Hysteresis
		;

	LPC_IOCON->PIO0_5 = 0
		| (2 << 3)					// Pull up
		| (1 << 5)					// Hysteresis
		;

	/*-------------------------------------------------------------
	 * Provide a chance to enter the boot-loader
	 */

	check_bootloader();

	/*-------------------------------------------------------------
	 * Enable UART for startup-debugging
	 */

	uart0Init(115200);
	uart_enable();

	/*-------------------------------------------------------------
	 * Start timer
	 */

	mrtInit(__SYSTEM_CLOCK/1000);

	/*-------------------------------------------------------------
	 * Enable reset pin
	 */

	LPC_SWM->PINENABLE0 = ~(1 << 6);		// PIO0_5 RESET_EN

	/*-------------------------------------------------------------
	 * Hello World
	 */

	welcome();

	/*-------------------------------------------------------------
	 * Detect pin-configuration by counting edges on the two possible
	 * possible clock inputs.
 	 *
	 * If neither is active the watch-dog will trigger.
	 */

	do {
		/* Measure input frequency on PIO0_1 and PIO0_2 */
		for (i = 1; i < 3; i++) {
			sct_setup(i);
			k = LPC_SCT->COUNT_U;
			mrtDelay(100);
			l = LPC_SCT->COUNT_U;
			hz = 10 * (l-k);
			printf("Rate PIO0_%d = %u\r\n", i, hz);
			if (hz > 1000)
				break;
		}
	} while (hz < 1000);

	/*-------------------------------------------------------------
 	 * Configure counter
	 */

	mrtDelay(100);
	printf("Using PIO0_%d\r\n", i);
	mrtDelay(100);
	uart_disable();

	button[0] = 1<<(3-i);	steps[0] = 1;
	button[1] = 1<<3;	steps[1] = 60;
	button[2] = 1<<5;	steps[2] = 3600;
	if (i == 1) {

		LPC_SWM->PINENABLE0 &= ~(1 << 7);       // Enable CLKIN

		LPC_SYSCON->MAINCLKSEL = 0x1;		// PLL input
		LPC_SYSCON->MAINCLKUEN = 0x0;
		LPC_SYSCON->MAINCLKUEN = 0x1;

		LPC_SYSCON->SYSPLLCLKSEL = 0x3;		// CLKIN
		LPC_SYSCON->SYSPLLCLKUEN = 0x0;
		LPC_SYSCON->SYSPLLCLKUEN = 0x1;

		LPC_SYSCON->SYSAHBCLKDIV = 1;

		sct_setup(0xff);
		mrtInit(FREQ/1000);

		/* Calibrated to look like 0x00 at 115200 bps */
		pulse_lo = 29;
		pulse_hi = 10;
	} else {
		sct_setup(2);
	}

	sct_output(4);

	/*-------------------------------------------------------------
	 * Until the clock is set, have it run 11 times too fast
	 */
	while (1) {
		fido_pat();
		if (!(LPC_GPIO_PORT->PIN0 & button[0]))
			break;
		if (!(LPC_GPIO_PORT->PIN0 & button[1]))
			break;
		if (!(LPC_GPIO_PORT->PIN0 & button[2]))
			break;
		mrtDelay(100);
		run_pulse();
	}

	LPC_SWM->PINENABLE0 |= (1 << 6);		// Disable RESET

	j = 0;
	while(1) {
		if (j == 0 && LPC_SCT->COUNT_U < 10000) {
			fido_pat();
			j = 1;
		}
		if (j == 1 && LPC_SCT->COUNT_U > 10000) {
			j = 0;
		}

		for (i = 0; i < 3; i++) {
			if (LPC_GPIO_PORT->PIN0 & button[i])
				continue;

			fido_pat();

			for(k = 0; k < steps[i]; k++)
				run_pulse();

			if (i > 0) {
				/*
				 * Min/Hour button release
				 * If you hold them for 10+ seconds
				 * The watch-dog bites
				 */
				for(k = 0; k < 1000; k++) {
					if (LPC_GPIO_PORT->PIN0 & button[i])
						continue;
					k = 0;
				}
				continue;
			}

			/* Check if the Sec button is held for >1s */

			mrt_counter = 0;
			for(k = 0; k < 1000; k++) {
				if (LPC_GPIO_PORT->PIN0 & button[i])
					break;
				if (mrt_counter > 1000)
					break;
				k = 0;
			}
			if (k == 1000)
				continue;

			/* Stop counter */
			sct_stop();

			/*
			 * Restart counter on button release
			 * or sync input
			 */
			for(k = 0; k < 1000; k++) {
				if (LPC_GPIO_PORT->PIN0 & button[i])
					break;
				l = LPC_GPIO_PORT->PIN0 & (1<<0);
				if (l)
					k = 0;
			}

			l = (1 << 0) | button[i];
			while (!(LPC_GPIO_PORT->PIN0 & l))
				continue;

			/*
			 * Calibrated for falling edge = PPI rising edge
			 * PPSO comes 164ns after PPS1
			 */
			LPC_SCT->COUNT_U = FREQ - 366;
			LPC_SCT->CTRL_L &= ~(1 << 2);		// Start

			for(k = 0; k < 1000; k++) {
				if (LPC_GPIO_PORT->PIN0 & button[i])
					continue;
				k = 0;
			}
		}
	}
}
Beispiel #11
0
int main(void)
{
    // Initialise the GPIO block
    gpioInit();
    
	#ifdef GPS
		// Initialise the UART0 block for printf output
		uart0Init(9600);
	#else
		// Initialise the UART0 block for printf output
		uart0Init(115200);
	#endif
    
    // Configure the multi-rate timer for 1ms ticks
    mrtInit(__SYSTEM_CLOCK/1000);
    
    // Configure the switch matrix (setup pins for UART0 and SPI)
    configurePins();
    
    //Seed random number generator, we can use our 'unique' ID
    random_output = NODE_ID[0] + NODE_ID[1] + NODE_ID[2];
    //printf("random: %d\r\n", random_output);
    
    RFM69_init();
    
    #ifdef GPS
		int navmode = 9;
		setupGPS();
    #endif

	#ifdef DEBUG
		printf("Node initialized, version %s\r\n",GIT_VER);
	#endif
    
    while(1) {
        
        #ifdef GPS
			mrtDelay(5000);
			navmode = gps_check_nav();
            if (navmode != 6){
                setupGPS();
            }
        
			mrtDelay(500);
			gps_get_position();
			mrtDelay(500);
			gps_check_lock();
			mrtDelay(500);

			//printf("Data: %d,%d,%d,%d,%d,%d\r\n", lat, lon, alt, navmode, lock, sats);
			//printf("Errors: %d,%d\r\n", GPSerror, serialBuffer_write);
        #endif
        
        incrementPacketCount();
        
        //Clear buffer
        data_temp[0] = '\0';
        uint8_t n;
        
        //Create the packet
        int int_temp = RFM69_readTemp(); // Read transmitter temperature
        rx_rssi = RFM69_lastRssi();
        floor_rssi = RFM69_sampleRssi();
        
        #ifdef GPS
			n = sprintf(data_temp, "%d%cL%d,%d,%dT%dR%d[%s]", NUM_REPEATS, data_count, lat, lon, alt, int_temp, rx_rssi, NODE_ID);
		#else
			if(data_count == 97) {
				n = sprintf(data_temp, "%d%cL%s[%s]", NUM_REPEATS, data_count, LOCATION_STRING, NODE_ID);
			} else {
				n = sprintf(data_temp, "%d%cT%dR%d,%dC%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, floor_rssi, rx_packets, NODE_ID);
			}
        #endif
        
        transmitData(n);
        
        awaitData(TX_GAP);
    }
    
}
Beispiel #12
0
int main(void)
{
  /* Initialise the GPIO block */
  gpioInit();

  /* Initialise the UART0 block for printf output */
  //uart0Init(115200);
  uart0Init(9600);
  /* Configure the multi-rate timer for 1ms ticks */
  mrtInit(__SYSTEM_CLOCK/1000);

  /* Configure the switch matrix (setup pins for UART0 and GPIO) */
  //configurePins();
  spiInit(LPC_SPI0, 6, 0);
  SwitchMatrix_Init(); //uart & spi
  LPC_GPIO_PORT->DIR0 |= (1 << CSN);
  LPC_GPIO_PORT->DIR0 |= (1 << CE);
  uint8_t temp = 0;

  nrf24_init();




  /* Set the LED pin to output (1 = output, 0 = input) */
  #if !defined(USE_SWD)
    LPC_GPIO_PORT->DIR0 |= (1 << LED_LOCATION);
  #endif

    //printf("write");
    mrtDelay(500);

    nrf24_config(2,16);

	#if TX_NODE
    	nrf24_tx_address(tx_address);
    	nrf24_rx_address(rx_address);
	#else
    	nrf24_tx_address(rx_address); //backwards looking but is fine
    	nrf24_rx_address(tx_address);
	#endif

    uint8_t i = 0;
  while(1)
  {

      /* Turn LED On by setting the GPIO pin high */
      LPC_GPIO_PORT->SET0 = 1 << LED_LOCATION;
      mrtDelay(500);

      /* Turn LED Off by setting the GPIO pin low */
      LPC_GPIO_PORT->CLR0 = 1 << LED_LOCATION;
      mrtDelay(500);

	  /*
      printf("Send\r\n");
      for(i=0; i<16; i++){
    	  printf("%d: %d\n\r", i, tx_data_array[i]);
      }
	   */
      nrf24_send(tx_data_array);
      while(nrf24_isSending());
      nrf24_powerUpRx();
      //done transmitting, set back to rx mode

      for(i=0; i<16; i++){
    	  tx_data_array[i]++;
      }

/*
      if(nrf24_dataReady()){
    	  printf("\n\rGot data\n\r");

          nrf24_getData(rx_data_array);
          for(i=0; i<16; i++){
          printf("%d: %d\n\r", i, rx_data_array[i]);
          }
      }
*/
  }
}
Beispiel #13
0
int main(void)
{
#ifdef ZOMBIE_MODE
    LPC_SYSCON->BODCTRL = 0x11;  //Should be set to Level 1 (Assertion 2.3V, De-assertion 2.4V) reset
#endif

#if defined(GATEWAY) || defined(DEBUG)
    // Initialise the UART0 block for printf output
    uart0Init(115200);
#endif

    // Configure the multi-rate timer for 1ms ticks
    mrtInit(__SYSTEM_CLOCK/1000);

    /* Enable AHB clock to the Switch Matrix , UART0 , GPIO , IOCON, MRT , ACMP */
    LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 7) | (1 << 14) /*| (1 << 6)*//* | (1 << 18)*/
                                 | (1 << 10) | (1 << 19);

    // Configure the switch matrix (setup pins for UART0 and SPI)
    configurePins();



#ifdef DEBUG
    mrtDelay(100);
    printf("Node Booted\r\n");
    mrtDelay(100);
#endif

    RFM69_init();

#ifdef ZOMBIE_MODE
    //This is to allow the setup to recover from the initial boot and
    // avoid a loop
    RFM69_setMode(RFM69_MODE_SLEEP);
    init_sleep();
    sleepMicro(20000);
#endif

#ifdef DEBUG
    printf("Node initialized, version %s\r\n",GIT_VER);
#endif

    //Seed random number generator, we can use our 'unique' ID
    random_output = NODE_ID[0] + NODE_ID[1] + NODE_ID[2];


    while(1) {

        /*
        #ifdef ZOMBIE_MODE
        adc_result = acmpVccEstimate();
        // Before transmitting if the input V is too low we could sleep again
        if (adc_result < 3100 || adc_result > 10000) {
            sleepRadio();
        }
        #endif
        */



        incrementPacketCount();

        //Clear buffer
        data_temp[0] = '\0';
        uint8_t n;

        //Create the packet
        int int_temp;
#ifdef ZOMBIE_MODE
        //This is to allow the setup to recover from the initial boot and
        // avoid a loop
        RFM69_setMode(RFM69_MODE_SLEEP);
        init_sleep();
        sleepMicro(10000);
#endif

        int_temp = RFM69_readTemp(); // Read transmitter temperature


        rx_rssi = RFM69_lastRssi();
        // read the rssi threshold before re-sampling noise floor which will change it
        rssi_threshold = RFM69_lastRssiThreshold();
        floor_rssi = RFM69_sampleRssi();

#ifdef ZOMBIE_MODE
        //This is to allow the setup to recover from the initial boot and
        // avoid a loop
        RFM69_setMode(RFM69_MODE_SLEEP);
        init_sleep();
        sleepMicro(10000);
#endif

#ifdef ZOMBIE_MODE
        adc_result = acmpVccEstimate();
        //sleepMicro(20000);
#endif

#ifdef DEBUG
        printf("ADC: %d\r\n", adc_result);

#endif
#ifdef ZOMBIE_MODE
        //This is to allow the setup to recover from the initial boot and
        // avoid a loop
        RFM69_setMode(RFM69_MODE_SLEEP);
        init_sleep();
        sleepMicro(10000);
#endif

        if(data_count == 97) {
            n = sprintf(data_temp, "%d%cL%s[%s]", NUM_REPEATS, data_count, LOCATION_STRING, NODE_ID);
        }
        else {

#ifdef DEBUG
            //n = sprintf(data_temp, "%d%cT%dR%d,%dC%dX%d,%dV%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, floor_rssi, rx_packets, rx_restarts, rssi_threshold, adc_result, NODE_ID);
            n = sprintf(data_temp, "%d%cT%dV%d[%s]", NUM_REPEATS, data_count, int_temp, adc_result, NODE_ID);
#elif defined(ZOMBIE_MODE)
            n = sprintf(data_temp, "%d%cT%dV%d[%s]", NUM_REPEATS, data_count, int_temp, adc_result, NODE_ID);
#else
            n = sprintf(data_temp, "%d%cT%dR%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, NODE_ID);
#endif
        }

        transmitData(n);

#ifdef ZOMBIE_MODE
        sleepRadio();
#else
        awaitData(TX_GAP);
#endif

    }

}
Beispiel #14
0
int main(void)
{

#if defined(GATEWAY) || defined(DEBUG) || defined(GPS)
    // Initialise the UART0 block for printf output
    uart0Init(115200);
#endif

    // Configure the multi-rate timer for 1ms ticks
    mrtInit(__SYSTEM_CLOCK/1000);

    /* Enable AHB clock to the Switch Matrix , UART0 , GPIO , IOCON, MRT , ACMP */
    LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 7) | (1 << 14) /*| (1 << 6)*//* | (1 << 18)*/
                                 | (1 << 10) | (1 << 19);

    // Configure the switch matrix (setup pins for UART0 and SPI)
    configurePins();

    LPC_GPIO_PORT->DIR0 |= (1 << GSM_PWR);

    RFM69_init();

#if defined(GATEWAY) || defined(DEBUG) || defined(GPS)
    mrtDelay(100);
    printf("Node Booted\r\n");
    mrtDelay(100);
#endif

    uart1Init(115200);

    GSM_On();

    //GSM_AT();


#if defined(GATEWAY) || defined(DEBUG) || defined(GPS)
    printf("Node initialized, version %s\r\n",GIT_VER);
#endif

    //Seed random number generator, we can use our 'unique' ID
    random_output = NODE_ID[0] + NODE_ID[1] + NODE_ID[2];

    mrtDelay(5000);

    GSM_AT();
    mrtDelay(5000);

    GSM_upload();

    while(1) {



        GSM_AT();

        incrementPacketCount();

        //Clear buffer
        data_temp[0] = '\0';
        uint8_t n;

        //Create the packet
        int int_temp;

        int_temp = RFM69_readTemp(); // Read transmitter temperature
        rx_rssi = RFM69_lastRssi();
        // read the rssi threshold before re-sampling noise floor which will change it
        rssi_threshold = RFM69_lastRssiThreshold();
        floor_rssi = RFM69_sampleRssi();

        if(data_count == 97) {
            n = sprintf(data_temp, "%d%cL%s[%s]", NUM_REPEATS, data_count, LOCATION_STRING, NODE_ID);
        }
        else {

#ifdef DEBUG
            n = sprintf(data_temp, "%d%cT%dR%d,%dC%dX%d,%dV%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, floor_rssi, rx_packets, rx_restarts, rssi_threshold, adc_result, NODE_ID);
#else
            n = sprintf(data_temp, "%d%cT%dR%dX%d[%s]", NUM_REPEATS, data_count, int_temp, rx_rssi, rx_packets, NODE_ID);
#endif
        }

        transmitData(n);
        GSM_upload();

        awaitData(TX_GAP);

    }

}