This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

simple communication with RF-2500

Other Parts Discussed in Thread: SIMPLICITI

hi, i would want to programm the end device to communicate with the access point and then display it in the GUI.

lets say i would like to programm the end device with a number 88. when i plug in the end device the number 88 would then be display it in the GUI on the end device node.

would appreciate if anybody here would enlighten me about this? please help. thanks

Derek

  • no help available here? please guide me!!!

  • Devora said:

    hi, i would want to programm the end device to communicate with the access point and then display it in the GUI.

    I assume the GUI you are referencing is a part of the Sensor Monitor demo.  Unfortunately the source is not provided for that GUI, but a similar one, with source, is provided with the MSP430 Solar Energy Harvesting Development Tool.
    This would need to be modified to display additional information that the eZ430-RF2500 acting as the Access Point would send over the Virtual COM port.  The eZ430-RF2500 Access Point needs to be modified to send this additional information to the PC running the GUI.

     

    Devora said:

    lets say i would like to programm the end device with a number 88. when i plug in the end device the number 88 would then be display it in the GUI on the end device node.

    Programming the End Device with a number, like 88, as an identifier should be straightforward.  The End Device application code would then need to be modified to send this information to the AP via a message which you need to construct.

    Secondly, the AP software needs to take this message and then send it over the serial interface which ends up on the Virtual COM port.

     

    Devora said:

    would appreciate if anybody here would enlighten me about this? please help. thanks

    You might be able to get away with this by adding an additional couple of bytes to the existing message which is sent by the ED to the AP which is the value 0x88.

  • thanks for the reply Brandon. but could you kindly guide me with it? as i am lost about the source code. i am not really sure which is the code that send the data from the ED to the AP and then to display on the GUI.

  • brandon or anyone else??

  • Devora said:

    thanks for the reply Brandon. but could you kindly guide me with it? as i am lost about the source code. i am not really sure which is the code that send the data from the ED to the AP and then to display on the GUI.

     

     

    First, I assume you are indeed talking about using the SimpliciTI stack and further more using the Wireless Sensor demo (SLAC139) found on the eZ430-RF2500 Product Folder.  If so, I would suggest you reference the SimpliciTI API.pdf file found in the documentation directory of the SimpliciTI software installation.
    In addition, there is a document discussing the specification of SimpliciTI which helps articulate the functionality of the protocol stack.

    The SimpliciTI API document would be the primary document to help understand the calls into the SimpliciTI stack for accomplishing what you are wanting to do.  You will then see these calls made in the Wireless Sensor demo application software in both the demo_ED.c and demo_AP.c source files.
    In the demo_ED.c, you will see this is the primary file for the sample application using SimpliciTI.  You should find 4 calls into the SimpliciTI stack which setup configuration via the SMPL_ioctl(), initialize the stack via SMPL_Init(), linking to the network via SMPL_Link() and finally periodically sending data to the AP via SMPL_Send().

    You will also find similiar structure on the demo_AP.c side for the Access Point.  This code is a little bit more involved as it sends data to the PC via the Virtual Console port in addition to receiving packets via SMPL_Receive().

  • thanks brandon. but OMG!!!!!!!!!!!!!!!!! ITS SO HARD TO UNDERSTAND....... =X

  • brandon. a question. how does the GUI (Wireless Sensor demo, i had made certain change to that already) recieve data from the AP?

  • Devora said:

    brandon. a question. how does the GUI (Wireless Sensor demo, i had made certain change to that already) recieve data from the AP?

    The demo_AP.c file can be reviewed to understand the packet structure sent to the PC via the Virtual COM port.  The GUI interacts with this Virtual COM Port to receive and display the information.

    At the end of main(), you will see the call to SMPL_Receive(), which gets the message sent from the ED.  The transmitData() function takes this message and sends this in a string to the PC.

  •  hi brandon. i had made some changed to the AP. but now the PC GUI doesnt even display the info when i plug in the AP. the highlighted is the things i add in. can you please help me? thanks =)

    #include "bsp.h"

    #include "mrfi.h"

    #include "bsp_leds.h"

    #include "bsp_buttons.h"

    #include "nwk_types.h"

    #include "nwk_api.h"

    #include "nwk_frame.h"

    #include "nwk.h"

     

    #include "msp430x22x4.h"

    #include "vlo_rand.h"

     

    #define MESSAGE_LENGTH 3

    void TXString( char* string, int length );

    void MCU_Init(void);

    void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH] );

    void transmitDataString(char addr[4],char rssi[3], char msg[MESSAGE_LENGTH]);

    void createRandomAddress(void);

     

    //data for terminal output

    const char splash[] = {"\r\n--------------------------------------------------\r\n     ****\r\n     ****           eZ430-RF2500\r\n     ******o****    Temperature Sensor Network\r\n********_///_****   Copyright 2007\r\n ******/_//_/*****  Texas Instruments Incorporated\r\n  ** ***(__/*****   All rights reserved.\r\n      *********     Version 1.03\r\n       *****\r\n        ***\r\n--------------------------------------------------\r\n"};

     

    // reserve space for the maximum possible peer Link IDs

    static linkID_t sLID[NUM_CONNECTIONS] = {0};

    static uint8_t  sNumCurrentPeers = 0;

     

    // callback handler

    static uint8_t sCB(linkID_t);

     

    // work loop semaphores

    static uint8_t sPeerFrameSem = 0;

    static uint8_t sJoinSem = 0;

    static uint8_t sSelfMeasureSem = 0;

     

    // mode data verbose = default, deg F = default

    char verboseMode = 1;

    char degCMode =0;

     

    int temperature[4] = {0};

     

    void main (void)

    {

      addr_t lAddr;

      bspIState_t intState;

      char *Flash_Addr;                         // Initialize radio address location

      Flash_Addr = (char *)0x10F0;

     

      WDTCTL = WDTPW + WDTHOLD;                 // Stop WDT

      // delay loop to ensure proper startup before SimpliciTI increases DCO

      // This is typically tailored to the power supply used, and in this case

      // is overkill for safety due to wide distribution.

      __delay_cycles(65000);

     

      if( CALBC1_8MHZ == 0xFF && CALDCO_8MHZ == 0xFF )// Do not run if cal values

      {

        P1DIR |= 0x03;

        BSP_TURN_ON_LED1();

        BSP_TURN_OFF_LED2();

        while(1)

        {

          __delay_cycles(65000);

          BSP_TOGGLE_LED2();

          BSP_TOGGLE_LED1();

        }

      }

     

      BSP_Init();

     

      if( Flash_Addr[0] == 0xFF &&

          Flash_Addr[1] == 0xFF &&

          Flash_Addr[2] == 0xFF &&

          Flash_Addr[3] == 0xFF )

        {

          createRandomAddress();                // Create Random device address at

        }                                       // initial startup if missing

      lAddr.addr[0]=Flash_Addr[0];

      lAddr.addr[1]=Flash_Addr[1];

      lAddr.addr[2]=Flash_Addr[2];

      lAddr.addr[3]=Flash_Addr[3];

     

      //SMPL_Init();

      SMPL_Ioctl(IOCTL_OBJ_ADDR, IOCTL_ACT_SET, &lAddr);

     

      MCU_Init();

      //Transmit splash screen and network init notification

      TXString( (char*)splash, sizeof splash);

      TXString( "\r\nInitializing Network....", 26 );

     

      SMPL_Init(sCB);

     

      // network initialized

      TXString( "Done\r\n", 6);

     

      // main work loop

      while(1)

      {

        // Wait for the Join semaphore to be set by the receipt of a Join frame from a

        // device that supports and End Device.

     

        if (sJoinSem && (sNumCurrentPeers < NUM_CONNECTIONS))

        {

          // listen for a new connection

          SMPL_LinkListen(&sLID[sNumCurrentPeers]);

          sNumCurrentPeers++;

          BSP_ENTER_CRITICAL_SECTION(intState);

          if (sJoinSem)

          {

            sJoinSem--;

          }

          BSP_EXIT_CRITICAL_SECTION(intState);

        }

     

        // if it is time to measure our own temperature...

        if(sSelfMeasureSem)

        {

          char msg[8];

          char addr[] = {"HUB0"};

          char rssi[] = {"000"};

          int degC, volt, anumber;

          volatile long temp;

          int results[2];

          int *tempOffset;                      // Initialize temperature offset

          tempOffset = (int *)0x10F4;           // coefficient

     

          ADC10CTL1 = INCH_10 + ADC10DIV_4;     // Temp Sensor ADC10CLK/5

          ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;

          __delay_cycles(250);                  // delay to allow reference to settle      ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled

          results[0] = ADC10MEM;

     

          ADC10CTL0 &= ~ENC;

     

          ADC10CTL1 = INCH_11;                  // AVcc/2

          ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

          __delay_cycles(250);                  // delay to allow reference to settle      ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled

          results[1] = ADC10MEM;

          ADC10CTL0 &= ~ENC;

          ADC10CTL0 &= ~(REFON + ADC10ON);      // turn off A/D to save power

     

          // Collect VCC Sample

          temp = results[1];

          volt = (temp*25)/512;

     

          // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278

          // the temperature is transmitted as an integer where 32.1 = 321

          // hence 4230 instead of 423

          temp = results[0];

          degC = ((temp * 4230) / 1024) - 2780;

          if( *tempOffset != 0xFFFF )

            degC += *tempOffset;

     

          // Moving window of samples

          temperature[0] = temperature[1];

          temperature[1] = temperature[2];

          temperature[2] = temperature[3];

          temperature[3] = degC;

     

          // If the low-pass filter buffer is not yet full, do not send data to AP

          if(temperature[0] != 0)

          {

            // Average the last 4 samples

            temp = temperature[0] + temperature[1] + temperature[2] + temperature[3];

            temp = temp >> 2;                   // Divide by 4

     

            // Load the message

            msg[0] = temp&0xFF;

            msg[1] = (temp>>8)&0xFF;

            msg[2] = volt;

            msg[4] = 0;

            msg[5] = 0;

                msg[6] = 0;

                msg[7] = 0;

            transmitDataString(addr, rssi, msg );

          }

     

          BSP_TOGGLE_LED1();

          sSelfMeasureSem = 0;

        }

     

        // Have we received a frame on one of the ED connections?

        // No critical section -- it doesn't really matter much if we miss a poll

        if (sPeerFrameSem)

        {

          uint8_t     msg[MAX_APP_PAYLOAD], len, i;

     

          // process all frames waiting

          for (i=0; i<sNumCurrentPeers; ++i)

          {

            if (SMPL_Receive(sLID[i], msg, &len) == SMPL_SUCCESS)

            {

              ioctlRadioSiginfo_t sigInfo;

              sigInfo.lid = sLID[i];

              SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SIGINFO, (void *)&sigInfo);

              transmitData( i, (signed char)sigInfo.sigInfo.rssi, (char*)msg );

              BSP_TURN_ON_LED2();               // Toggle LED2 when received packet

              BSP_ENTER_CRITICAL_SECTION(intState);

              sPeerFrameSem--;

              BSP_EXIT_CRITICAL_SECTION(intState);

              __delay_cycles(10000);

              BSP_TURN_OFF_LED2();

            }

          }

        }

      }

    }

     

    /*******************************************************************************

    *BEGHDR

    *

    *NAME:createRandomAddress()

    *

    *DESCRIPTION: generate random address

    *

    *******************************************************************************/

    void createRandomAddress(void)

    {

      unsigned int rand, rand2;

      char *Flash_Addr;                         // Initialize radio address location

      Flash_Addr = (char *)0x10F0;

     

      do

      {

        rand = TI_getRandomIntegerFromVLO();    // first byte can not be 0x00 of 0xFF

      }

      while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );

      rand2 = TI_getRandomIntegerFromVLO();

     

      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz

      DCOCTL = CALDCO_1MHZ;

      FCTL2 = FWKEY + FSSEL0 + FN1;             // MCLK/3 for Flash Timing Generator

      FCTL3 = FWKEY + LOCKA;                    // Clear LOCK & LOCKA bits

      FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation

     

      Flash_Addr[0]=(rand>>8) & 0xFF;

      Flash_Addr[1]=rand & 0xFF;

      Flash_Addr[2]=(rand2>>8) & 0xFF;

      Flash_Addr[3]=rand2 & 0xFF;

     

      FCTL1 = FWKEY;                            // Clear WRT bit

      FCTL3 = FWKEY + LOCKA + LOCK;             // Set LOCK & LOCKA bit

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH] )

    {

      char addrString[4];

      char rssiString[3];

      volatile signed int rssi_int;

     

      addrString[0] = '0';

      addrString[1] = '0';

      addrString[2] = '0'+(((addr+1)/10)%10);

      addrString[3] = '0'+((addr+1)%10);

      rssi_int = (signed int) rssi;

      rssi_int = rssi_int+128;

      rssi_int = (rssi_int*100)/256;

      rssiString[0] = '0'+(rssi_int%10);

      rssiString[1] = '0'+((rssi_int/10)%10);

      rssiString[2] = '0'+((rssi_int/100)%10);

     

      transmitDataString( addrString, rssiString, msg );

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void transmitDataString(char addr[4],char rssi[3], char msg[MESSAGE_LENGTH] )

    {

      char temp_string[] = {" XX.XC"};

     

      int temp = msg[0] + (msg[1]<<8);

      int tcnt=msg[4] + (msg[5]<<8);

      if( !degCMode )

      {

        temp = (int) ((((float)temp)*1.8)+320);

        temp_string[5] = 'F';

      }

      if( temp < 0 )

      {

        temp_string[0] = '-';

        temp = temp * -1;

      }

      else if( ((temp/1000)%10) != 0 )

      {

        temp_string[0] = '0'+((temp/1000)%10);

      }

      temp_string[4] = '0'+(temp%10);

      temp_string[2] = '0'+((temp/10)%10);

      temp_string[1] = '0'+((temp/100)%10);

     

      if( verboseMode )

      {

            char output_verbose[] = {"\r\nNode:XXXX,Temp:-XX.XC,Battery:X.XV,Strength:XXX%,RE:XXXXXXX,anumber:XX"};

     

        output_verbose[46] = rssi[2];

        output_verbose[47] = rssi[1];

        output_verbose[48] = rssi[0];

     

        output_verbose[17] = temp_string[0];

        output_verbose[18] = temp_string[1];

        output_verbose[19] = temp_string[2];

        output_verbose[20] = temp_string[3];

        output_verbose[21] = temp_string[4];

        output_verbose[22] = temp_string[5];

     

        output_verbose[32] = '0'+(msg[2]/10)%10;

        output_verbose[34] = '0'+(msg[2]%10);

        output_verbose[7] = addr[0];

        output_verbose[8] = addr[1];

        output_verbose[9] = addr[2];

        output_verbose[10] = addr[3];

        output_verbose[54] = '0'+(msg[3]/100)%10;

        output_verbose[55] = '0'+(msg[3]/10)%10;

        output_verbose[56] = '0'+(msg[3]%10);

        output_verbose[57] = '0'+(msg[6]%10);

        output_verbose[58] = '0'+((tcnt/100)%10);

        output_verbose[59] = '0'+((tcnt/10)%10);

          output_verbose[60] = '0'+(tcnt%10);

     

        output_verbose[70] = '0'+(msg[7]/10)%10;

        output_verbose[71] = '0'+(msg[7]%10);

     

        TXString(output_verbose, sizeof output_verbose );

      }

      else

      {

        char output_short[] = {"\r\n$ADDR,-XX.XC,V.C,RSI,N#"};

     

        output_short[19] = rssi[2];

        output_short[20] = rssi[1];

        output_short[21] = rssi[0];

     

        output_short[8] = temp_string[0];

        output_short[9] = temp_string[1];

        output_short[10] = temp_string[2];

        output_short[11] = temp_string[3];

        output_short[12] = temp_string[4];

        output_short[13] = temp_string[5];

     

        output_short[15] = '0'+(msg[2]/10)%10;

        output_short[17] = '0'+(msg[2]%10);

        output_short[3] = addr[0];

        output_short[4] = addr[1];

        output_short[5] = addr[2];

        output_short[6] = addr[3];

          output_short[7] = '0'+(msg[7]%10);

     

        TXString(output_short, sizeof output_short );

      }

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void TXString( char* string, int length )

    {

      int pointer;

      for( pointer = 0; pointer < length; pointer++)

      {

        //volatile int i;

        UCA0TXBUF = string[pointer];

        while (!(IFG2&UCA0TXIFG));              // USCI_A0 TX buffer ready?

      }

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void MCU_Init()

    {

      BCSCTL1 = CALBC1_8MHZ;                    // Set DCO

      DCOCTL = CALDCO_8MHZ;

     

      BCSCTL3 |= LFXT1S_2;                      // LFXT1 = VLO

      TBCCTL0 = CCIE;                           // TCCR0 interrupt enabled

      TBCCR0 = 12000;                           // ~1 second

      TBCTL = TBSSEL_1 + MC_1;                  // ACLK, upmode

     

      P3SEL |= 0x30;                            // P3.4,5 = USCI_A0 TXD/RXD

      UCA0CTL1 = UCSSEL_2;                      // SMCLK

      UCA0BR0 = 0x41;                           // 9600 from 8Mhz

      UCA0BR1 = 0x3;

      UCA0MCTL = UCBRS_2;

      UCA0CTL1 &= ~UCSWRST;                     // **Initialize USCI state machine**

      IE2 |= UCA0RXIE;                          // Enable USCI_A0 RX interrupt

      __enable_interrupt();

    }

     

    /*******************************************************************************

    * Runs in ISR context. Reading the frame should be done in the

    * application thread not in the ISR thread.

    *******************************************************************************/

    static uint8_t sCB(linkID_t lid)

    {

      if (lid)

      {

        sPeerFrameSem++;

      }

      else

      {

        sJoinSem++;

      }

      // leave frame to be read by application.

      return 0;

    }

     

    /*******************************************************************************

    * ADC10 interrupt service routine

    *******************************************************************************/

    #pragma vector=ADC10_VECTOR

    __interrupt void ADC10_ISR(void)

    {

      __bic_SR_register_on_exit(LPM0_bits);     // Clear CPUOFF bit from 0(SR)

    }

     

    /*******************************************************************************

    * Timer B0 interrupt service routine

    *******************************************************************************/

    #pragma vector=TIMERB0_VECTOR

    __interrupt void Timer_B (void)

    {

      sSelfMeasureSem = 1;

    }

     

    /*******************************************************************************

    * USCIA interrupt service routine

    *******************************************************************************/

    #pragma vector=USCIAB0RX_VECTOR

    __interrupt void USCI0RX_ISR(void)

    {

      char rx = UCA0RXBUF;

      if ( rx == 'V' || rx == 'v' )

      {

        verboseMode = 1;

      }

      else if ( rx == 'M' || rx == 'm' )

      {

        verboseMode = 0;

      }

      else if ( rx == 'F' || rx == 'f' )

      {

        degCMode = 0;

      }

      else if ( rx == 'C' || rx == 'c' )

      {

        degCMode = 1;

      }

    }

     

  • Hey Brandon. you there with me?

  • You should be able to see these messages printed out on HyperTerminal connected to the Virtual COM Port.  Do not invoke the PC GUI, but HyperTerminal instead.

    Are the messages formatted the way you expect them to?

    Have you recompiled the PC GUI to accept this new formated data coming over the Virtual COM Port?

  • Hi Brandon. theres seems to have some problems with the sending of message form ED to AP. i tried using PuTTY to see the Virtual Com Port.

    i had addon the code below to the ED:

    anumber = 0x88;

    msg[7] = anumber;

    the following code i had addon for the AP, the yellow highlight part is the part i addon.

    if(sSelfMeasureSem)

     {

          char msg[8];

          char addr[] = {"HUB0"};

          char rssi[] = {"000"};

          char anumber[] = {"000"};

          int degC, volt;

          volatile long temp;

          int results[2];

          int *tempOffset;                      // Initialize temperature offset

          tempOffset = (int *)0x10F4;           // coefficient

     

          ADC10CTL1 = INCH_10 + ADC10DIV_4;     // Temp Sensor ADC10CLK/5

          ADC10CTL0 = SREF_1 + ADC10SHT_3 + REFON + ADC10ON + ADC10IE + ADC10SR;

          __delay_cycles(250);                  // delay to allow reference to settle      ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled

          results[0] = ADC10MEM;

     

          ADC10CTL0 &= ~ENC;

     

          ADC10CTL1 = INCH_11;                  // AVcc/2

          ADC10CTL0 = SREF_1 + ADC10SHT_2 + REFON + ADC10ON + ADC10IE + REF2_5V;

          __delay_cycles(250);                  // delay to allow reference to settle      ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          ADC10CTL0 |= ENC + ADC10SC;           // Sampling and conversion start

          __bis_SR_register(CPUOFF + GIE);      // LPM0 with interrupts enabled

          results[1] = ADC10MEM;

          ADC10CTL0 &= ~ENC;

          ADC10CTL0 &= ~(REFON + ADC10ON);      // turn off A/D to save power

     

          // Collect VCC Sample

          temp = results[1];

          volt = (temp*25)/512;

     

          // oC = ((A10/1024)*1500mV)-986mV)*1/3.55mV = A10*423/1024 - 278

          // the temperature is transmitted as an integer where 32.1 = 321

          // hence 4230 instead of 423

          temp = results[0];

          degC = ((temp * 4230) / 1024) - 2780;

          if( *tempOffset != 0xFFFF )

            degC += *tempOffset;

     

          // Moving window of samples

          temperature[0] = temperature[1];

          temperature[1] = temperature[2];

          temperature[2] = temperature[3];

          temperature[3] = degC;

     

          // If the low-pass filter buffer is not yet full, do not send data to AP

          if(temperature[0] != 0)

          {

            // Average the last 4 samples

            temp = temperature[0] + temperature[1] + temperature[2] + temperature[3];

            temp = temp >> 2;                   // Divide by 4

     

            // Load the message

            msg[0] = temp&0xFF;

            msg[1] = (temp>>8)&0xFF;

            msg[2] = volt;

            msg[4] = 0;

            msg[5] = 0;

            msg[6] = 0;

            msg[7] = 0;

            transmitDataString(addr, rssi, msg, anumber );

          }

     

          BSP_TOGGLE_LED1();

          sSelfMeasureSem = 0;

        }

     

        // Have we received a frame on one of the ED connections?

        // No critical section -- it doesn't really matter much if we miss a poll

        if (sPeerFrameSem)

        {

          uint8_t     msg[MAX_APP_PAYLOAD], len, i;

     

          // process all frames waiting

          for (i=0; i<sNumCurrentPeers; ++i)

          {

            if (SMPL_Receive(sLID[i], msg, &len) == SMPL_SUCCESS)

            {

              ioctlRadioSiginfo_t sigInfo;

              sigInfo.lid = sLID[i];

              SMPL_Ioctl(IOCTL_OBJ_RADIO, IOCTL_ACT_RADIO_SIGINFO, (void *)&sigInfo);

              transmitData( i, (signed char)sigInfo.sigInfo.rssi, (char*)msg, i );

              BSP_TURN_ON_LED2();               // Toggle LED2 when received packet

              BSP_ENTER_CRITICAL_SECTION(intState);

              sPeerFrameSem--;

              BSP_EXIT_CRITICAL_SECTION(intState);

              __delay_cycles(10000);

              BSP_TURN_OFF_LED2();

            }

          }

        }

      }

    }

     

    /*******************************************************************************

    *BEGHDR

    *

    *NAME:createRandomAddress()

    *

    *DESCRIPTION: generate random address

    *

    *******************************************************************************/

    void createRandomAddress(void)4

    {

      unsigned int rand, rand2;

      char *Flash_Addr;                         // Initialize radio address location

      Flash_Addr = (char *)0x10F0;

     

      do

      {

        rand = TI_getRandomIntegerFromVLO();    // first byte can not be 0x00 of 0xFF

      }

      while( (rand & 0xFF00)==0xFF00 || (rand & 0xFF00)==0x0000 );

      rand2 = TI_getRandomIntegerFromVLO();

     

      BCSCTL1 = CALBC1_1MHZ;                    // Set DCO to 1MHz

      DCOCTL = CALDCO_1MHZ;

      FCTL2 = FWKEY + FSSEL0 + FN1;             // MCLK/3 for Flash Timing Generator

      FCTL3 = FWKEY + LOCKA;                    // Clear LOCK & LOCKA bits

      FCTL1 = FWKEY + WRT;                      // Set WRT bit for write operation

     

      Flash_Addr[0]=(rand>>8) & 0xFF;

      Flash_Addr[1]=rand & 0xFF;

      Flash_Addr[2]=(rand2>>8) & 0xFF;

      Flash_Addr[3]=rand2 & 0xFF;

     

      FCTL1 = FWKEY;                            // Clear WRT bit

      FCTL3 = FWKEY + LOCKA + LOCK;             // Set LOCK & LOCKA bit

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void transmitData(int addr, signed char rssi,  char msg[MESSAGE_LENGTH], int anumber )

    {

      char addrString[4];

      char rssiString[3];

      char anumberString[2];

      volatile signed int rssi_int;

     

      addrString[0] = '0';

      addrString[1] = '0';

      addrString[2] = '0'+(((addr+1)/10)%10);

      addrString[3] = '0'+((addr+1)%10);

      rssi_int = (signed int) rssi;

      rssi_int = rssi_int+128;

      rssi_int = (rssi_int*100)/256;

      rssiString[0] = '0'+(rssi_int%10);

      rssiString[1] = '0'+((rssi_int/10)%10);

      rssiString[2] = '0'+((rssi_int/100)%10);

      anumberString[0] = '0'+(msg[7]/10)%10;

      anumberString[1] = '0'+(msg[7]%10);

     

      transmitDataString( addrString, rssiString, msg, anumberString );

    }

     

    /*******************************************************************************

    *

    *******************************************************************************/

    void transmitDataString(char addr[4],char rssi[3], char msg[MESSAGE_LENGTH], char anumber[2] )

    {

      char temp_string[] = {" XX.XC"};

     

      int temp = msg[0] + (msg[1]<<8);

      int tcnt=msg[4] + (msg[5]<<8);

      if( !degCMode )

      {

        temp = (int) ((((float)temp)*1.8)+320);

        temp_string[5] = 'F';

      }

      if( temp < 0 )

      {

        temp_string[0] = '-';

        temp = temp * -1;

      }

      else if( ((temp/1000)%10) != 0 )

      {

        temp_string[0] = '0'+((temp/1000)%10);

      }

      temp_string[4] = '0'+(temp%10);

      temp_string[2] = '0'+((temp/10)%10);

      temp_string[1] = '0'+((temp/100)%10);

     

      if( verboseMode )

      {

            char output_verbose[] = {"\r\nNode:XXXX,Temp:-XX.XC,Battery:X.XV,Strength:XXX%,RE:XXXXXXX,Anumber:XX"};

     

        output_verbose[46] = rssi[2];

        output_verbose[47] = rssi[1];

        output_verbose[48] = rssi[0];

     

        output_verbose[17] = temp_string[0];

        output_verbose[18] = temp_string[1];

        output_verbose[19] = temp_string[2];

        output_verbose[20] = temp_string[3];

        output_verbose[21] = temp_string[4];

        output_verbose[22] = temp_string[5];

     

        output_verbose[32] = '0'+(msg[2]/10)%10;

        output_verbose[34] = '0'+(msg[2]%10);

        output_verbose[7] = addr[0];

        output_verbose[8] = addr[1];

        output_verbose[9] = addr[2];

        output_verbose[10] = addr[3];

        output_verbose[54] = '0'+(msg[3]/100)%10;

        output_verbose[55] = '0'+(msg[3]/10)%10;

        output_verbose[56] = '0'+(msg[3]%10);

        output_verbose[57] = '0'+(msg[6]%10);

        output_verbose[58] = '0'+((tcnt/100)%10);

        output_verbose[59] = '0'+((tcnt/10)%10);

          output_verbose[60] = '0'+(tcnt%10);

     

        output_verbose[70] = anumber[0];

        output_verbose[71] = anumber[1];

     

        TXString(output_verbose, sizeof output_verbose );

      }

      else

      {

        char output_short[] = {"\r\n$ADDR,-XX.XC,V.C,RSI,N#,XX"};

     

        output_short[19] = rssi[2];

        output_short[20] = rssi[1];

        output_short[21] = rssi[0];

     

        output_short[8] = temp_string[0];

        output_short[9] = temp_string[1];

        output_short[10] = temp_string[2];

        output_short[11] = temp_string[3];

        output_short[12] = temp_string[4];

        output_short[13] = temp_string[5];

     

        output_short[15] = '0'+(msg[2]/10)%10;

        output_short[17] = '0'+(msg[2]%10);

        output_short[3] = addr[0];

        output_short[4] = addr[1];

        output_short[5] = addr[2];

        output_short[6] = addr[3];

     

          output_short[26] = anumber[0];

          output_short[27] = anumber[1];

     

        TXString(output_short, sizeof output_short );

      }

    }

     

     

    after recompiling the firmware for AP and ED, using PuTTY, it shows the Anumber:36 instead the number 88 i wanted, any idea what is the reason for it?

  • brandon, alright, i have got the message from PuTTY correctly, now i have problems wht the GUI.

  • Are you using the existing, provided GUI, or a modified version of it?

    If you change the packet structure sent by the AP to the PC, you will need to correspondingly modify the PC GUI to accept and parse this new packet.  In addition, the code associate with the node class needs to be modified to add this additional parameter and draw it on the actual visual portion of the GUI.

  • a modify version of my own, i had also changed the packet structure in the iohandler.cpp on the PC GUI as below:

     

    IoHandler::IoHandler(QObject *pParent)

    {

        pMyParent = (QMainWindow *)pParent;

     

        RefreshComPort();

     

          //conWindow=new ConWindow;

          //conWindow->show();

        comPort = new ComPort(this);

     

        connect(this, SIGNAL(dataReceived(/*int index*/)), pParent, SLOT(dataReceived(/*int index*/)));

     

        // Create instance to Node Database.

        pNodeDb = new NodeDb;

     

        id_node = new QByteArray("Node:");

          id_temperature= new QByteArray("Temp:");

          id_voltage = new QByteArray("Battery:");

        id_strength = new QByteArray("Strength:");

          id_EOP = new QByteArray("RE:");

          id_anumber = new QByteArray("Anumber:");

    }

    void IoHandler::handleData(QByteArray *pPacket)

    {

        NodeDb::DATA *pData = new NodeDb::DATA;

     

          int position, sizeOfIdentifier,i;

          // Array to save the value which will be converted

        QByteArray temporary("");

     

          // securety to see if the array received is empty or do not contain end of packet

          if(pPacket->isNull() ||!(pPacket->contains(*id_anumber))){

    // We do not want to start messing with an emtpy or incomplete message

                return;

          }

     

          position = pPacket->indexOf(*id_node);

          sizeOfIdentifier = id_node->size();

     

          if (position == -1) {

              // Bad things can happen if "Node:" is not found in the message...

                return;

          }

        // Base node

          else if(pPacket->at(position + sizeOfIdentifier + 2) == 'B'){

                pData->addr = 0x0000;

                pData->type = Node::ACCESS_POINT;

          }

          // Other node

          else {

                // The node number is found here, see function description

                temporary.append(pPacket->at(position + sizeOfIdentifier + 2));

                temporary.append(pPacket->at(position + sizeOfIdentifier + 3));

            pData->addr = temporary.toInt();

                temporary.clear();

                pData->type = Node::END_DEVICE;

          }

     

          pData->status = NodeDb::DS_UPDATED;

     

          // Find and add the temperature

        position = pPacket->indexOf(*id_temperature);

          if (position == -1) {

              // Bad things can happen if "Temp:" is not found in the message...

                return;

          }

          sizeOfIdentifier = id_temperature->size();

        temporary.append(pPacket->at(position + sizeOfIdentifier));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 1));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 2));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 3));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 4));

         

          // Trimmed to remove space at start if the temperature is below 100.0F

          temporary.trimmed();

        pData->temp = temporary.toFloat();

     

          // Cleared so voltage can be added

        temporary.clear();

     

          // Find and add voltage data

        position = pPacket->indexOf(*id_voltage);

          if (position == -1) {

              // Bad things can happen if "Battery:" is not found in the message...

                return;

          }

         

          sizeOfIdentifier = id_voltage->size();

        temporary.append(pPacket->at(position + sizeOfIdentifier));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 1));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 2));

        pData->voltage = temporary.toFloat();

     

        // Cleared so strength can be added

        temporary.clear();

     

          // Find and add strength data

        position = pPacket->indexOf(*id_strength);

          if (position == -1) {

              // Bad things can happen if "Strength:" is not found in the message...

                return;

          }

          sizeOfIdentifier = id_strength->size();

        temporary.append(pPacket->at(position + sizeOfIdentifier));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 1));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 2));

        pData->strength = temporary.toInt();

     

          // Cleared so RE can be added

        temporary.clear();

     

          // Find the RE data

        position = pPacket->indexOf(*id_EOP);

          if (position == -1) {

              // Bad things can happen if "RE:" is not found in the message...

                return;

          }

     

          sizeOfIdentifier = id_EOP->size();

        temporary.append(pPacket->at(position + sizeOfIdentifier));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 1));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 2));

        pData->re = temporary.toInt();

     

          temporary.clear();

          temporary.append(pPacket->at(position + sizeOfIdentifier +3));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 4));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 5));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 6));

          pData->t_time_on=temporary.toInt();

     

          // Cleared so anumber can be added

        temporary.clear();

     

          // Find and add anumber data

        position = pPacket->indexOf(*id_anumber);

          if (position == -1) {

              // Bad things can happen if "anumber: " is not found in the message...

                return;

          }

          sizeOfIdentifier = id_anumber->size();

        temporary.append(pPacket->at(position + sizeOfIdentifier));

          temporary.append(pPacket->at(position + sizeOfIdentifier + 1));

          pData->anumber = temporary.toInt();

         

          // time stamp for console information    

          QDate date = QDate::currentDate();

          QString cur_date;

          cur_date.sprintf( "%2d/%2d/%4d", date.month(), date.day(),date.year());

     

          QString qsTemp;

          qsTemp = QTime::currentTime().toString();

     

          pack_len=ComPortThread::PACKET_LENGTH;   

     

          for (i=0;i<pack_len;i++)

          {

                conTemp.append(pPacket->at(i));

          }

     

          conTemp.append(", ");

          conTemp.append(cur_date);

          conTemp.append(", ");

          conTemp.append(qsTemp);

         

          emit storeData(conTemp);

          conTemp="";

     

          // for test

          if (pData->type == Node::END_DEVICE)

          {

                rebyte2=temporary.toInt();

     

                pData->fadeNumber=0;

                pData->fadeTime=0;

                pData->newNode=1;

                pData->deletedNode=0;

          }

         

          int index;

        index = pNodeDb->addData(pData);

     

        emit dataReceived();

    }

     

     

    But it seems like the GUI is not getting the data from AP, the GUI just doesnt work even when i plug in the AP to the USB.  

     

  • I am not familiar with the PC GUI side application code, therefore I can't comment on the reason why you are not getting anything here.

  • argh. that is bad. anybody here who can help me with the PC GUI??

  • Hi.

    Found one thing that you will need to change. In comportthread.h you will need to extend the PACKET_LENGTH to the new string size, otherwise it will not capture the whole string.

    Hope this gets you at least a step further.

    Kjetil

  • Hi there, 

     

    Devora, did you make it happen after all this time? Did you manage to alter the code in order to show the number 88 or any respective number, every time you plug in a device?