Beispiel #1
0
//This method get the zone and the power of the lamp one after one, this can be use to analyse part after part
void Dispo::Analyse(String code, int zone)
{
  // if we are still looking to the current zone of the order
  if(orderZone)
  {
    //Serial.println(code);    //Debug code show the order zone area
    int temp = code.toInt(); // Convert a string to a int cause the zone is an string
    // we check we are in the good zone, if it's true, the next part can be read
    if(temp == zone)
    {
      zoneMatch = true;
    }
    else
    {
      zoneMatch = false;
    }
    orderZone = false;         // Say we have finished looking the zone
    //Serial.print(" zone : ");  //Debug code Show the zone of the arduino
    //Serial.println(zone);      //Debug code
  }
  else
  {
    // we are reading the order and the next step is the a new patern than we put orderZone to true than
    orderZone = true;
    //we are in the good zone so we execute the order
    if(zoneMatch)
    {
       //Serial.println(code);  //Debug code show the code that's send from internet to arduino for this zone
       int p = code.toInt();  // Convert a string to a int cause we need a % in int
       Luminaire(p);
    }
  }
}
Beispiel #2
0
void Soundy::playABC(String abc) {

  //abc.toLowerCase(); // legacy
  
  Serial.write("L="+L);
  
  for (int n = 0; n < abc.length(); n++) {
    char note = abc.charAt(n);    

    if (!isNote(String(note))) continue;
    Serial.write(note);

    int duration = 1;    
    if (n < abc.length()-1) {
      String next = String(abc.charAt(n+1));
      if (next.toInt() > 0) {
        duration = next.toInt();        
        n++;
      }
    }
    Serial.write(duration);    
        
    if (note == ' ') {
      delay ( duration * L);
    } else {
      playNote(String(note), duration * L);
    }
    delay( L / 2);    
  }
}
Beispiel #3
0
int Request::timeParamToSeconds(String param)
{
	try {
		int s = 0;

		if(param.contains("h"))
		{
			String hours = param;
			param = hours.cut('h');
			s+= hours.toInt()*3600;

			if(!param.contains("m") && !param.contains("s"))
				param+= 'm';
		}

		if(param.contains("m"))
		{
			String minutes = param;
			param = minutes.cut('m');
			s+= minutes.toInt()*60;
		}

		param.cut('s');
		s+= param.toInt();
		return s;
	}
	catch(const std::exception &e)
	{
		return -1;
	}
}
	void EX_Servo::beSmart(const String &str)  
	{
		String level = str.substring(str.indexOf(' ') + 1, str.indexOf(':'));
		String rate = str.substring(str.indexOf(':') + 1);
       
		level.trim();
		rate.trim();
		
		if (st::Executor::debug) {
			Serial.print(F("EX_Servo::beSmart level = "));
			Serial.println(level);
			Serial.print(F("EX_Servo::beSmart rate = "));
			Serial.println(rate);
		}
				
		m_nCurrentLevel = int(level.toInt());
		m_nCurrentRate = long(rate.toInt());
		m_nOldAngle = m_nCurrentAngle;
		m_nTargetAngle = map(m_nCurrentLevel, 0, 100, m_nMinLevelAngle, m_nMaxLevelAngle);

		if (st::Executor::debug) {
			Serial.print(F("EX_Servo::beSmart OldAngle = "));
			Serial.println(m_nOldAngle);
			Serial.print(F("EX_Servo::beSmart TargetAngle = "));
			Serial.println(m_nTargetAngle);
			Serial.print(F("EX_Servo::beSmart CurrentRate = "));
			Serial.println(m_nCurrentRate);
		}
		writeAngleToPin();
		

	}
