• This is where I'm at after a refresh.

    var cmd="";
    
    //Function handles data coming in from Serial.
    Serial4.on('data',function (c) {
    
      if(c==="\r")
      {  
        parseResponse(cmd);
        cmd="";
      }
       cmd+=c;
    });
    
    
    //Parse responses on data received on serial
    function parseResponse(buffer){
       if(buffer.length < 2)
         return; 
    
         if(buffer.indexOf("ERROR:")>0){
         console.log("Error - forcing shutdown");
          Stop_GSM();   
          }
        else
         {
           console.log(buffer);
         }
    }
    
    
    
    function Send_SMS(text)
    {
      Start_GSM();
      setTimeout(function(){send(text);},10000­);
    }
    
    
    //Start the GSM Module
    function Start_GSM() {
      Serial4.setup(9600);
      console.log("GSM Starting...");
      pinMode(C0,"output");
      digitalPulse(C0,1,2000);
    }
    
    function Stop_GSM(){
    pinMode(C0,"output");
    digitalPulse(C0,1,2000);
    }
    
    
    
    function send(input){
        setTimeout(function(){send_command("AT+C­MGS=\"number here\"\r");},2000);
        setTimeout(function(){send_command(input­+"\x1A\r");},3000);
      setTimeout(function(){Stop_GSM();},10000­);
    }
    
    
    
    function send_command(command){
    //Send the command to serial port connected to GSM
      Serial4.write(command);
    }
    
    
    
    function onInit(){
    Send_SMS("Heyyyy!");
    }
    
    onInit();
    

    For me the timed sending of commands is enough to get things running and sending texts. I just need to add in my GPS code and I'll have a tracker that can sms coords to twilio. My JS skills arent up to doing anything better.

About