当前位置: 首页>>代码示例>>C++>>正文


C++ WiFly类代码示例

本文整理汇总了C++中WiFly的典型用法代码示例。如果您正苦于以下问题:C++ WiFly类的具体用法?C++ WiFly怎么用?C++ WiFly使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了WiFly类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: receivePacket

boolean receivePacket(UDPpacket& packet, WiFly& wifly)
{
	boolean ret;
	char buf[100];
	ret = wifly.gets(buf, sizeof(buf));
	packet.data += buf;
// 	do {
// 		rByte = wifly.read();
// 		//Serial.println(rByte);
// 		packet.data = packet.data + (char) rByte;
// 		if((char)rByte == '\n') {
// 			break;
// 		}
// 	}while(rByte != -1);
	packet.dataLength = packet.data.length();
	wifly.getHostIP(packet.ip, sizeof(packet.ip));
	packet.port = wifly.getHostPort();

	return true;
	
// 	if(!packet.data.compareTo("-1"))
// 		return false;
// 	else
// 		return true;
}
开发者ID:lagoudiana,项目名称:Arduino-Wifly,代码行数:25,代码来源:UdpServer.cpp

示例2: sendPacket

boolean sendPacket(UDPpacket& packet, WiFly& wifly)
{
	boolean ret;
	char buf[100];
	
	packet.data.toCharArray(buf, sizeof(buf));

	ret = wifly.sendto((const char *)buf, packet.ip, packet.port);
	wifly.flush();
	return ret;
}
开发者ID:lagoudiana,项目名称:Arduino-Wifly,代码行数:11,代码来源:UdpServer.cpp

示例3: terminal