Beispiel #5
0
//this method is a method that get the zone of the arduino, the zone of the ordrer and the order. he will get the result quiqly but need some works from the user
void Dispo::Analyse(String codeZone, String code, int zone)
{
  int temp = codeZone.toInt();
  if(temp == zone)
  {
    int p = code.toInt();
  }
}
String ActuatorRelay::set(String instruction_code, int instruction_id, String instruction_parameter) {
  if ((instruction_code == instruction_code_) && (instruction_id == instruction_id_)) {
    if (instruction_parameter.toInt() == 1) {
      turnOn();
      return "";
    }
    else if(instruction_parameter.toInt() == 0) {
      turnOff();
      return "";
    }
  }
  return "";
}
void NetworkConnectionClass::getConfigData()
{
  String name = "";
  String value = "";
  boolean isValue = false;
  char character;
  SensorData *data;
  while (client.available() > 0) {
    character = client.read();
    if (character == '{') {
      data = new SensorData();
      name = "";
      value = "";
      isValue = false;
      continue;
    }
    if (character == ',' || character == '}') {
      if (name.equals("name")) {
        data->name = value;
      }
      else if (name.equals("code")) {
        data->code = value.toInt();
      }
      else if (name.equals("threshold")) {
        data->treshold = value.toInt();
      }
      else if (name.equals("pin")) {
        data->pin = getIntValue(value);
      }
      Serial.println(value);
      name = "";
      value = "";
      isValue = false;
      if (character == '}') {
        data->oldValue = 0;
        sensorData->insert(data);
      }
      continue;
    }
    if (character == ':') {
      isValue = true;
      continue;
    }
    if (!isValue) {
      name.concat(character);
    }
    else {
      value.concat(character);
    }
  }
}
Beispiel #8
0
Action* getAction() {
  while (Serial.available()) {
    char inChar = (char)Serial.read();
    if (inChar == '\n') {
      Serial.flush();

      int indexOfUnderscore = tmpSerial.indexOf('_');
      if (indexOfUnderscore > 0) {
        command = tmpSerial.substring(0, indexOfUnderscore);
        params  = tmpSerial.substring(indexOfUnderscore + 1);
      } else {
        command = tmpSerial;
        params  = "";
      }

      tmpSerial = "";

      pp("Received command: ");
      ppln(command);

      if (command == "bb") {
        return new Identify();
      } else if (command == "off") {
        return new Off();
      } else if (command == "rainbow") {
        return new Rainbow();
      } else if (command == "rainbow-all") {
        return new RainbowAll();
      } else if (command == "rainbow-shift") {
        return new RainbowShift();
      } else if (command == "set-leds") {
        return new SetLEDs(params.toInt());
      } else {
        //
        // These don't return actions.  Instead they take some immediate effect
        // mostly used to do some sort of configuration.
        //
        if (command == "change-delay") {
          delayInterval = params.toInt();
        } else if (command == "set-bri") {
          strip.setBrightness(params.toInt());
        }
        return NULL;
      }

    } else {
      tmpSerial += inChar;
    }
  }
  return NULL;
}
Beispiel #9
0
void CommandInterpreter::messageToHSVColor(const String &valueName, const String &message, ColorHSV &color)
{
    if( valueName.equals( "Hue" ) )
    {
        color.h = message.toInt();
    }
    else if( valueName.equals( "Saturation" ) )
    {
        color.s = message.toInt();
    }
    else if( valueName.equals( "Value" ) )
    {
        color.v = message.toInt();
    }
}
Beispiel #10
0
static void callback(char* topic, byte* payload, unsigned int length) {
  StaticJsonBuffer<200> jsonBuffer;

//  Serial.print("Message arrived [");
//  Serial.print(topic);
//  Serial.print("] ");
//  for (int i = 0; i < length; i++) {
//    Serial.print((char)payload[i]);
//  }
//  Serial.println();

  JsonObject& root = jsonBuffer.parseObject((char *)payload);
  if (!root.success()) {
    Serial.println("Failed to parse incoming JSON message.");
    return;
  }

  String keyname = root["keyname"];
  String value = root["value"];
//  Serial.print("Got key: ");
//  Serial.println(keyname);

//  Serial.print("Value: ");
//  Serial.println(value);

  if (keyname == "new_mode") {
    g_settings.mode = value.toInt() ? MODE_COOL:MODE_HEAT;
    Serial.print("Updated MODE to: ");
    Serial.println(g_settings.mode);
  }  else if (keyname == "new_compmode") {
    g_settings.comp_mode = value.toInt();
    Serial.print("Updated COMPRESSOR MODE to: ");
    Serial.println(g_settings.comp_mode);
  }  else if (keyname == "full_status") {
    full_status = value.toInt();
    Serial.print("Force full status update");
    Serial.println(full_status);
  }  else if (keyname == "new_setpoint") {
    g_settings.setpoint = value.toInt();
    Serial.print("Updated setpoint to: ");
    Serial.println(g_settings.setpoint);
  }  else if (keyname == "new_hyst") {
    g_settings.hysteresis = value.toInt();
    Serial.print("Updated hysteresis to: ");
    Serial.println(g_settings.hysteresis);
  }

}
Beispiel #11
0
int tinkerAnalogWrite(String command){
    int pinNumber = command.charAt(1) - '0';
    if (pinNumber< 0 || pinNumber >7) return -1;
    String value = command.substring(3);
    if(command.startsWith("D")){
        pinMode(pinNumber, OUTPUT);
        analogWrite(pinNumber, value.toInt());
        return 1;
    }
    else if(command.startsWith("A")){
        pinMode(pinNumber+10, OUTPUT);
        analogWrite(pinNumber+10, value.toInt());
        return 1;
    }
    else return -2;
}
Beispiel #12
0
void PopupMenuImpl::setValue(const String& value) {
  DCHECK(m_ownerElement);
  bool success;
  int listIndex = value.toInt(&success);
  DCHECK(success);
  m_ownerElement->provisionalSelectionChanged(listIndex);
}
Beispiel #13
0
void onDataSent(HttpClient& client, bool successful)
{
	if (successSent)
		return;

	Serial.println("ON DATA SENT: ");

	if (successful)
	{
		successSent = true;
		blinkGreenStart(200, 2);
		Serial.println("Success sent");
	}
	else if (!successSent)
	{
		blinkRedStart(200, 4);
		Serial.println("Failed");

	}

	String response = client.getResponseString();
	Serial.println("Server response: '" + response + "'");
	if (response.length() > 0)
	{
		int intVal = response.toInt();

		if (intVal == 0)
			Serial.println("Sensor value wasn't accepted");
	}

	WifiStation.disconnect();
	sleepTimer.startOnce();
}
Beispiel #14
0
void PopupMenuImpl::setValueAndClosePopup(int numValue,
                                          const String& stringValue) {
  DCHECK(m_popup);
  DCHECK(m_ownerElement);
  if (!stringValue.isEmpty()) {
    bool success;
    int listIndex = stringValue.toInt(&success);
    DCHECK(success);

    EventQueueScope scope;
    m_ownerElement->selectOptionByPopup(listIndex);
    if (m_popup)
      m_chromeClient->closePagePopup(m_popup);
    // 'change' event is dispatched here.  For compatbility with
    // Angular 1.2, we need to dispatch a change event before
    // mouseup/click events.
  } else {
    if (m_popup)
      m_chromeClient->closePagePopup(m_popup);
  }
  // We dispatch events on the owner element to match the legacy behavior.
  // Other browsers dispatch click events before and after showing the popup.
  if (m_ownerElement) {
    PlatformMouseEvent event;
    Element* owner = &ownerElement();
    owner->dispatchMouseEvent(event, EventTypeNames::mouseup);
    owner->dispatchMouseEvent(event, EventTypeNames::click);
  }
}
Beispiel #15
0
void Dispositif::parseMessage(String code)
{
  if(orderZone)
  {
    //Serial.println(code);
    //int temp = code.toInt();
    // we check we are in the good zone, if it's true, the next part can be read
    if(code == zone)
    {
      zoneMatch = true;
    }
    else
    {
      zoneMatch = false;
    }
    orderZone = false; 
  }
  else
  { 
    orderZone = true;
    // if we are in the right zone, we can update the brightness
    if(zoneMatch)
    {
       //int p = code.toInt();  // Code is a string
       setBrightness(0, code.toInt());
    }
  }
}
Beispiel #16
0
int Ospom::groupCommandVal(void) {
       //Secondary Serial String Processing Input to use in group commands
  int CommandInt = InputString.charAt(8) - '0';  //converting char to int
  int Comand1 = InputString.charAt(9) - '0';  //converting char 2 to int
  if ((Comand1 >= 0) && (Comand1 <= 9) && (Comand1 != ':')) {
    CommandInt = CommandInt * 10;
    CommandInt += Comand1;  
  } 
//This part gets further command info
  String serialReadString = "";
  if (((InputString.charAt(9) - '0') >= 0) && ((InputString.charAt(9) - '0') <=9)) {  //If it is a 2 digit request
    for (int i = 11; i < InputString.length(); i++) {
      char ActuatorRead = InputString.charAt(i);
      serialReadString += ActuatorRead;
    }
  }
  else {   //If it is a 1 digit request
    for (int i = 10; i < InputString.length(); i++) {
      char ActuatorRead = InputString.charAt(i);
      serialReadString += ActuatorRead;
    }
  }
  serialReadString.toCharArray(CommandCharArray, serialReadString.length());    //convert to Char array
  GroupCommandInt = serialReadString.toInt();  //An integer of the serial input
  return CommandInt;
}
uint8_t NetworkConnectionClass::getIntValue(String pin) {
  uint8_t pin_uint = 0;

  if (pin.equals("A0")) {
    pin_uint = A0;
  }
  else if (pin.equals("A1")) {
    pin_uint = A1;
  }
  else if (pin.equals("A2")) {
    pin_uint = A2;
  }
  else if (pin.equals("A3")) {
    pin_uint = A3;
  }
  else if (pin.equals("A4")) {
    pin_uint = A4;
  }
  else if (pin.equals("A5")) {
    pin_uint = A5;
  }
  else if (pin.equals("A6")) {
    pin_uint = A6;
  }
  else if (pin.equals("A7")) {
    pin_uint = A7;
  }
  else {
    pin_uint = pin.toInt();
  }
  return pin_uint;
}
void DefaultPolicyDelegate::decidePolicyForNavigationAction(WebView* webView, 
    /*[in]*/ WebActionPropertyBag* actionInformation, 
    /*[in]*/ WebMutableURLRequest* request, 
    /*[in]*/ WebFrame* /*frame*/, 
    /*[in]*/ WebFramePolicyListener* listener)
{
    int navType = 0;

    String ret = actionInformation->Read(WebActionNavigationTypeKey);
    navType = ret.toInt();

    bool canHandleRequest = webView->canHandleRequest(request);
    if (canHandleRequest)
        listener->use();
    else if (navType == WebNavigationTypePlugInRequest)
        listener->use();
    else {
        String url = request->URL();
        // A file URL shouldn't fall through to here, but if it did,
        // it would be a security risk to open it.
        if (!url.startsWith("file:")) {
            // FIXME: Open the URL not by means of a webframe, but by handing it over to the system and letting it determine how to open that particular URL scheme.  See documentation for [NSWorkspace openURL]
            ;
        }
        listener->ignore();
    }
}
Beispiel #19
0
bool Uri::Private::parseDecOctet()
{
    String decOctet;
    for (size_t i = 0; i < 3; ++i) {
        const Char currChar = m_uri[m_parserPos];
        const iuint32 currValue = currChar.value();
        if (currValue && currValue < 128 && isDigit[currValue]) {
            decOctet += currChar;
            ++m_parserPos;
        } else {
            break;
        }
    }
    if (decOctet.empty()) {
        return false;
    } else {
        const size_t retValue = decOctet.toInt();
        if (retValue < 256) {
            m_parserAux += decOctet;
            return true;
        } else {
            return false;
        }
    }
}
int setPublishable(String publishable)
{
    if( publishable.length() > 0 )
    {
        int pubInt = publishable.toInt();
        
        Serial.println("===> setPublishable");
        Serial.print("\t");Serial.println(pubInt);
        
        if (pubInt == 0)
        {
            publishController->setPublishable(false);
        }
        else
        {
            publishController->setPublishable(true);
        }
        
        return 1;
    }
    else
    {
        return -1;
    }
}
Beispiel #21
0
int PhoBot::control(String command) {
    // "F-100" - forward B, L, R
    String action = command.substring(0, 1);
    String speedStr = command.substring(2);
    float speed = 0;
    if (! action.equalsIgnoreCase("S")) {
        speed = speedStr.toInt() / 100.0;
    }
    if (action.equalsIgnoreCase("F")) {
        setMotor(M3, FORWARD, speed);
        setMotor(M4, FORWARD, speed);
    }
    else if (action.equalsIgnoreCase("B")) {
        setMotor(M3, BACK, speed);
        setMotor(M4, BACK, speed);
    }
    else if (action.equalsIgnoreCase("L")) {
        setMotor(M3, FORWARD, speed);
        setMotor(M4, BACK, speed);
    }
    else if (action.equalsIgnoreCase("R")) {
        setMotor(M3, BACK, speed);
        setMotor(M4, FORWARD, speed);
    }
    else if (action.equalsIgnoreCase("S")) {
        setMotor(M3, STOP);
        setMotor(M4, STOP);
    }
    return 1;
}
Beispiel #22
0
void selectMode() {
	getModes();
	*kvt << "\nPlease select a graphic mode in the list below:\n";

	for (u32int i = 0; i < Disp::modes.size(); i++) {
		Disp::mode_t& m = Disp::modes[i];
		*kvt << (s32int)i << ":\t" << "Text " << m.textRows << "x" << m.textCols << MVT::setcsrcol(21);
		if (m.graphWidth != 0 and m.graphHeight != 0) {
			*kvt << "Graphics " << m.graphWidth << "x" << m.graphHeight << "x" << m.graphDepth << "\t";
		} else {
			*kvt << "No graphics";
		}
		*kvt << MVT::setcsrcol(45) << m.device->getName() << "\n";
	}

	while (1) {
		*kvt << "\nYour selection: ";
		String answer = kvt->readLine();
		u32int n = answer.toInt();
		kvt->unmap();
		if (n >= 0 and n < Disp::modes.size() and Disp::setMode(Disp::modes[n])) {
			delete kvt;
			SB::reinit();
			kvt = new ScrollableVT(Disp::mode.textRows - SB::height, Disp::mode.textCols, 100, KVT_FGCOLOR, KVT_BGCOLOR);
			kvt->map(SB::height);
			Kbd::setFocus(kvt);
			return;
		} else {
			Disp::setMode(Disp::modes[1]);
			kvt->map();
			*kvt << "Error while switching video mode, please select another one.";
		}
	}
}
Beispiel #23
0
bool NetworkJob::handleFTPHeader(const String& header)
{
    size_t spacePos = header.find(' ');
    if (spacePos == notFound)
        return false;
    String statusCode = header.left(spacePos);
    switch (statusCode.toInt()) {
    case 213:
        m_isFTPDir = false;
        break;
    case 530:
        purgeCredentials();
        sendRequestWithCredentials(ProtectionSpaceServerFTP, ProtectionSpaceAuthenticationSchemeDefault, "ftp");
        break;
    case 230:
        storeCredentials();
        break;
    case 550:
        // The user might have entered an URL which point to a directory but forgot type '/',
        // e.g., ftp://ftp.trolltech.com/qt/source where 'source' is a directory. We need to
        // added '/' and try again.
        if (m_handle && !m_handle->firstRequest().url().path().endsWith("/"))
            m_needsRetryAsFTPDirectory = true;
        break;
    }

    return true;
}
Beispiel #24
0
void InspectorState::loadFromSettings()
{
    for (PropertyMap::iterator i = m_properties.begin(); i != m_properties.end(); ++i) {
        if (i->second.m_preferenceName.length()) {
            String value;
            m_client->populateSetting(i->second.m_preferenceName, &value);
            switch (i->second.m_value->type()) {
            case InspectorValue::TypeBoolean:
                if (value.length())
                    i->second.m_value = InspectorBasicValue::create(value == "true");
                break;
            case InspectorValue::TypeString:
                i->second.m_value = InspectorString::create(value);
                break;
            case InspectorValue::TypeNumber:
                if (value.length())
                    i->second.m_value = InspectorBasicValue::create((double)value.toInt());
                break;
            default:
                ASSERT(false);
                break;
            }
        }
    }
}
Beispiel #25
0
void loop() {
  String content = "";
  char character;
  while(Serial.available()) { // Read from serial, if available, continue.
    character = Serial.read();
    content.concat(character);
  }
  if (content != "") {
    Serial.println(content);
    String ledToChange = getValue(content, '=', 0);
    String ledValueStr = getValue(content, '=', 1);
    int ledValueInt = ledValueStr.toInt();
    Serial.println("Changing led " + ledToChange + " to value " + ledValueStr);
    ledToChange.toLowerCase();
    if(ledToChange == "r" || ledToChange == "red") {
      analogWrite(RED_PORT, ledValueInt);
    } 
    else if (ledToChange == "g" || ledToChange == "green") {
      analogWrite(GREEN_PORT, ledValueInt);
    }  
    else if (ledToChange == "b" || ledToChange == "blue") {
      analogWrite(BLUE_PORT, ledValueInt);
    } 
    else if (ledToChange == "off") {
      analogWrite(RED_PORT, 0);
      analogWrite(GREEN_PORT, 0);
      analogWrite(BLUE_PORT, 0);
    }
  } 
  delay(100); // Just to be safe, we delay every 100miliseconds
}
Beispiel #26
0
int HttpRequest::getContentLength()
{
	String len = getHeader("Content-Length");
	if (len.length() == 0) return -1;

	return len.toInt();
}
Beispiel #27
0
void CommandInterpreter::interpret( String const & topic, String const & message )
{
    String valuePath, valueName;
    strOp::splitFromEnd( topic, valuePath, valueName, '/' );
    if( valuePath.equals( "Netz39/Service/Clock/Wallclock/Simple" ) )
    {
        if( valueName.equals( "Second" ) )
        {
            m_second = message.toInt();
        }
        else if( valueName.equals( "Minute" ) )
        {
            m_minute = message.toInt();
        }
        else if( valueName.equals( "Hour" ) )
        {
            m_hour = message.toInt();
        }
    }
    else if( valuePath.equals( "Netz39/Things/Logouhr/Background" ) )
    {
        messageToHSVColor( valueName, message, m_backgroundColorOuter );
        //m_backgroundColorOuter.v = static_cast<int>( min( max( m_backgroundColorOuter.v, 1 ), 4 ) ) * 255 / 4;
        m_backgroundColorInner = m_backgroundColorOuter;
    }
    else if( valuePath.equals( "Netz39/Things/Logouhr/HourHand" ) )
    {
        messageToHSVColor( valueName, message, m_hourColor );
    }
    else if( valuePath.equals( "Netz39/Things/Logouhr/MinuteHand" ) )
    {
        messageToHSVColor( valueName, message, m_minuteColor );
    }
    else if( valuePath.equals( "Netz39/Things/Logouhr/SecondHand" ) )
    {
        messageToHSVColor( valueName, message, m_secondColor );
    }
    else if( valuePath.equals( "Netz39/Things/Logouhr" ) )
    {
        if( valueName.equals( "Mode" ) )
        {
            setMode( message );
        }
    }

    updatePixels();
}
Beispiel #28
0
bool drive_laser(String message){
    String test = message; // nop
    int counter;
    for(counter = 0; message[counter] != '\r'; counter++);
    String strlen = message.substring(2, 1+counter);
    
    String buffer = message.substring(counter + 1, counter + 2 + strlen.toInt());
    int ProgNr = buffer.toInt();
    
    digitalWrite(LASER_ON, HIGH);  //Laser anschalten
    delay(2000);

    //gewähltes Programm an Laser übermitteln durch setzen der Anschlüsse des Parallel I/O-Schnittstelle
    
    if(ProgNr == 1){
        digitalWrite(LASER_BIT_0, HIGH);
        digitalWrite(LASER_BIT_1, LOW);
        digitalWrite(LASER_BIT_2, LOW);
    }
    else if(ProgNr == 2){
        digitalWrite(LASER_BIT_0, LOW);
        digitalWrite(LASER_BIT_1, HIGH);
        digitalWrite(LASER_BIT_2, LOW);
    }
    else if(ProgNr == 3){
        digitalWrite(LASER_BIT_0, HIGH);
        digitalWrite(LASER_BIT_1, HIGH);
        digitalWrite(LASER_BIT_2, LOW);
    }
   
    
   
    delay(200);
    digitalWrite(LASER_START, HIGH);  //Starte Programm
    delay(1000);
    digitalWrite(LASER_START, LOW);

    //delay(1000);
    digitalWrite(LASER_ON, LOW);
    digitalWrite(LASER_BIT_0, LOW);
    digitalWrite(LASER_BIT_1, LOW);
    digitalWrite(LASER_BIT_2, LOW);
    

    return true;

}
Beispiel #29
0
/**
 * reads the response from the server
 * @return int http code
 */
