# 物聯網

## WIFI
```python
from cocopiPython import Networking
```

### 初始化
```python
Networking()
```

### 連接WiFi
```python
wifiContent(WiFiSSID,WiFiPSD)
```

### 参数信息
|参数|值|说明|
|:---|:---|:---|
|WiFiSSID|字串|WiFi名稱，必填|
|WiFiPSD|字串|WiFi密碼，必填|

### WiFi連接狀態
```python
wifiIsContent()
```

### 獲取IP
```python
getWifiIP()
```

### 樣例
```python
from cocopiPython import NetWorking

Networking = NetWorking() # 初始化
Networking.wifiContent("CocoRobo_SZ","cocorobo2019")
while not Networking.wifiIsContent():
    print("wifi連接中...")
print('wifi連接成功!')
print('IP地址：',Networking.getWifiIP())
```

## 天氣預報
```python
from cocopiPython import Weather
```

### 初始化
```python
Weather()
```

### 獲取天氣
```python
getWeather(city,lang='zh-hans')
```

### 參數說明
|参数|值|说明|
|:---|:---|:---|
|city|數字|城市代碼，必填，詳見<a target="_blank" href="https://github.com/qwd/LocationList/blob/master/China-City-List-latest.csv">中國城市代碼參照</a>|
|lang|字串|語言，選填，預設為簡體中文|

### 樣例
```python
from cocopiPython import Weather,NetWorking
# 聯網 
Networking = NetWorking()
Weather = Weather()

Networking.wifiContent("CocoRobo_SZ","cocorobo2019")

while not Networking.wifiIsContent():
    print("wifi連接中...")
print('wifi連接成功！')  

weatherData = Weather.getWeather(101280601,"zh-hans")
print(weatherData)
```

## 郵件發送
```python
from cocopiPython import Email
```

### 初始化
```python
Email()
```

### 發送郵件
```python
send(email,content,title)
```

### 參數說明
|参数|值|说明|
|:---|:---|:---|
|email|字串|要發送的郵箱地址，必填|
|content|字串|郵件內容，必填|
|title|字串|郵件標題，必填|

### 樣例
```python
from cocopiPython import NetWorking,Email

Net = NetWorking()
email = Email()

Net.wifiContent("CocoRobo_SZ","cocorobo2019")

while not Net.wifiIsContent():
    print("wifi連接中...")
print('wifi連接成功！')  
email.send('1101068574@qq.com','who are you?','name')
```

## 雲端服務
```python
from cocopiPython import Cloud
```

### 初始化
```python
Cloud()
```

### 發送
```python
sendData(key,data)
```

### 參數說明
|参数|值|说明|
|:---|:---|:---|
|key|字串|雲端事件的API，必填|
|data|字典|發送的數據，必填，以字典的格式發送，{key:value}|

### 樣例
```python
from cocopiPython import NetWorking,Cloud

Net = NetWorking()
cloud = Cloud()

Net.wifiContent("CocoRobo_SZ","cocorobo2019")

while not Net.wifiIsContent():
    print("wifi連接中...")
print('wifi連接成功！')  

params = {"Property0":666}
cloud.sendData("7219bc312639056e95a42480f9870d9f",params)
time.sleep(2)
```

### 接收 
```python
getData(key,value)
```
### 參數說明
|参数|值|说明|
|:---|:---|:---|
|key|字串|雲端事件的API，必填|
|value|字串|屬性名稱，必填|

### 樣例
```python
from cocopiPython import NetWorking,Cloud

Net = NetWorking()
cloud = Cloud()

Net.wifiContent("CocoRobo_SZ","cocorobo2019")

while not Net.wifiIsContent():
    print("wifi連接中...")
print('wifi連接成功！')  

data_cloud = cloud.getData("7219bc312639056e95a42480f9870d9f",'Property0')
print(data_cloud)
```