/* Connect the WiFly serial to the serial monitor. */
void terminal()
{
  while (1) {
    if (wifly.available() > 0) {
     Serial.write(wifly.read());
    }

    if (Serial.available() > 0) {
      wifly.write(Serial.read());
    }
  }
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:13,代码来源:Lifegraph.cpp

示例4: wifiSetup

bool wifiSetup(WiFly myWiFly) {
	// Scan, nouveau mode nécessite un firmware >= 2.22
	if (myWiFly.version() < 2.22)
	{
		return false;
	}
	
	if (myWiFly.sendCommand(wifiCompactModeStr))
	{
		return true;
	}
	else
	{
		return false;
	}
}
开发者ID:pmot,项目名称:Balise,代码行数:16,代码来源:wifi_scan_ap.cpp

示例5: wifiScan

bool wifiScan(WiFly myWiFly) {
	// un scan wifi via le RN 171 met environ 2500ms par défaut:
	// - 200ms par canal
	// - 13 canaux
	if (myWiFly.sendCommand(wifiScanStr))
	{
		return true;
	}
	else
	{
		return false;
	}
}
开发者ID:pmot,项目名称:Balise,代码行数:13,代码来源:wifi_scan_ap.cpp

示例6: wifiScanReadLn

int wifiScanReadLn(WiFly myWiFly, char *ptrLine) {
	bool endOfLine = false;
	char c=' ';
	int i=0;

	while (!endOfLine && i<(MAX_LENGTH_SCAN_LINE-1)) 	{
		if (myWiFly.receive((uint8_t *)&c, 1, 300) > 0) {
			if (c != '\r')
				ptrLine[i++] = c;
			else
				endOfLine = true;
		}
		else endOfLine = true; // Plus rien de dispo en entrée...
	}

	ptrLine[i] = '\0';

	return i;
}
开发者ID:pmot,项目名称:Balise,代码行数:19,代码来源:wifi_scan_ap.cpp

示例7: readResponse

void readResponse (char *buf, int max_len, int content_len) {
  // Read content.
  int len = wifly.readBytes(buf, max_len > content_len ? content_len : max_len);
  buf[len] = '\0'; // insurance
  
  // Flush buffer.
  while (wifly.available() > 0) {
    wifly.read();
  }
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:10,代码来源:Lifegraph.cpp

示例8: debugWifiState

void debugWifiState () {
  char buf[32];
  Serial.print(F("MAC: "));
  Serial.println(wifly.getMAC(buf, sizeof(buf)));
  Serial.print(F("IP: "));
  Serial.println(wifly.getIP(buf, sizeof(buf)));
  Serial.print(F("Netmask: "));
  Serial.println(wifly.getNetmask(buf, sizeof(buf)));
  Serial.print(F("Gateway: "));
  Serial.println(wifly.getGateway(buf, sizeof(buf)));
  Serial.print(F("DeviceID: "));
  Serial.println(wifly.getDeviceID(buf, sizeof(buf)));
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:13,代码来源:Lifegraph.cpp

示例9: _headerStart

void JSONAPI::_headerStart (const char *method) {
  // If an old connection is active, close.
  if (wifly.isConnected()) {
    wifly.close();
  }

  if (!wifly.open(this->host, 80)) {
    Serial.println(F("Failed to connect to host."));
  }
  
  wifly.print(method);
  wifly.print(" ");
  // wifly.print("http://");
  // wifly.print(this->host);
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:15,代码来源:Lifegraph.cpp

示例10: request

int JSONAPI::request ( js0n_user_cb_t cb ) {
  if (this->hasBody) {
    wifly.println("0");
    wifly.println();
  }
  
  js0n_parser_t parser;
  parser.buffer = this->buffer;
  parser.stream = &wifly;
  parser.user_cb = cb;
  
  int status_code = 0;
  readResponseHeaders(&status_code, (int *) &parser.length);
  if (status_code != 0 && status_code < 500) {
    int parse_status = js0n_parse ( &parser );
  }
  return status_code;
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:18,代码来源:Lifegraph.cpp

示例11: loop

void loop() {
  int available;

  if (wifly.isConnected() == false) {
    Serial.println("Connecting");

    if (wifly.open("192.168.1.100", 4001)) {
      Serial.println("Connected");
    } else {
      Serial.println("Failed to open");
    }
  } else {
    available = wifly.available();

    if (available < 0) {
      Serial.println("Disconnected");
    } else if (available > 0) {
      Serial.write(wifly.read());
    }
  }
}
开发者ID:matylla,项目名称:accelerode,代码行数:21,代码来源:accelerode.cpp

示例12: _headerEnd

void JSONAPI::_headerEnd () {
  wifly.println(" HTTP/1.1"); // paste your number here
  wifly.print("Host: ");
  wifly.println(this->host);
  wifly.println("User-Agent: lifegraph/0.0.1");
  if (this->hasBody) {
    wifly.println("Content-Type: application/x-www-form-urlencoded");
    wifly.println("Transfer-Encoding: chunked");
  }
  wifly.println();
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:11,代码来源:Lifegraph.cpp

示例13: loop

void loop()
{

    if (wifly.available() > 0) {

    	/* See if there is a request */
		if (wifly.gets(buf, sizeof(buf))) {
		    if (strncmp_P(buf, PSTR("GET /ping"), 9) == 0) {

				/* GET request */
#ifdef DEBUG
				Serial.println(F("PONG XML requested"));
#endif
				while (wifly.gets(buf, sizeof(buf)) > 0) {
				    //Skip rest of request
				}

				sendPong();

	   	 	} else if (strncmp_P(buf, PSTR("GET /data"), 9) == 0) {

	        	/* POST request */
#ifdef DEBUG
	        	Serial.println(F("DATACOLLECTOR XML: sendind sensors data"));
#endif

				while (wifly.gets(buf, sizeof(buf)) > 0) {
				    //Skip rest of request
				}

                // discard rest of input
		    	// wifly.flushRx();		
				sendSensorsDataXML();

	    	} else {

	       		// Unexpected request
#ifdef DEBUG
				Serial.print(F("Unexpected: "));
				Serial.println(buf);
				Serial.println(F("Sending 404"));
#endif
				while (wifly.gets(buf, sizeof(buf)) > 0) {
				    //Skip rest of request
				}

                // discard rest of input
				wifly.flushRx();		
				send404();

	    	}
		}
    }
}
开发者ID:LValentini,项目名称:MathDuino,代码行数:54,代码来源:mathduinosensors.cpp

示例14: connect

int LifegraphAPI::connect (uint8_t uid[], int uidLength) {
  this->hasBody = false;
  this->_headerStart("GET");
  this->_headerPath("tokens");
  wifly.print("/");
  char token[3];
  for (int i = 0; i < uidLength; i++) {
    snprintf(token, 3, "%02x", uid[i]);
    wifly.print(token);
  }
  wifly.print("?namespace=");
  wifly.print(this->ns);
  wifly.print("&key=");
  wifly.print(this->key);
  wifly.print("&secret=");
  wifly.print(this->secret);
  this->_headerEnd();
  return this->request( NULL );
}
开发者ID:dattasaurabh82,项目名称:arduino-lifegraph,代码行数:19,代码来源:Lifegraph.cpp

示例15: sendPong

/** Send an index HTML page with an input box for a username */
void sendPong()
{
    /* Send the header direclty with print */
    wifly.println(F("HTTP/1.1 200 OK"));
    wifly.println(F("Content-Type: text/xml"));
    wifly.println(F("Transfer-Encoding: chunked"));
    wifly.println();

    /* Send the body using the chunked protocol so the client knows when
     * the message is finished.
     * Note: we're not simply doing a close() because in version 2.32
     * firmware the close() does not work for client TCP streams.
     */
    wifly.sendChunkln(F("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"));
	snprintf_P(wbuf, sizeof(wbuf), PSTR("<pong>%s</pong>"), macaddr);
    wifly.sendChunkln(wbuf);

    wifly.sendChunkln();
}
开发者ID:LValentini,项目名称:MathDuino,代码行数:20,代码来源:mathduinosensors.cpp


注:本文中的WiFly类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。