Package ch.ethz.inf.vs.californium.coap

Examples of ch.ethz.inf.vs.californium.coap.Option


        // the second 4 bits represent the option length
        int optionLengthNibble = (0x0F & nextByte);
        int optionLength = readOptionValueFromNibble(optionLengthNibble);
       
        // read option
        Option option = new Option(currentOption);
        option.setValue(reader.readBytes(optionLength));
       
        // add option to message
        addOptionToSet(option, message.getOptions());
      } else break;
    }
View Full Code Here


            // if is present a conversion for the content-type, then add
            // a new option
            for (int coapContentType : coapContentTypes) {
              if (coapContentType != MediaTypeRegistry.UNDEFINED) {
                // create the option
                Option option = new Option(optionNumber, coapContentType);
                optionList.add(option);
              }
            }
          }
        } else if (optionNumber == OptionRegistry.MAX_AGE) {
          int maxAge = 0;
          if (!headerValue.contains("no-cache")) {
            headerValue = headerValue.split(",")[0];
            if (headerValue != null) {
              int index = headerValue.indexOf('=');
              try {
                maxAge = Integer.parseInt(headerValue.substring(index + 1).trim());
              } catch (NumberFormatException e) {
                LOGGER.warning("Cannot convert cache control in max-age option");
                continue;
              }
            }
          }
          // create the option
          Option option = new Option(optionNumber, maxAge);
          // option.setValue(headerValue.getBytes(Charset.forName("ISO-8859-1")));
          optionList.add(option);
        } else {
          // create the option
          Option option = new Option(optionNumber);
          switch (OptionNumberRegistry.getFormatByNr(optionNumber)) {
          case INTEGER:
            option.setIntegerValue(Integer.parseInt(headerValue));
            break;
          case OPAQUE:
            option.setValue(headerValue.getBytes(ISO_8859_1));
            break;
          case STRING:
          default:
            option.setStringValue(headerValue);
            break;
          }
          // option.setValue(headerValue.getBytes(Charset.forName("ISO-8859-1")));
          optionList.add(option);
        }
View Full Code Here

TOP

Related Classes of ch.ethz.inf.vs.californium.coap.Option

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.