Skip to content

Commit 44127f6

Browse files
committed
Release v1.0.0
0 parents  commit 44127f6

File tree

6 files changed

+437
-0
lines changed

6 files changed

+437
-0
lines changed

.gitignore

Whitespace-only changes.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 yuuu
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# mruby-esp32-mqtt
2+
3+
MQTT library for mruby-esp32.
4+
5+
## Installation
6+
7+
You need [esp-idf v5.0](https://docs.espressif.com/projects/esp-idf/en/release-v5.0/esp32/index.html) to use this mrbgems.
8+
9+
Add the line below to your `build_config.rb`:
10+
11+
```ruby
12+
conf.gem :github => 'yuuu/mruby-esp32-mqtt'
13+
```
14+
15+
In addition, you may need to add `mqtt` to the component linking mruby.
16+
17+
```cmake
18+
idf_component_register(
19+
# ...
20+
REQUIRES esp_wifi esp_hw_support esp_rom mqtt # <- add
21+
)
22+
23+
add_prebuilt_library(
24+
# ...
25+
PRIV_REQUIRES esp_wifi esp_hw_support esp_rom mqtt # <- add
26+
)
27+
```
28+
29+
## Examples
30+
31+
Connect MQTT.
32+
33+
```ruby
34+
mqtt = ESP32::MQTT::Client.new('test.mosquitto.org', 1883)
35+
mqtt.connect
36+
```
37+
38+
Connect MQTT + TLS.
39+
40+
```ruby
41+
mqtt = ESP32::MQTT::Client.new('test.mosquitto.org', 8883)
42+
mqtt.ssl = true
43+
mqtt.ca = IO.read('root-ca.pem')
44+
mqtt.cert = IO.read('certificate.pem.crt')
45+
mqtt.key = IO.read('private.pem.key')
46+
mqtt.connect
47+
```
48+
49+
Publish message to topic.
50+
51+
```ruby
52+
mqtt.publish("topic", 'message')
53+
```
54+
55+
Subscribe to topic and get message.
56+
57+
```ruby
58+
mqtt.subscribe("topic")
59+
topic, message = mqtt.get
60+
```
61+
62+
Disconnect.
63+
64+
```ruby
65+
mqtt.disconnect
66+
```
67+
68+
## LICENSE
69+
70+
MIT License.

mrbgem.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
MRuby::Gem::Specification.new('mruby-esp32-mqtt') do |spec|
2+
spec.license = 'MIT'
3+
spec.author = 'yuuu'
4+
spec.summary = 'MQTT class on ESP32'
5+
end

mrblib/mrb_esp32_mqtt.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
module ESP32
2+
module MQTT
3+
class Client
4+
attr_accessor :ca, :cert, :key
5+
end
6+
end
7+
end

0 commit comments

Comments
 (0)