Skip to content

Commit 738ff8f

Browse files
authored
Merge pull request #40 from tomvictor/hotfix/v0.0.14
version update
2 parents 11e87b2 + 2739ce2 commit 738ff8f

File tree

17 files changed

+1242
-502
lines changed

17 files changed

+1242
-502
lines changed

Cargo.lock

Lines changed: 225 additions & 340 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,8 @@ rumqttc = "0.22.0"
1414
rumqttd = "0.17.0"
1515
config = "0.13"
1616
bytes = "1"
17-
paho-mqtt = "0.12.1"
1817

1918
[package.metadata.maturin]
2019
name = "iotcore._iotcore"
2120
reqwest = { version = "0.11", features = ["blocking", "json"] }
22-
rumqttc = "0.20.0"
21+
rumqttc = "0.20.0"

README.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ def read_root():
5353
```python
5454
from fastapi import FastAPI
5555
from contextlib import asynccontextmanager
56-
from iotcore import IotCore, IotCoreBroker
56+
from iotcore import IotCore
5757

5858
iot = IotCore()
5959

6060

6161
@asynccontextmanager
6262
async def lifespan(app: FastAPI):
63-
broker = IotCoreBroker("Broker")
64-
broker.run_forever()
6563
iot.background_loop_forever()
6664
yield
6765

@@ -73,6 +71,22 @@ app = FastAPI(lifespan=lifespan)
7371
def read_root():
7472
return {"Hello": "World"}
7573

74+
75+
def mqtt_callback(data):
76+
print(f"iot >: {data}")
77+
78+
79+
@app.get("/sub")
80+
def read_root():
81+
iot.subscribe("iot", mqtt_callback)
82+
return {"response": "subscribed"}
83+
84+
85+
@app.get("/pub")
86+
def read_root():
87+
iot.publish("iot", "test")
88+
return {"response": "published"}
89+
7690
```
7791

7892

docs/index.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,13 @@ def read_root():
5353
```python
5454
from fastapi import FastAPI
5555
from contextlib import asynccontextmanager
56-
from iotcore import IotCore, IotCoreBroker
56+
from iotcore import IotCore
5757

5858
iot = IotCore()
5959

6060

6161
@asynccontextmanager
6262
async def lifespan(app: FastAPI):
63-
broker = IotCoreBroker("Broker")
64-
broker.run_forever()
6563
iot.background_loop_forever()
6664
yield
6765

@@ -73,6 +71,22 @@ app = FastAPI(lifespan=lifespan)
7371
def read_root():
7472
return {"Hello": "World"}
7573

74+
75+
def mqtt_callback(data):
76+
print(f"iot >: {data}")
77+
78+
79+
@app.get("/sub")
80+
def read_root():
81+
iot.subscribe("iot", mqtt_callback)
82+
return {"response": "subscribed"}
83+
84+
85+
@app.get("/pub")
86+
def read_root():
87+
iot.publish("iot", "test")
88+
return {"response": "published"}
89+
7690
```
7791

7892

examples/fastapi/main.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
from fastapi import FastAPI
22
from contextlib import asynccontextmanager
3-
from iotcore import IotCore, IotCoreBroker
3+
from iotcore import IotCore
44

55
iot = IotCore()
66

77

88
@asynccontextmanager
99
async def lifespan(app: FastAPI):
10-
broker = IotCoreBroker("Broker")
11-
broker.run_forever()
1210
iot.background_loop_forever()
1311
yield
1412

@@ -36,8 +34,3 @@ def read_root():
3634
iot.publish("iot", "test")
3735
return {"response": "published"}
3836

39-
40-
@app.get("/reconnect")
41-
def read_root():
42-
iot.reconnect()
43-
return {"response": "ok"}

examples/mqtt_rs/Cargo.lock

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/mqtt_rs/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
paho-mqtt = "0.12.1"
9+
paho-mqtt = "0.12.1"
10+
openssl = { version = "0.10", features = ["vendored"] }
11+
openssl-sys = "0.9.93"

examples/mqtt_rs/src/main.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ use paho_mqtt as mqtt;
44
fn main() {
55
// Initialize the logger from the environment
66
// Create a client & define connect options
7-
let host = env::args()
8-
.nth(1)
9-
.unwrap_or_else(|| "mqtt://0.0.0.0:1883".to_string());
7+
let host = "mqtt://localhost:1883".to_string();
108

119
let mut cli = mqtt::Client::new(host).unwrap_or_else(|e| {
1210
println!("Error creating the client: {:?}", e);

0 commit comments

Comments
 (0)