91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

adrduino中怎么利用wido實現聯網

發布時間:2021-08-05 17:40:15 來源:億速云 閱讀:147 作者:Leah 欄目:互聯網科技

本篇文章為大家展示了adrduino中怎么利用wido實現聯網,內容簡明扼要并且容易理解,絕對能使你眼前一亮,通過這篇文章的詳細介紹希望你能有所收獲。

#include <Adafruit_CC3000.h>
#include <ccspi.h>
#include <SPI.h>
#include <string.h>
#include "utility/debug.h"

#define WiDo_IRQ   7
#define WiDo_VBAT  5
#define WiDo_CS    10
Adafruit_CC3000 WiDo = Adafruit_CC3000(WiDo_CS, WiDo_IRQ, WiDo_VBAT,
                                         SPI_CLOCK_DIVIDER); // you can change this clock speed

#define WLAN_SSID       "Tenda_XXXXX"           // cannot be longer than 32 characters!
#define WLAN_PASS       "12345678"

// Security can be WLAN_SEC_UNSEC, WLAN_SEC_WEP, WLAN_SEC_WPA or WLAN_SEC_WPA2
#define WLAN_SECURITY   WLAN_SEC_WPA2
#define TIMEOUT_MS  2000

void setup(){
  
  Serial.begin(115200);
  /* Initialise the module */
  Serial.println(F("\nInitialising the CC3000 ..."));
  if (!WiDo.begin())
  {
    Serial.println(F("Unable to initialise the CC3000! Check your wiring?"));
    while(1);
  }
    
  /* NOTE: Secure connections are not available in 'Tiny' mode!
     By default connectToAP will retry indefinitely, however you can pass an
     optional maximum number of retries (greater than zero) as the fourth parameter.
  */
  
  Serial.println(F("Connecting Router/AP"));
  if (!WiDo.connectToAP(WLAN_SSID, WLAN_PASS, WLAN_SECURITY)) {
    Serial.println(F("Failed!"));
    while(1);
  }
  
  Serial.println(F("Router/AP Connected!"));
  
  /* Wait for DHCP to complete */
  Serial.println(F("Request DHCP"));
  while (!WiDo.checkDHCP())
  {
    delay(100); // ToDo: Insert a DHCP timeout!
  }  
}

void loop(){
  
  static Adafruit_CC3000_Client tcpClient;
  static unsigned long heartRate = millis();
  
  if(!tcpClient.connected()){
    Serial.println("Try to connect the Local Server");
    tcpClient.close();
    
    /* Set the target ip address and connection port */
    uint32_t ip = WiDo.IP2U32(192,168,0,12);
    tcpClient = WiDo.connectTCP(ip, 8080);
    
    if(!tcpClient.connected()){
      Serial.println(F("Couldn't connect to server! Make sure TCP Test Tool is running on the server."));
      while(1);
    }
  }
  else if(millis() - heartRate > 1000){
    heartRate = millis();  // Update time stamp of the microcontroller system
    
    char clientString[30];
    sprintf(clientString, "%s%d%s", "Wido heartRate: ",heartRate/1000," s\r\n");
    
    Serial.println(clientString);
    tcpClient.fastrprintln(clientString);

  }
  
  /* Read data until either the connection is closed, or the timeout is reached. */ 
  unsigned long lastRead = millis();
  while (tcpClient.connected() && (millis() - lastRead < TIMEOUT_MS)) {
    while (tcpClient.available()) {
      char c = tcpClient.read();
      Serial.print(c);
      lastRead = millis();
      
      // Disable sending message for a moment
      heartRate = millis();
    }
  }
}
 

上述內容就是adrduino中怎么利用wido實現聯網,你們學到知識或技能了嗎?如果還想學到更多技能或者豐富自己的知識儲備,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

济南市| 长治市| 景泰县| 兴和县| 深圳市| 梧州市| 巩义市| 呼伦贝尔市| 定陶县| 克什克腾旗| 大同县| 新龙县| 平顺县| 平舆县| 吉隆县| 延寿县| 卫辉市| 黎平县| 乐亭县| 南城县| 青神县| 类乌齐县| 永年县| 金坛市| 巢湖市| 鱼台县| 漾濞| 金塔县| 福海县| 宜良县| 武汉市| 呼玛县| 墨江| 聂拉木县| 京山县| 江西省| 富蕴县| 徐闻县| 同江市| 雷波县| 阿拉善右旗|