int HTTPClient::handleHeaderResponse() {

    if(!connected()) {
        return HTTPC_ERROR_NOT_CONNECTED;
    }

    _returnCode = -1;
    _size = -1;

    while(connected()) {
        size_t len = _tcp->available();
        if(len > 0) {
            String headerLine = _tcp->readStringUntil('\n');
            headerLine.trim(); // remove \r

            DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] RX: '%s'\n", headerLine.c_str());

            if(headerLine.startsWith("HTTP/1.")) {
                _returnCode = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt();
            } else if(headerLine.indexOf(':')) {
                String headerName = headerLine.substring(0, headerLine.indexOf(':'));
                String headerValue = headerLine.substring(headerLine.indexOf(':') + 2);

                if(headerName.equalsIgnoreCase("Content-Length")) {
                    _size = headerValue.toInt();
                }

                if(headerName.equalsIgnoreCase("Connection")) {
                    _canReuse = headerValue.equalsIgnoreCase("keep-alive");
                }

                for(size_t i = 0; i < _headerKeysCount; i++) {
                    if(_currentHeaders[i].key.equalsIgnoreCase(headerName)) {
                        _currentHeaders[i].value = headerValue;
                        break;
                    }
                }
            }

            if(headerLine == "") {
                DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] code: %d\n", _returnCode);
                if(_size) {
                    DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] size: %d\n", _size);
                }
                if(_returnCode) {
                    return _returnCode;
                } else {
                    DEBUG_HTTPCLIENT("[HTTP-Client][handleHeaderResponse] Remote host is not an HTTP Server!");
                    return HTTPC_ERROR_NO_HTTP_SERVER;
                }
            }

        } else {
            delay(0);
        }
    }

    return HTTPC_ERROR_CONNECTION_LOST;
}
Beispiel #30
0
Position Concept::named(String const& _name)
{
	if (_name.isEmpty())
		return back();
	if (_name[0].isNumber())
		return middle(_name.toInt() + INT_MIN);
	return middle(AuxilliaryRegistrar::get()->arbitraryOfName(_name));
}