Skip to content

Commit 0deb715

Browse files
committed
Leave mos only
1 parent 8a7c027 commit 0deb715

File tree

9 files changed

+48
-105
lines changed

9 files changed

+48
-105
lines changed

Makefile

+16-36
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,25 @@
1+
API = mongoose-os/api
2+
CATEGORIES ?= core cloud net drivers arduino rpc misc
3+
DEV ?= ../cesanta.com
4+
INC ?= ../mongoose-os/include
5+
HTMLDIR ?= ../website-miot/front/docs
6+
7+
.PHONY: sidebar.html $(API)/core $(API)
8+
9+
110
all: sidebar.html # apps
211

3-
APPSMD = quickstart/apps.md
4-
TMP = /tmp/.tmp.mos.yml
5-
apps:
6-
curl -s https://api.github.com/orgs/mongoose-os-apps/repos?per_page=200 |\
7-
perl -nle 'print $$1 if /"full_name": "(.*)"/' > /tmp/repos.txt
8-
echo '# Example apps' > $(APPSMD)
9-
echo '| GitHub repo | Description | Author |' >> $(APPSMD)
10-
echo '| ---- | ----------- | --- |' >> $(APPSMD)
11-
sort /tmp/repos.txt | while read REPO ; do \
12-
curl -s https://raw.githubusercontent.com/$$REPO/master/mos.yml > $(TMP); \
13-
echo $$REPO ; \
14-
echo "| [$${REPO#*/}](https://github.com/$$REPO) | $$(cat $(TMP) | perl -nle 'print $$1 if /^description: (.*)/') | $$(cat $(TMP) | perl -nle 'print $$1 if /^author: (.*)/') | " >> $(APPSMD) ;\
15-
done
12+
list:
13+
curl -s https://api.github.com/orgs/mongoose-os-libs/repos?per_page=200 |\
14+
perl -nle 'print $$1 if /"full_name": "(.*)"/' > $@.txt
1615

17-
API = mongoose-os/api
18-
.PHONY: sidebar.html $(API)/core $(API)
16+
sync: list
17+
@for REPO in $$(cat list.txt) ; do test -d $$REPO && (cd $$REPO && git pull) || (mkdir -p $$(dirname $$REPO) ; cd $$(dirname $$REPO); git clone [email protected]:$$REPO.git); done
1918

20-
CATEGORIES ?= core cloud net drivers arduino rpc misc
2119
clean-generated:
2220
@for C in $(CATEGORIES) ; do rm -rf $(API)/$$C; mkdir $(API)/$$C; touch $(API)/$$C/index.md ; done
2321

2422

25-
LIBS ?= /tmp/libs
26-
LIBSINDEX ?= /tmp/libs.txt
27-
DEV ?= ../cesanta.com
28-
INC ?= ../mongoose-os/include
29-
3023
$(API)/core: clean-generated
3124
@echo '[]' > symbols.json
3225
@(cd $(INC) && ls *.h) | while read F; do node tools/genapi.js $@/$$F.md cesanta/mongoose-os $(INC)/$$F >> $@/index.md; done
@@ -36,17 +29,8 @@ $(API)/core: clean-generated
3629
@node tools/genapi.js $@/mg_str.h.md cesanta/mongoose-os $(DEV)/common/mg_str.h >> $@/index.md
3730

