Navigation

    • Register
    • Login
    • Search
    • OpenHardware.io
    • Categories
    • Recent
    • Tags
    • Popular
    1. Home
    2. James Lamont
    • Profile
    • Following
    • Followers
    • Topics
    • Posts
    • Best
    • Groups

    James Lamont

    @James Lamont

    0
    Reputation
    1
    Posts
    229
    Profile views
    0
    Followers
    0
    Following
    Joined Last Online

    James Lamont Follow

    Best posts made by James Lamont

    This user hasn't posted anything yet.

    Latest posts made by James Lamont

    • RE: Sketch presentation / Vera inclusion

      Working with ejtb, here is the updated code. We did upload those files and bounced the lua, However we were unable to get a device registered from the Vera. Any thoughts from this point?

      /*
       * Blabberator.ino
       * 
       * 
       * June 2016
       * 
       */
      
      #define BLABBERATOR_VERSION "0.5"
      
      
      #define SPI_SS  10  // SPI Slave Select
      #define SPI_MOSI 11 // SPI Master Out, Slave In
      #define SPI_MISO 12 // SPI Master In, Slave Out
      #define SPI_SCK  13 // SPI Synchronous Clock
      
      #include <MyConfig.h>
      #include <MySensors.h>
      #include <SPI.h>
      #include <SoftwareSerial.h>
      
      
      /******* Emic Defines, Globals, and Functions *************/
      #define EMIC_RXPIN   3  // Serial input (connects to Emic 2's SOUT pin)
      #define EMIC_TXPIN   4  // Serial output (connects to Emic 2's SIN pin)
      SoftwareSerial emicSerial =  SoftwareSerial(EMIC_RXPIN, EMIC_TXPIN) ;
      void emicSay(char* szStr)
      {
        unsigned long lStart ;  //Time that the last character was sent to the Emic
      
        Serial.print(F("Saying \"")) ;
        Serial.print(szStr) ;
        Serial.print(F("\"... ")) ;
        Serial.flush() ;
      
        //Send the string to the Emic
        emicSerial.listen() ;
        emicSerial.print('S') ;
        emicSerial.print(szStr) ;
        lStart = millis() ;   //Record the time
        emicSerial.print('\n') ;
        emicSerial.flush() ;
      
        //Wait for the Emic to finish
        while (emicSerial.read() != ':')
        {
          if (millis() - lStart > 5000)
          {//Wait for as long as 5 seconds before declaring defeat
            Serial.println(F("timeout waiting for the Emic to finish")) ;
            Serial.flush() ;
            return ;
          }
        }
        Serial.println(F("done")) ;
        Serial.flush() ;
      }
      
      /******* MySensor Defines, Globals, and Callback *************/
      #define NODE_ID 10
      
      
      //Callback function to receive incoming messages
      void receive(const MyMessage &message)
      {
        char * pszMsg ;
      
        //Handle acknowledgement messages
        if (message.isAck())
        {
          Serial.println(F("Ack received from the gateway")) ;
          Serial.flush() ;
        }
      
        //Handle messages by type
        switch (message.type)
        {
          case V_TEXT:    //V_CUSTOM is a guess at a reasonable message type
            pszMsg = (char*)message.getString() ; //This may or may not work
            if (pszMsg != NULL) //Check to see if the returned pointer is legit
            {
              if (pszMsg[0] != (char)0) //Check to see if the string is empty
              {
                emicSay(pszMsg) ;
              }
            }
            break ;
          default:
            Serial.print(F("Unhandled message of type ")) ;
            Serial.println(message.type) ;
            Serial.flush() ;
        }
      }
      
      /******* Stock Arduino Entry Points *************/
      void setup() {
        pinMode(SPI_SS, OUTPUT) ;   //SPI SS pin - set to output to prevent floating asserts stopping SPI
      
        /*
         * Debug serial port initialization (this is the USB link back to the programming computer)
         */
        Serial.begin(MY_BAUD_RATE); //Initialize using whatever the MySensors library is using to avoid conflict
        // this check is only needed on the Leonardo:
        while (!Serial) {
          ; // wait for serial port to connect. Needed for native USB port only
        }
      
        delay(2000) ; //Wait 2 seconds to let the software on the other end of the link to get ready
        
        Serial.print(F("Blabberator booting: version ")) ;
        Serial.println(BLABBERATOR_VERSION) ;
        Serial.flush() ;
      
        /*
         * NOTE: This code was shamelessly stolen from the Emic demo
          When the Emic 2 powers on, it takes about 3 seconds for it to successfully
          initialize. It then sends a ":" character to indicate it's ready to accept
          commands. If the Emic 2 is already initialized, a CR will also cause it
          to send a ":"
        */
        Serial.print(F("Initializing Emic... ")) ;
        emicSerial.begin(9600);
        emicSerial.listen() ;                // Route incoming serial to this object
        emicSerial.print('\n') ;             // Send a CR in case the system is already up
        while (emicSerial.read() != ':') ;   // When the Emic 2 has initialized and is ready, it will send a single ':' character, so wait here until we receive it
        delay(10) ;                          // Short delay
        emicSerial.flush() ;                 // Flush the receive buffer
        Serial.println(F("done")) ;
        Serial.flush() ;
      }
      
      void presentation()  
      {
        /*
         * MySensor node initialization
         * 
         * Sadly, these functions to not have a return value to indicate how they made out.
         */
        Serial.print(F("Initializing MySensor node... ")) ;
        sendSketchInfo("Blabberator", BLABBERATOR_VERSION);
        present(NODE_ID, S_INFO); 
        Serial.print(F("done")) ;
        Serial.flush() ;
      }
      
      void loop() {
        //Nothing to see here folks, move along
      }```
      posted in Development
      James Lamont
      James Lamont