code: static public short bytesToShort(byte[] buffer, int index) {
          int length = 2;
          short integer = 0;
          for (int i = 0; i < length; i++) {
              integer |= ((buffer[index + length - i - 1] & 0xFF) << (i * 8));
          }
          return integer;
      }
docs: This function converts the bytes in a byte array at the specified index to its
  corresponding short value.
  
  @param buffer The byte array containing the short.
  @param index The index for the first byte in the byte array.
  @return The corresponding short value.