3831
$(API):
39-
@test -f $(LIBSINDEX) || curl -s https://api.github.com/orgs/mongoose-os-libs/repos?per_page=200 | perl -nle 'print $$1 if /"full_name": "(.*)"/' | sort > $(LIBSINDEX)
40-
@mkdir -p $(LIBS)
41-
@cat $(LIBSINDEX) | while read REPO ; \
42-
do echo $$REPO; \
43-
BR=$$(basename $$REPO); \
44-
if test -d $(DEV)/mos_libs/$$BR; then \
45-
R=$(DEV)/mos_libs/$$BR; \
46-
else \
47-
R=$(LIBS)/$$BR; \
48-
test -d $$R && (cd $$R && git pull --quiet) || git clone --quiet https://github.com/$$REPO $$R; \
49-
fi; \
32+
@for REPO in mongoose-os-libs/* ; do \
33+
echo $$REPO; BR=$$(basename $$REPO); R=$$REPO; \
5034
CATEGORY=$$(perl -ne 'print $$1 if /docs:(.+?):(.+?)/' $$R/mos.yml); \
5135
test -z "$$CATEGORY" && CATEGORY=misc && echo " github.com/$$REPO is missing docs:tag!"; \
5236
TITLE=$$(perl -ne 'print $$2 if /docs:(.+?):(.+?)\s*$$/' $$R/mos.yml); \
@@ -64,11 +48,7 @@ sidebar.html: $(API)/core $(API)
6448
@node tools/gensidebar.js > $@
6549

6650

67-
HTMLDIR ?= ../website-miot/front/docs
6851
html:
6952
rm -rf $(HTMLDIR)/*
7053
@node tools/genhtml.js "$(HTMLDIR)" $$(find . -name \*.md)
7154
cp sidebar.html $(HTMLDIR)/
72-
73-
clean:
74-
rm -rf $(LIBS) $(LIBSINDEX)

index.md

-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
- [Mongoose OS](mongoose-os)
2-
- [CCM communication module](ccm)
3-
- [Kiwi BLE gateway](kiwi)
4-
- [UART gateway](uart-gateway)
52

63

mongoose-os/api/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
- [Networking](net)
44
- [Drivers](drivers)
55
- [Arduino compat](arduino)
6-
- [RPC remote management](rpc)
6+
- [RPC](rpc)
77
- [Misc](misc)

mongoose-os/api/net/mqtt.md

+19-10
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ bool mgos_mqtt_global_connect(void);
136136
> Normally MQTT will try to connect in the background, at certain interval.
137137
> This function will force immediate connection attempt.
138138
>
139+
#### mgos_mqtt_global_disconnect
140+
141+
```c
142+
void mgos_mqtt_global_disconnect(void);
143+
```
144+
>
145+
> Disconnect from and/or stop trying to connect to MQTT server
146+
> until mgos_mqtt_global_connect() is called.
147+
>
139148
#### mgos_mqtt_global_is_connected
140149
141150
```c
@@ -145,23 +154,23 @@ bool mgos_mqtt_global_is_connected(void);
145154
#### mgos_mqtt_pub
146155

147156
```c
148-
bool mgos_mqtt_pub(const char *topic, const void *message, size_t len, int qos,
149-
bool retain);
157+
uint16_t mgos_mqtt_pub(const char *topic, const void *message, size_t len,
158+
int qos, bool retain);
150159
```
151160
>
152161
> Publish message to the configured MQTT server, to the given MQTT topic.
153-
> Return value will be true if there is a connection to the server and the
154-
> message has been queued for sending. In case of QoS 1 return value does
155-
> not indicate that PUBACK has been received; there is currently no way to
156-
> check for that.
162+
> Return value will be the packet id (> 0) if there is a connection to the
163+
> server and the message has been queued for sending. In case no connection is
164+
> available, 0 is returned. In case of QoS 1 return value does not indicate
165+
> that PUBACK has been received; there is currently no way to check for that.
157166
>
158167
#### mgos_mqtt_pubf
159168
160169
```c
161-
bool mgos_mqtt_pubf(const char *topic, int qos, bool retain,
162-
const char *json_fmt, ...);
163-
bool mgos_mqtt_pubv(const char *topic, int qos, bool retain,
164-
const char *json_fmt, va_list ap);
170+
uint16_t mgos_mqtt_pubf(const char *topic, int qos, bool retain,
171+
const char *json_fmt, ...);
172+
uint16_t mgos_mqtt_pubv(const char *topic, int qos, bool retain,
173+
const char *json_fmt, va_list ap);
165174
```
166175
> Variant of mgos_mqtt_pub for publishing a JSON-formatted string
167176
#### (*sub_handler_t)

mongoose-os/api/rpc/rpc-gatts.md

-29
Original file line numberDiff line numberDiff line change
@@ -25,33 +25,4 @@ Three attributes are defined:
2525
- `5f6d4f53-5f52-5043-5f72-785f63746c5f (_mOS_RPC_rx_ctl_)` - a read/notify attribute. It returns the length of the frame that device wishes to transmit as a big-endian 32-bit number. If this value is not zero, frame data will be returned in response to read requests of the data attribute. Read chunks will be up to MTU bytes in size. Client may subscribe to notifications on this attribute. Notification will be sent whenever a new frame is submitted for delivery and the notification body will contain length (the same value as returned by reading). Upon receiving notification client can proceed to read the data without reading `rx_ctl` again.
2626

2727

28-
## Lightning How To
29-
30-
- Add `- origin: https://github.com/mongoose-os-libs/rpc-gatts` to your mos.yml libs
31-
- For this example we'll be doing a wifi.scan as that's very handy! Add `- origin: https://github.com/mongoose-os-libs/rpc-service-wifi` to your mos.yml libs as well.
32-
- Ensure your mos.yml config.schema has:
33-
```
34-
- ["bt.enable", "b", true, {title: "Enable the BT service"}]
35-
- ["bt.keep_enabled", "b", true, {title: "Keep the BT service enabled despite WIFI being up"}]
36-
- ["bt.random_address", "b", false, {title: "Use a consistent BT MAC address"}]
37-
- ["bt.dev_name", "MyDeviceName_??????"]
38-
```
39-
- Rebuild/flash your app
40-
- Run a BLE scanner (ie Bluesee) to see your MyDeviceName_????? device. Connect to see the services. Look for the one with 5f52-5043 in the middle.
41-
- Select that service to open it. In Bluesee you'll have 3 characteristics per above docu.
42-
- Figure out your RPC command, we'll use: `{"id":1999,"method":"Wifi.Scan"}`
43-
- We need to tell the service ahead of time how many hex bytes we'll be sending. We need to convert ascii to hex, trim the extra spaces and then count the bytes. Fun!
44-
- Enter your RPC command into this ascii to hex converter: https://www.rapidtables.com/convert/number/ascii-to-hex.html
45-
- It'll give you a space separated hex output: `7b 22 69 64 22 3a 31 39 39 39 2c 22 6d 65 74 68 6f 64 22 3a 22 57 69 66 69 2e 53 63 61 6e 22 7d`
46-
- Trim the spaces with http://www.unit-conversion.info/texttools/replace-text/
47-
- Count the new hex string with: https://mothereff.in/byte-counter
48-
- Halve the string count, as two hex characters equal one byte of data. With the text above, 64 / 2 = 32.
49-
- Convert 32 to the large 32 bit number the system is expecting. Note: It's little endian, not big endian. Use this converter: https://www.scadacore.com/tools/programming-calculators/online-hex-converter/ . Put the 32 in the input, then copy/paste the 'UINT32 - Little Endian (DCBA)' result and trim spaces:00000020
50-
- Enter that `00000020` into the write only characteristic that has `5043-5F74` in the middle. Press write. In the console you'll see a log entry like: `mgos_rpc_channel_ga:296 0x3ffe1d24 expected_flen 32 res 0`
51-
- On the middle read only characteristic with `5043-5F72` in the middle, click subscribe. The number will change to let us know when data is available (and how long the hex string is)
52-
- On the read/write characteristic with `5043-5F53` in the middle, toggle the hex button so it says Ascii
53-
- Paste in our ascii command: `{"id":1999,"method":"Wifi.Scan"}`
54-
- You'll see the middle read only characteristic will have changed to let us know data is ready
55-
- Click 'read' on the top read/write characteristic we just entered the scan command into. It'll start pulling the data of the scan results! You can click it multiple times to scroll through the data till the end.
56-
- You can repeat the request by clicking the write only characteristic to send it our command length, then paste our command again, and click write.
5728
-----

sidebar.html

+1-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
<ul class="tree" style="">
2-
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>Mongoose OS</b>
3-
<ul class="tree" style="display:none;">
42
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>Quick Start</b>
53
<ul class="tree" style="display:none;">
64
<li><a href="/docs/mongoose-os/quickstart/setup.md">Quick Start</a></li>
@@ -148,7 +146,7 @@
148146
<li><a href="/docs/mongoose-os/api/arduino/arduino-wire.md">Wire</a></li>
149147
</ul>
150148
</div>
151-
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>RPC remote management</b>
149+
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>RPC</b>
152150
<ul class="tree" style="display:none;">
153151
<li><a href="/docs/mongoose-os/api/rpc/rpc-common.md">RPC core</a></li>
154152
<li><a href="/docs/mongoose-os/api/rpc/rpc-loopback.md">RPC loopback</a></li>
@@ -190,21 +188,3 @@
190188
</ul>
191189
</div>
192190
</ul>
193-
</div>
194-
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>CCM communication module</b>
195-
<ul class="tree" style="display:none;">
196-
<li><a href="/docs/ccm/intro.md">User guide</a></li>
197-
<li><a href="/docs/ccm/licensing.md">Licensing</a></li>
198-
</ul>
199-
</div>
200-
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>Kiwi BLE gateway</b>
201-
<ul class="tree" style="display:none;">
202-
<li><a href="/docs/kiwi/intro.md">User guide</a></li>
203-
</ul>
204-
</div>
205-
<div class="tree-toggler"><i class="fa fa-fw fa-caret-right"></i>&nbsp;<b>UART gateway</b>
206-
<ul class="tree" style="display:none;">
207-
<li><a href="/docs/uart-gateway/intro.md">User guide</a></li>
208-
</ul>
209-
</div>
210-
</ul>

symbols.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -5567,6 +5567,12 @@
55675567
"doc": "\n```c\nbool mgos_mqtt_global_connect(void);\n```\n> \n> Attempt MQTT connection now (if enabled and not already connected).\n> Normally MQTT will try to connect in the background, at certain interval.\n> This function will force immediate connection attempt.\n> \n",
55685568
"lang": "c"
55695569
},
5570+
{
5571+
"name": "mgos_mqtt_global_disconnect",
5572+
"file": "[mgos_mqtt.h](https://github.com/mongoose-os-libs/mqtt/tree/master/include/mgos_mqtt.h)",
5573+
"doc": "\n```c\nvoid mgos_mqtt_global_disconnect(void);\n```\n> \n> Disconnect from and/or stop trying to connect to MQTT server\n> until mgos_mqtt_global_connect() is called.\n> \n",
5574+
"lang": "c"
5575+
},
55705576
{
55715577
"name": "mgos_mqtt_global_is_connected",
55725578
"file": "[mgos_mqtt.h](https://github.com/mongoose-os-libs/mqtt/tree/master/include/mgos_mqtt.h)",
@@ -5576,13 +5582,13 @@
55765582
{
55775583
"name": "mgos_mqtt_pub",
55785584
"file": "[mgos_mqtt.h](https://github.com/mongoose-os-libs/mqtt/tree/master/include/mgos_mqtt.h)",
5579-
"doc": "\n```c\nbool mgos_mqtt_pub(const char *topic, const void *message, size_t len, int qos,\n bool retain);\n```\n> \n> Publish message to the configured MQTT server, to the given MQTT topic.\n> Return value will be true if there is a connection to the server and the\n> message has been queued for sending. In case of QoS 1 return value does\n> not indicate that PUBACK has been received; there is currently no way to\n> check for that.\n> \n",
5585+
"doc": "\n```c\nuint16_t mgos_mqtt_pub(const char *topic, const void *message, size_t len,\n int qos, bool retain);\n```\n> \n> Publish message to the configured MQTT server, to the given MQTT topic.\n> Return value will be the packet id (> 0) if there is a connection to the\n> server and the message has been queued for sending. In case no connection is\n> available, 0 is returned. In case of QoS 1 return value does not indicate\n> that PUBACK has been received; there is currently no way to check for that.\n> \n",
55805586
"lang": "c"
55815587
},
55825588
{
55835589
"name": "mgos_mqtt_pubf",
55845590
"file": "[mgos_mqtt.h](https://github.com/mongoose-os-libs/mqtt/tree/master/include/mgos_mqtt.h)",
5585-
"doc": "\n```c\nbool mgos_mqtt_pubf(const char *topic, int qos, bool retain,\n const char *json_fmt, ...);\nbool mgos_mqtt_pubv(const char *topic, int qos, bool retain,\n const char *json_fmt, va_list ap);\n```\n> Variant of mgos_mqtt_pub for publishing a JSON-formatted string \n",
5591+
"doc": "\n```c\nuint16_t mgos_mqtt_pubf(const char *topic, int qos, bool retain,\n const char *json_fmt, ...);\nuint16_t mgos_mqtt_pubv(const char *topic, int qos, bool retain,\n const char *json_fmt, va_list ap);\n```\n> Variant of mgos_mqtt_pub for publishing a JSON-formatted string \n",
55865592
"lang": "c"
55875593
},
55885594
{

tools/genapi.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if (repoName == 'cesanta/mongoose-os') {
8484
const jsBase = jsmap[hBase];
8585
if (jsBase) {
8686
jsLink = `[${jsBase}](${mjsURL}/tree/master/fs/${jsBase})`;
87-
jsFile = `/tmp/libs/mjs/fs/${jsBase}`;
87+
jsFile = `mongoose-os-libs/mjs/fs/${jsBase}`;
8888
}
8989
} else if (repoName == 'cesanta/frozen') {
9090
const cBase = hBase.replace(/.h$/, '.c');

tools/gensidebar.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const f = (dir, depth) => {
88
md.split('\n').forEach((line) => {
99
const m = line.match(/\[(.+)\]\((.+)\)/);
1010
if (!m) return;
11-
const link = dir.replace(/^./, '/docs');
11+
const link = '/docs/' + dir; // dir.replace(/^./, '/docs');
1212
if (m[2].match(/.md$/)) {
1313
a.push(`<li><a href="${link}/${m[2]}">${m[1]}</a></li>`);
1414
} else {
@@ -22,4 +22,4 @@ const f = (dir, depth) => {
2222
a.push('</ul>');
2323
return a;
2424
};
25-
console.log(f('.', 0, '').join('\n'));
25+
console.log(f('mongoose-os', 0, '').join('\n'));

0 commit comments

Comments
 (0)