forked from cesanta/mongoose-os-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsymbols.json
7592 lines (7592 loc) · 565 KB
/
symbols.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
[
{
"name": "mgos_app_init",
"file": "[mgos_app.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_app.h)",
"doc": "\n```c\nenum mgos_app_init_result mgos_app_init(void);\n```\n> \n> User app init function.\n> A weak stub is provided in `mgos_app_init.c`, which can be overridden.\n> \n> Example of a user-defined init function:\n> ```c\n> #include \"mgos_app.h\"\n> \n> enum mgos_app_init_result mgos_app_init(void) {\n> if (!my_super_duper_hardware_init()) {\n> LOG(LL_ERROR, (\"something went bad\"));\n> return MGOS_APP_INIT_ERROR;\n> }\n> LOG(LL_INFO, (\"my app initialised\"));\n> return MGOS_APP_INIT_SUCCESS;\n> }\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_app_preinit",
"file": "[mgos_app.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_app.h)",
"doc": "\n```c\nvoid mgos_app_preinit(void);\n```\n> \n> An early init hook, for apps that want to take control early\n> in the init process. How early? very, very early. If the platform\n> uses RTOS, it is not running yet. Dynamic memory allocation is not\n> safe. Networking is not running. The only safe thing to do is to\n> communicate to mg_app_init something via global variables or shut\n> down the processor and go (back) to sleep.\n> \n",
"lang": "c"
},
{
"name": "mgos_bitbang_write_bits",
"file": "[mgos_bitbang.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_bitbang.h)",
"doc": "\n```c\nvoid mgos_bitbang_write_bits(int gpio, enum mgos_delay_unit delay_unit, int t0h,\n int t0l, int t1h, int t1l, const uint8_t *data,\n size_t len);\n```\n> \n> Bit bang GPIO pin `gpio`. `len` bytes from `data` are sent to the specified\n> pin bit by bit. Sending each bit consists of a \"high\" and \"low\" phases,\n> length of which is determined by the specified timing parameters.\n> \n> ```\n> +-----+\n> | |\n> -+ +-------\n> \n> tXh tXl\n> ```\n> \n> `t0h` and `t0l` specify timings if the bit being transmitted is 0,\n> `t1h` and `t1l` specify the same for the case where the bit is 1.\n> If any of these is < 0, the corresponding phase is skipped.\n> \n",
"lang": "c"
},
{
"name": "mgos_bitbang_write_bits_js",
"file": "[mgos_bitbang.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_bitbang.h)",
"doc": "\n```c\nvoid mgos_bitbang_write_bits_js(int gpio, enum mgos_delay_unit delay_unit,\n uint32_t t, const uint8_t *data, size_t len);\n```\n> \n> This function is a wrapper for `mgos_bitbang_write_bits()`.\n> It has smaller number of arguments (less than 6) and therefore could be\n> FFI-ed to JavaScript. Essentially, it just packs all time patterns\n> into a single value `t`.\n> \n",
"lang": "c"
},
{
"name": "BitBang.write(pin, delay_unit, t0h, t0l, t1h, t1l, ptr, len)",
"file": "[api_bitbang.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_bitbang.js)",
"doc": "\n```javascript\nBitBang.write(pin, delay_unit, t0h, t0l, t1h, t1l, ptr, len)\n```\nWrite bits to a given `pin`. `delay_unit` is one of the:\n`BitBang.DELAY_MSEC`, `BitBang.DELAY_USEC`, `BitBang.DELAY_100NSEC`.\n`ptr, len` is a bit pattern to write. `t0h, t0l` is the time pattern\nfor zero bit, `t1h, t1l` is the time pattern for 1. The time pattern\nspecifies the number of time units to hold the pin high, and the number\nof units to hold the pin low. Return value: none.\n",
"lang": "js"
},
{
"name": "mgos_debug_write",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nvoid mgos_debug_write(int fd, const void *buf, size_t len);\n```\n> \n> Write debug info `buf`, `len` to the given file descriptor `fd`.\n> \n",
"lang": "c"
},
{
"name": "mgos_debug_flush",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nvoid mgos_debug_flush(void);\n```\n> \n> Flush debug UARTs, both stdout and stderr.\n> \n",
"lang": "c"
},
{
"name": "mgos_set_stdout_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nenum mgos_init_result mgos_set_stdout_uart(int uart_no);\n```\n> Set UART for stdout. Negative value disables stdout. \n",
"lang": "c"
},
{
"name": "mgos_set_stderr_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nenum mgos_init_result mgos_set_stderr_uart(int uart_no);\n```\n> Set UART for stderr. Negative value disables stderr. \n",
"lang": "c"
},
{
"name": "mgos_get_stdout_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nint mgos_get_stdout_uart(void);\n```\n> Get stdout UART number; -1 indicates that stdout is disabled. \n",
"lang": "c"
},
{
"name": "mgos_get_stderr_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nint mgos_get_stderr_uart(void);\n```\n> Get stderr UART number; -1 indicates that stderr is disabled. \n",
"lang": "c"
},
{
"name": "mgos_debug_suspend_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nvoid mgos_debug_suspend_uart(void);\n```\n> \n> Suspend UART output (both stdout and stderr); see\n> `mgos_debug_resume_uart()`. Nested suspension is supported: UART needs to be\n> resumed as many times as it was suspended.\n> \n",
"lang": "c"
},
{
"name": "mgos_debug_resume_uart",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nvoid mgos_debug_resume_uart(void);\n```\n> \n> Resume previously suspended UART output, see `mgos_debug_suspend_uart()`.\n> \n",
"lang": "c"
},
{
"name": "mgos_debug_uart_is_suspended",
"file": "[mgos_debug.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_debug.h)",
"doc": "\n```c\nbool mgos_debug_uart_is_suspended(void);\n```\n> \n> Returns whether UART output is suspended at the moment.\n> \n",
"lang": "c"
},
{
"name": "Log.print(level, msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.print(level, msg)\n```\nPrint message to stderr if provided\nlevel is >= `Cfg.get('debug.level')`. Possible levels are:\n- `Log.ERROR` (0)\n- `Log.WARN` (1)\n- `Log.INFO` (2)\n- `Log.DEBUG` (3)\n- `Log.VERBOSE_DEBUG` (4)\n",
"lang": "js"
},
{
"name": "Log.error(msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.error(msg)\n```\nShortcut for `Log.print(Log.ERROR, msg)`\n",
"lang": "js"
},
{
"name": "Log.warn(msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.warn(msg)\n```\nShortcut for `Log.print(Log.WARN, msg)`\n",
"lang": "js"
},
{
"name": "Log.info(msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.info(msg)\n```\nShortcut for `Log.print(Log.INFO, msg)`\n",
"lang": "js"
},
{
"name": "Log.debug(msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.debug(msg)\n```\nShortcut for `Log.print(Log.DEBUG, msg)`\n",
"lang": "js"
},
{
"name": "Log.verboseDebug(msg)",
"file": "[api_log.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_log.js)",
"doc": "\n```javascript\nLog.verboseDebug(msg)\n```\nShortcut for `Log.print(Log.VERBOSE_DEBUG, msg)`\n",
"lang": "js"
},
{
"name": "MGOS_EVENT_BASE",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\n#define MGOS_EVENT_BASE(a, b, c) ((a) << 24 | (b) << 16 | (c) << 8)\n```\n> \n> Macro to generate unique base event number.\n> A library can use the last byte (LSB) to create up to 256 unique\n> events (see enum below on how Mongoose OS core defines its events).\n> A library should call mgos_event_register_base() in order to claim\n> it and prevent event number conflicts.\n> \n",
"lang": "c"
},
{
"name": "MGOS_EVENT_BASE",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\n#define MGOS_EVENT_SYS MGOS_EVENT_BASE('M', 'O', 'S')\n```\n> \n> These events are registered by the MGOS core.\n> Other events could be registered by the external libraries.\n> \n",
"lang": "c"
},
{
"name": "mgos_event_register_base",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\nbool mgos_event_register_base(int base_event_number, const char *name);\n```\n> \n> Register a base event number in order to prevent event number conflicts.\n> Use `MGOS_EVENT_BASE()` macro to get `base_event_number`; `name` is an\n> arbitrary name of the module who registers the base number.\n> \n> Example:\n> ```c\n> #define MY_EVENT_BASE MGOS_EVENT_BASE('F', 'O', 'O')\n> \n> enum my_event {\n> MY_EVENT_AAA = MY_EVENT_BASE,\n> MY_EVENT_BBB,\n> MY_EVENT_CCC,\n> };\n> \n> // And somewhere else:\n> mgos_event_register_base(MY_EVENT_BASE, \"my module foo\");\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_event_trigger",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\nint mgos_event_trigger(int ev, void *ev_data);\n```\n> Trigger an event `ev` with the event data `ev_data`. Return number of event\n> handlers invoked. \n",
"lang": "c"
},
{
"name": "(*mgos_event_handler_t)",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\ntypedef void (*mgos_event_handler_t)(int ev, void *ev_data, void *userdata);\n```\n> Event handler signature. \n",
"lang": "c"
},
{
"name": "mgos_event_add_handler",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\nbool mgos_event_add_handler(int ev, mgos_event_handler_t cb, void *userdata);\n```\n> \n> Add an event handler. Return true on success, false on error (e.g. OOM).\n> \n> Example:\n> ```c\n> static void system_restart_cb(int ev, void *ev_data, void *userdata) {\n> LOG(LL_INFO, (\"Going to reboot!\"));\n> (void) ev;\n> (void) ev_data;\n> (void) userdata;\n> }\n> \n> // And somewhere else:\n> mgos_event_add_handler(MGOS_EVENT_REBOOT, system_restart_cb, NULL);\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_event_add_group_handler",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\nbool mgos_event_add_group_handler(int evgrp, mgos_event_handler_t cb,\n void *userdata);\n```\n> \n> Like `mgos_event_add_handler()`, but subscribes on all events in the given\n> group `evgrp`. Event group includes all events from `evgrp & ~0xff` to\n> `evgrp | 0xff`.\n> \n> Example:\n> ```c\n> static void sys_event_cb(int ev, void *ev_data, void *userdata) {\n> LOG(LL_INFO, (\"Got system event %d\", ev));\n> (void) ev;\n> (void) ev_data;\n> (void) userdata;\n> }\n> \n> // And somewhere else:\n> mgos_event_add_handler(MGOS_EVENT_SYS, sys_event_cb, NULL);\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_event_remove_handler",
"file": "[mgos_event.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_event.h)",
"doc": "\n```c\nbool mgos_event_remove_handler(int ev, mgos_event_handler_t cb, void *userdata);\nbool mgos_event_remove_group_handler(int evgrp, mgos_event_handler_t cb,\n void *userdata);\n```\n> \n> Remove an event handler.\n> Both cb and userdata must match the initial add invocation.\n> Returns true if a handler was found and removed, false if there was no\n> such handler in the first place.\n> \n",
"lang": "c"
},
{
"name": "Event.addHandler(ev, callback, userdata)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.addHandler(ev, callback, userdata)\n```\nAdd a handler for the given event `ev`. Callback should look like:\n\nfunction(ev, evdata, userdata) { /* ... */ }\n\nExample:\n```javascript\n\nEvent.addHandler(Event.REBOOT, function(ev, evdata, ud) {\n print(\"Going to reboot!\");\n}, null);\n```\n",
"lang": "js"
},
{
"name": "Event.addGroupHandler(evgrp, callback, userdata)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.addGroupHandler(evgrp, callback, userdata)\n```\nLike `Event.addHandler()`, but subscribes on all events in the given\nevent group `evgrp`. Event group includes all events from `evgrp & ~0xff`\nto `evgrp | 0xff`.\n\nExample:\n```javascript\n\nEvent.addGroupHandler(Event.SYS, function(ev, evdata, ud) {\n print(\"Sys event:\", ev);\n}, null);\n```\n",
"lang": "js"
},
{
"name": "Event.on(event_num, callback, userdata)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.on(event_num, callback, userdata)\n```\nAlias for Event.addHandler\n",
"lang": "js"
},
{
"name": "Event.regBase(base_event_number, name)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.regBase(base_event_number, name)\n```\nRegister a base event number in order to prevent event number conflicts.\nUse `Event.baseNumber(id)` to get `base_event_number`; `name` is an\narbitrary event name.\n\nExample:\n```javascript\nlet bn = Event.baseNumber(\"ABC\");\nif (!Event.regBase(bn, \"My module\")) {\n die(\"Failed to register base event number\");\n}\n\nlet MY_EVENT_FOO = bn + 0;\nlet MY_EVENT_BAR = bn + 1;\nlet MY_EVENT_BAZ = bn + 2;\n```\n",
"lang": "js"
},
{
"name": "Event.baseNumber(id)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.baseNumber(id)\n```\nGenerates unique base event number (32-bit) by a 3-char string.\nLSB is always zero, and a library can use it to create up to 256 unique\nevents.\n\nA library should call `Event.regBase()` in order to claim\nit and prevent event number conflicts. (see example there)\n",
"lang": "js"
},
{
"name": "Event.trigger(ev, evdata)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.trigger(ev, evdata)\n```\nTrigger an event with the given id `ev` and event data `evdata`.\n",
"lang": "js"
},
{
"name": "Event.evdataLogStr(evdata)",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.evdataLogStr(evdata)\n```\nGetter function for the `evdata` given to the event callback for the event\n`Event.LOG`, see `Event.addHandler()`.\n",
"lang": "js"
},
{
"name": "Event.LOG",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.LOG\n```\nSystem event which is triggered every time something is printed to the\nlog. In the callback, use `Event.evdataLogStr(evdata)` to get string\nwhich was printed.\n",
"lang": "js"
},
{
"name": "Event.REBOOT",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.REBOOT\n```\nSystem event which is triggered right before going to reboot. `evdata`\nis irrelevant for this event.\n",
"lang": "js"
},
{
"name": "Event.OTA_STATUS",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.OTA_STATUS\n```\nSystem event which is triggered when OTA status changes.\n\nIn the callback, use `OTA.evdataOtaStatusMsg(evdata)` from `api_ota.js` to\nget the OTA status message.\n",
"lang": "js"
},
{
"name": "Event.CLOUD_CONNECTED",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.CLOUD_CONNECTED\n```\nTriggered when device is connected to the cloud (mqtt, dash)\n",
"lang": "js"
},
{
"name": "Event.CLOUD_DISCONNECTED",
"file": "[api_events.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_events.js)",
"doc": "\n```javascript\nEvent.CLOUD_DISCONNECTED\n```\nTriggered when device is disconnected from the cloud\n",
"lang": "js"
},
{
"name": "mgos_file_copy",
"file": "[mgos_file_utils.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_file_utils.h)",
"doc": "\n```c\nbool mgos_file_copy(const char *from, const char *to);\n```\n> Copy a file \n",
"lang": "c"
},
{
"name": "mgos_file_digest",
"file": "[mgos_file_utils.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_file_utils.h)",
"doc": "\n```c\nbool mgos_file_digest(const char *fname, mbedtls_md_type_t dt, uint8_t *digest);\n```\n> Compute file's digest. *digest must have enough space for the digest type. \n",
"lang": "c"
},
{
"name": "mgos_file_copy_if_different",
"file": "[mgos_file_utils.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_file_utils.h)",
"doc": "\n```c\nbool mgos_file_copy_if_different(const char *from, const char *to);\n```\n> Copy the file if target does not exist or is different. \n",
"lang": "c"
},
{
"name": "(*mgos_gpio_int_handler_f)",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\ntypedef void (*mgos_gpio_int_handler_f)(int pin, void *arg);\n```\n> GPIO interrupt handler signature. \n",
"lang": "c"
},
{
"name": "mgos_gpio_set_mode",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_set_mode(int pin, enum mgos_gpio_mode mode);\n```\n> Set mode - input or output. \n",
"lang": "c"
},
{
"name": "mgos_gpio_set_pull",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_set_pull(int pin, enum mgos_gpio_pull_type pull);\n```\n> Set pull-up or pull-down type. \n",
"lang": "c"
},
{
"name": "mgos_gpio_setup_input",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_setup_input(int pin, enum mgos_gpio_pull_type pull);\n```\n> Sets up a pin as an input and confiures pull-up or pull-down. \n",
"lang": "c"
},
{
"name": "mgos_gpio_setup_output",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_setup_output(int pin, bool level);\n```\n> \n> Sets up pin output while avoiding spurious transitions:\n> desired output level is configured first, then mode.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_read",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_read(int pin);\n```\n> Read pin input level. \n",
"lang": "c"
},
{
"name": "mgos_gpio_write",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nvoid mgos_gpio_write(int pin, bool level);\n```\n> Set pin's output level. \n",
"lang": "c"
},
{
"name": "mgos_gpio_toggle",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_toggle(int pin);\n```\n> Flip output pin value. Returns value that was written. \n",
"lang": "c"
},
{
"name": "mgos_gpio_read_out",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_read_out(int pin);\n```\n> Read the value of the output register. \n",
"lang": "c"
},
{
"name": "mgos_gpio_set_int_handler",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_set_int_handler(int pin, enum mgos_gpio_int_mode mode,\n mgos_gpio_int_handler_f cb, void *arg);\n```\n> \n> Install a GPIO interrupt handler.\n> \n> This will invoke handler on the main task, which makes it possible to use\n> any functions but may delay servicing of the interrupt. If lower latency\n> is required, use `mgos_gpio_set_int_handler_isr`, but you'll need to\n> understand the implications, which are platform-specific.\n> \n> Interrupt is automatically cleared once upon triggering.\n> Then it is disabled until the handler gets a chance to run, at which point\n> it is re-enabled. At this point it may re-trigger immediately if the\n> interrupt condition arose again while the handler was pending or running.\n> Handler may use `mgos_gpio_clear_int` to explicitly clear the condition.\n> \n> Note that this will not enable the interrupt, this must be done explicitly\n> with `mgos_gpio_enable_int()`.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_set_int_handler_isr",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_set_int_handler_isr(int pin, enum mgos_gpio_int_mode mode,\n mgos_gpio_int_handler_f cb, void *arg);\n```\n> \n> Same as mgos_gpio_set_int_handler but invokes handler in ISR context,\n> without the overhead of a context switch. GPIO interrupts are disabled while\n> the handler is running.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_enable_int",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_enable_int(int pin);\n```\n> Enable interrupt on the specified pin. \n",
"lang": "c"
},
{
"name": "mgos_gpio_disable_int",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_disable_int(int pin);\n```\n> Disables interrupt (without removing the handler). \n",
"lang": "c"
},
{
"name": "mgos_gpio_clear_int",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nvoid mgos_gpio_clear_int(int pin);\n```\n> Clears a GPIO interrupt flag. \n",
"lang": "c"
},
{
"name": "mgos_gpio_remove_int_handler",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nvoid mgos_gpio_remove_int_handler(int pin, mgos_gpio_int_handler_f *old_cb,\n void **old_arg);\n```\n> \n> Removes a previosuly set interrupt handler.\n> \n> If `cb` and `arg` are not NULL, they will contain previous handler and arg.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_set_button_handler",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_set_button_handler(int pin, enum mgos_gpio_pull_type pull_type,\n enum mgos_gpio_int_mode int_mode,\n int debounce_ms, mgos_gpio_int_handler_f cb,\n void *arg);\n```\n> \n> Handle a button on the specified pin.\n> \n> Configures the pin for input with specified pull-up and performs debouncing:\n> upon first triggering user's callback is invoked immediately but further\n> interrupts are inhibited for the following debounce_ms millseconds.\n> \n> Typically 50 ms of debouncing time is sufficient.\n> int_mode is one of the `MGOS_GPIO_INT_EDGE_*` values and will specify whether\n> the handler triggers when button is pressed, released or both.\n> Which is which depends on how the button is wired: if the normal state is\n> pull-up (typical), then `MGOS_GPIO_INT_EDGE_NEG` is press and\n> `_POS` is release.\n> \n> Calling with `cb` = NULL will remove a previously installed handler.\n> \n> Note: implicitly enables the interrupt.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_blink",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nbool mgos_gpio_blink(int pin, int on_ms, int off_ms);\n```\n> \n> A utility function that takes care of blinking an LED.\n> The pin must be configured as output first.\n> On (output \"1\") and off (\"0\") times are specified in milliseconds.\n> Set to (0, 0) to disable.\n> \n",
"lang": "c"
},
{
"name": "mgos_gpio_str",
"file": "[mgos_gpio.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_gpio.h)",
"doc": "\n```c\nconst char *mgos_gpio_str(int pin_def, char buf[8]);\n```\n> String representation of pin number.\n> Will return \"PA5\" or \"PK3\" for platforms that have port banks. \n",
"lang": "c"
},
{
"name": "GPIO.set_mode(pin, mode)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.set_mode(pin, mode)\n```\nSet GPIO pin mode.\n`mode` can be either `GPIO.MODE_INPUT` or `GPIO.MODE_OUTPUT`.\n",
"lang": "js"
},
{
"name": "GPIO.set_pull(pin, pull_type)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.set_pull(pin, pull_type)\n```\nSet GPIO pin pull type.\n`pull_type` can be either `GPIO.PULL_NONE`, `GPIO.PULL_UP`, or\n`GPIO.PULL_DOWN`.\n",
"lang": "js"
},
{
"name": "GPIO.setup_input(pin, pull_type)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.setup_input(pin, pull_type)\n```\nSetup pin as input and configure pull type.\n`pull_type` can be either `GPIO.PULL_NONE`, `GPIO.PULL_UP`, or\n`GPIO.PULL_DOWN`.\n",
"lang": "js"
},
{
"name": "GPIO.setup_output(pin, level)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.setup_output(pin, level)\n```\nSetup pin as output and set initial level, 0 or 1.\nAvoids spurious transitions: applies level first, then sets mode.\n",
"lang": "js"
},
{
"name": "GPIO.toggle(pin)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.toggle(pin)\n```\nToggle the level of certain GPIO pin.\nReturn value: 0 or 1, indicating the resulting pin level.\n",
"lang": "js"
},
{
"name": "GPIO.write(pin, level)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.write(pin, level)\n```\nSet GPIO pin level to either 0 or 1. Return value: none.\n",
"lang": "js"
},
{
"name": "GPIO.read(pin)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.read(pin)\n```\nRead GPIO pin level. Return value: 0 or 1.\n",
"lang": "js"
},
{
"name": "GPIO.enable_int(pin)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.enable_int(pin)\n```\nEnable interrupts on GPIO pin.\nThis function must be called AFTER the interrupt handler is installed.\nReturn value: 1 in case of success, 0 otherwise.\n",
"lang": "js"
},
{
"name": "GPIO.disable_int(pin)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.disable_int(pin)\n```\nDisable interrupts on GPIO pin.\nReturn value: 1 in case of success, 0 otherwise.\n",
"lang": "js"
},
{
"name": "GPIO.blink(pin, on_ms, off_ms)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.blink(pin, on_ms, off_ms)\n```\nA utility function that takes care of blinking an LED.\nThe pin must be configured as output first.\nOn (output \"1\") and off (\"0\") times are specified in milliseconds.\nSet to (0, 0) to disable.\nReturn value: 1 on success, 0 on failure.\n",
"lang": "js"
},
{
"name": "GPIO.set_int_handler(pin, mode, handler)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.set_int_handler(pin, mode, handler)\n```\nInstall GPIO interrupt handler. `mode` could be one of: `GPIO.INT_NONE`,\n`GPIO.INT_EDGE_POS`, `GPIO.INT_EDGE_NEG`, `GPIO.INT_EDGE_ANY`,\n`GPIO.INT_LEVEL_HI`, `GPIO.INT_LEVEL_LO`.\nReturn value: 1 in case of success, 0 otherwise.\nExample:\n```javascript\nGPIO.set_mode(pin, GPIO.MODE_INPUT);\nGPIO.set_int_handler(pin, GPIO.INT_EDGE_NEG, function(pin) {\n print('Pin', pin, 'got interrupt');\n}, null);\nGPIO.enable_int(pin);\n```\n",
"lang": "js"
},
{
"name": "GPIO.set_button_handler(pin, pull, intmode, period, handler)",
"file": "[api_gpio.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_gpio.js)",
"doc": "\n```javascript\nGPIO.set_button_handler(pin, pull, intmode, period, handler)\n```\nInstall\nGPIO button handler. `pull` is pull type, `intmode` is interrupt mode,\n`period` is debounce interval in milliseconds, handler is a function that\nreceives pin number.\nReturn value: 1 in case of success, 0 otherwise.\nExample:\n```javascript\nGPIO.set_button_handler(pin, GPIO.PULL_UP, GPIO.INT_EDGE_NEG, 200,\nfunction(x) {\n print('Button press, pin: ', x);\n}, null);\n```\n",
"lang": "js"
},
{
"name": "_IRAM_STR_LIT",
"file": "[mgos_iram.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_iram.h)",
"doc": "\n```c\n#define _IRAM_STR_LIT(a) #a\n#define _IRAM_STR(a) _IRAM_STR_LIT(a)\n```\n> \n> Provides the IRAM macro that creates unique sections under .text\n> so that unused functions can be GC'd.\n> \n",
"lang": "c"
},
{
"name": "MGOS_EVENT_BASE",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\n#define MGOS_EVENT_GRP_NET MGOS_EVENT_BASE('N', 'E', 'T')\n```\n> \n> Event group which should be given to `mgos_event_add_group_handler()`\n> in order to subscribe to network events.\n> \n> Example:\n> ```c\n> static void my_net_ev_handler(int ev, void *evd, void *arg) {\n> if (ev == MGOS_NET_EV_IP_ACQUIRED) {\n> LOG(LL_INFO, (\"Just got IP!\"));\n> // Fetch something very useful from somewhere\n> }\n> (void) evd;\n> (void) arg;\n> }\n> \n> // Somewhere else:\n> mgos_event_add_group_handler(MGOS_EVENT_GRP_NET, my_net_ev_handler, NULL);\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_net_get_ip_info",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\nbool mgos_net_get_ip_info(enum mgos_net_if_type if_type, int if_instance,\n struct mgos_net_ip_info *ip_info);\n```\n> \n> Retrieve IP configuration of the provided interface type and instance\n> number, and fill provided `ip_info` with it. Returns `true` in case of\n> success, false otherwise.\n> \n",
"lang": "c"
},
{
"name": "mgos_net_ip_to_str",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\nchar *mgos_net_ip_to_str(const struct sockaddr_in *sin, char *out);\n```\n> \n> Converts address to dotted-quad NUL-terminated string.\n> `out` must be at least 16 bytes long.\n> Returns the out pointer.\n> \n",
"lang": "c"
},
{
"name": "mgos_net_str_to_ip",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\nbool mgos_net_str_to_ip(const char *ips, struct sockaddr_in *sin);\n```\n> \n> Parses dotted-quad NUL-terminated string into an IPv4 address.\n> \n",
"lang": "c"
},
{
"name": "mgos_net_str_to_ip_n",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\nbool mgos_net_str_to_ip_n(const struct mg_str ips, struct sockaddr_in *sin);\n```\n> \n> Parses dotted-quad NUL-terminated string into an IPv4 address.\n> \n",
"lang": "c"
},
{
"name": "mgos_get_nameserver",
"file": "[mgos_net.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_net.h)",
"doc": "\n```c\nchar *mgos_get_nameserver(void);\n```\n> \n> Returns nameserver address. The caller should `free()` it. Returns NULL\n> in case of no DNS.\n> \n",
"lang": "c"
},
{
"name": "Net.ctos(conn, local, ip, port)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.ctos(conn, local, ip, port)\n```\nConvert address of a connection `conn` to string. Set `local` to\n`true` to stringify local address, otherwise `false` to stringify remote.\nSet `ip` to `true` to stringify IP, `port` to stringify port. Example:\n```javascript\nprint('Connection from:', Net.ctos(conn, false, true, true));\n```\n",
"lang": "js"
},
{
"name": "Net.discard(conn, len)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.discard(conn, len)\n```\nRemove initial `len` bytes of data from the connection's `conn`\nreceive buffer in order to discard that data and reclaim RAM to the system.\n",
"lang": "js"
},
{
"name": "Net.serve(options)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.serve(options)\n```\nStart TCP or UDP server. `options` is an object:\n```javascript\n{\n // Required. Port to listen on, 'tcp://PORT' or `udp://PORT`.\n addr: 'tcp://1234',\n // Optional. Called when connection is established.\n onconnect: function(conn) {}, \n // Optional. Called when new data is arrived.\n ondata: function(conn, data) {},\n // Optional. Called when protocol-specific event is triggered.\n onevent: function(conn, data, ev, edata) {},\n // Optional. Called when the connection is about to close.\n onclose: function(conn) {},\n // Optional. Called when on connection error.\n onerror: function(conn) {},\n}\n```\nExample - a UDP echo server. Change `udp://` to `tcp://` to turn this\nexample into the TCP echo server:\n```javascript\nNet.serve({\n addr: 'udp://1234',\n ondata: function(conn, data) {\n print('Received from:', Net.ctos(conn, false, true, true), ':', data);\n Net.send(conn, data); // Echo received data back\n Net.discard(conn, data.length); // Discard received data\n },\n});\n```\n",
"lang": "js"
},
{
"name": "Net.connect(options)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.connect(options)\n```\nConnect to a remote host. `options` is the same as for the `Net.serve`.\nThe addr format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or\n`udp`. `HOST` could be an IP address or a host name. If `HOST` is a name,\nit will be resolved asynchronously.\n\nExamples of valid addresses: `google.com:80`, `udp://1.2.3.4:53`,\n`10.0.0.1:443`, `[::1]:80`.\n",
"lang": "js"
},
{
"name": "Net.close(conn)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.close(conn)\n```\nSend all pending data to the remote peer,\nand disconnect when all data is sent.\nReturn value: none.\n",
"lang": "js"
},
{
"name": "Net.send(conn, data)",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.send(conn, data)\n```\nSend data to the remote peer. `data` is an mJS string.\nReturn value: none.\n",
"lang": "js"
},
{
"name": "Net.EVENT_GRP",
"file": "[api_net.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_net.js)",
"doc": "\n```javascript\nNet.EVENT_GRP\n```\nNet events group, to be used with `Event.addGroupHandler()`. Possible\nevents are:\n- `Net.STATUS_DISCONNECTED`\n- `Net.STATUS_CONNECTING`\n- `Net.STATUS_CONNECTED`\n- `Net.STATUS_GOT_IP`\n",
"lang": "js"
},
{
"name": "mgos_sys_config_save",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_sys_config_save(const struct mgos_config *cfg, bool try_once,\n char **msg);\n```\n> \n> Save config. Performs diff against defaults and only saves diffs.\n> Reboot is required to reload the config.\n> If try_once is set, the config will only take effect for one boot.\n> \n> If return value is false, a message may be provided in *msg.\n> If non-NULL, it must be free()d.\n> It is safe to pass a NULL `msg`\n> \n",
"lang": "c"
},
{
"name": "mgos_sys_config_save_level",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_sys_config_save_level(const struct mgos_config *cfg,\n enum mgos_config_level level, bool try_once,\n char **msg);\n```\n> Saves given coonfig at the specified level. Performs diff against level-1. \n",
"lang": "c"
},
{
"name": "mgos_sys_config_load_level",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_sys_config_load_level(struct mgos_config *cfg,\n enum mgos_config_level level);\n```\n> Loads config up to and including level. \n",
"lang": "c"
},
{
"name": "save_cfg",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool save_cfg(const struct mgos_config *cfg, char **msg);\n```\n> Deprecated API, equivalent to mgos_sys_config_save(cfg, false, msg). \n",
"lang": "c"
},
{
"name": "load_config_defaults",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool load_config_defaults(struct mgos_config *cfg);\n```\n> Loads configs up to MGOS_CONFIG_LEVEL_USER - 1. Deprecated. \n",
"lang": "c"
},
{
"name": "mgos_config_reset",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nvoid mgos_config_reset(int level);\n```\n> \n> Reset config down to and including |level|.\n> 0 - defaults, 1-8 - vendor levels, 9 - user.\n> mgos_config_reset(MGOS_CONFIG_LEVEL_USER) will wipe user settings.\n> \n",
"lang": "c"
},
{
"name": "(*mgos_config_validator_fn)",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\ntypedef bool (*mgos_config_validator_fn)(const struct mgos_config *cfg,\n char **msg);\nvoid mgos_sys_config_register_validator(mgos_config_validator_fn fn);\n```\n> \n> Register a config validator.\n> Validators will be invoked before saving config and if any of them\n> returns false, config will not be saved.\n> An error message may be *msg may be set to error message.\n> Note: if non-NULL, *msg will be freed. Remember to use strdup and asprintf.\n> \n",
"lang": "c"
},
{
"name": "mgos_config_validate",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_config_validate(const struct mgos_config *cfg, char **msg);\n```\n> Run validators on the specified config. \n",
"lang": "c"
},
{
"name": "mgos_expand_mac_address_placeholders",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nvoid mgos_expand_mac_address_placeholders(char *str);\n```\n> Expands question marks in \"str\" with digits from the MAC address. \n",
"lang": "c"
},
{
"name": "mgos_config_apply",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_config_apply(const char *sys_config_subset_json, bool save);\n```\n> Apply a subset of system configuration. Return true on success. \n",
"lang": "c"
},
{
"name": "mgos_config_apply_s",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_config_apply_s(const struct mg_str, bool save);\n```\n> Same as mgos_config_apply but uses mg_str \n",
"lang": "c"
},
{
"name": "mgos_sys_config_parse_sub",
"file": "[mgos_sys_config.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_sys_config.h)",
"doc": "\n```c\nbool mgos_sys_config_parse_sub(const struct mg_str json, const char *section,\n void *cfg);\n```\n> \n> Parse a subsection of sys config, e.g. just \"spi\".\n> cfg must point to the subsection's struct.\n> Example:\n> ```\n> struct mgos_config_spi cfg;\n> const struct mg_str json_cfg = MG_MK_STR(\"{\\\"unit_no\\\": 1}\");\n> memset(&cfg, 0, sizeof(cfg));\n> mgos_sys_config_parse_sub(json_cfg, \"spi\", cfg);\n> ```\n> \n",
"lang": "c"
},
{
"name": "Cfg.get(path)",
"file": "[api_config.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_config.js)",
"doc": "\n```javascript\nCfg.get(path)\n```\nGet the config value by the configuration variable. Currently, only\nsimple types are returned: strings, ints, booleans, doubles. Objects\nare not yet supported.\n\nExamples:\n```javascript\nload('api_config.js');\nCfg.get('device.id'); // returns a string\nCfg.get('debug.level'); // returns an integer\nCfg.get('wifi.sta.enable'); // returns a boolean\n```\n",
"lang": "js"
},
{
"name": "Cfg.set(obj, opt_save)",
"file": "[api_config.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_config.js)",
"doc": "\n```javascript\nCfg.set(obj, opt_save)\n```\nSet the configuration. `obj` must be a subset of the whole configuation\ntree. `save` is boolean flag that indicating whether the change should\nbe saved - it could be omitted, in which case it defaults to `true`.\nExamples:\n```javascript\nload('api_config.js');\nCfg.set({wifi: {ap: {enable: false}}}); // Disable WiFi AP mode\nCfg.set({debug: {level: 3}}); // Set debug level to 3\n```\n",
"lang": "js"
},
{
"name": "mgos_get_heap_size",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_heap_size(void);\n```\n> Get system memory size. \n",
"lang": "c"
},
{
"name": "mgos_get_free_heap_size",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_free_heap_size(void);\n```\n> Get system free memory. \n",
"lang": "c"
},
{
"name": "mgos_get_min_free_heap_size",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_min_free_heap_size(void);\n```\n> Get minimal watermark of the system free memory. \n",
"lang": "c"
},
{
"name": "mgos_get_fs_memory_usage",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_fs_memory_usage(void);\n```\n> Get filesystem memory usage \n",
"lang": "c"
},
{
"name": "mgos_get_fs_size",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_fs_size(void);\n```\n> \n> Get filesystem size.\n> Deprecated, please use mgos_vfs_get_space_total(\"/\") instead.\n> \n",
"lang": "c"
},
{
"name": "mgos_get_free_fs_size",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nsize_t mgos_get_free_fs_size(void);\n```\n> \n> Get filesystem free space.\n> Deprecated, please use mgos_vfs_get_space_free(\"/\") instead.\n> \n",
"lang": "c"
},
{
"name": "mgos_fs_gc",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_fs_gc(void);\n```\n> Garbage-collect filesystem \n",
"lang": "c"
},
{
"name": "mgos_wdt_feed",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_wdt_feed(void);\n```\n> Feed watchdog \n",
"lang": "c"
},
{
"name": "mgos_wdt_set_timeout",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_wdt_set_timeout(int secs);\n```\n> Set watchdog timeout\n",
"lang": "c"
},
{
"name": "mgos_wdt_enable",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_wdt_enable(void);\n```\n> Enable watchdog \n",
"lang": "c"
},
{
"name": "mgos_wdt_disable",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_wdt_disable(void);\n```\n> Disable watchdog \n",
"lang": "c"
},
{
"name": "mgos_system_restart",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_system_restart(void) __attribute__((noreturn));\n```\n> Restart system \n",
"lang": "c"
},
{
"name": "mgos_msleep",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_msleep(uint32_t msecs);\n```\n> Delay given number of milliseconds \n",
"lang": "c"
},
{
"name": "mgos_usleep",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_usleep(uint32_t usecs);\n```\n> Delay given number of microseconds \n",
"lang": "c"
},
{
"name": "mgos_ints_disable",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_ints_disable(void);\n```\n> Disable interrupts \n",
"lang": "c"
},
{
"name": "mgos_ints_enable",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_ints_enable(void);\n```\n> Enable interrupts \n",
"lang": "c"
},
{
"name": "(*mgos_cb_t)",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\ntypedef void (*mgos_cb_t)(void *arg);\n```\n> Callback for `mgos_invoke_cb()` \n",
"lang": "c"
},
{
"name": "mgos_invoke_cb",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nbool mgos_invoke_cb(mgos_cb_t cb, void *arg, bool from_isr);\n```\n> \n> Invoke a callback in the main MGOS event loop.\n> Returns true if the callback has been scheduled for execution.\n> \n",
"lang": "c"
},
{
"name": "mgos_get_cpu_freq",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nuint32_t mgos_get_cpu_freq(void);\n```\n> Get the CPU frequency in Hz \n",
"lang": "c"
},
{
"name": "mgos_rlock_create",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nstruct mgos_rlock_type *mgos_rlock_create(void);\n```\n> Create a recursive lock. \n",
"lang": "c"
},
{
"name": "mgos_rlock",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_rlock(struct mgos_rlock_type *l);\n```\n> Acquire a recursive lock. \n",
"lang": "c"
},
{
"name": "mgos_runlock",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_runlock(struct mgos_rlock_type *l);\n```\n> Release a recursive lock. \n",
"lang": "c"
},
{
"name": "mgos_rlock_destroy",
"file": "[mgos_system.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_system.h)",
"doc": "\n```c\nvoid mgos_rlock_destroy(struct mgos_rlock_type *l);\n```\n> Destroy a recursive lock. \n",
"lang": "c"
},
{
"name": "Sys._sbuf(len)",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys._sbuf(len)\n```\nHelper function to allocate string of at least given length. Note that\nthe resulting string is usually bigger than this, and it is always\nlonger than 5 bytes; that's to guarantee that the string data is stored in\na common buffer and not inlined into mjs_val_t, thus the buffer can be\nused as an \"output\" buffer: a string can be passed to some function which\nwill alter the contents, and these changes will be visible to the caller.\n",
"lang": "js"
},
{
"name": "Sys.calloc(nmemb, size)",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.calloc(nmemb, size)\n```\nAllocate a memory region.\nNote: currently memory allocated this way must be explicitly released with\n`free()`.\n",
"lang": "js"
},
{
"name": "Sys.total_ram()",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.total_ram()\n```\nReturn total available RAM in bytes.\n",
"lang": "js"
},
{
"name": "Sys.free_ram()",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.free_ram()\n```\nReturn free available RAM in bytes.\n",
"lang": "js"
},
{
"name": "Sys.reboot(ms)",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.reboot(ms)\n```\nReboot the system after `ms` milliseconds. Return value: none.\n",
"lang": "js"
},
{
"name": "Sys.uptime()",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.uptime()\n```\nReturn number of seconds since last reboot.\n",
"lang": "js"
},
{
"name": "Sys.usleep(microseconds)",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.usleep(microseconds)\n```\nSleep given number of microseconds.\nReturn value: none.\n",
"lang": "js"
},
{
"name": "Sys.wdt_feed()",
"file": "[api_sys.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_sys.js)",
"doc": "\n```javascript\nSys.wdt_feed()\n```\nFeed the watchdog timer.\nReturn value: none.\n",
"lang": "js"
},
{
"name": "mgos_uptime",
"file": "[mgos_time.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_time.h)",
"doc": "\n```c\ndouble mgos_uptime(void);\n```\n> Get number of seconds since last reboot \n",
"lang": "c"
},
{
"name": "mgos_uptime_micros",
"file": "[mgos_time.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_time.h)",
"doc": "\n```c\nint64_t mgos_uptime_micros(void);\n```\n> Get number of microseconds since last reboot \n",
"lang": "c"
},
{
"name": "mgos_strftime",
"file": "[mgos_time.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_time.h)",
"doc": "\n```c\nint mgos_strftime(char *s, int size, char *fmt, int time);\n```\n> \n> Format `time` according to a `strftime()`-conformant format.\n> Write the result into the `s,size` buffer. Return resulting string length.\n> \n",
"lang": "c"
},
{
"name": "mgos_settimeofday",
"file": "[mgos_time.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_time.h)",
"doc": "\n```c\nint mgos_settimeofday(double time, struct timezone *tz);\n```\n> \n> Like standard `settimeofday()`, but uses `double` seconds value instead of\n> `struct timeval *tv`. If time was changed successfully, emits an event\n> `MGOS_EVENT_TIME_CHANGED`.\n> \n",
"lang": "c"
},
{
"name": "(*timer_callback)",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\ntypedef void (*timer_callback)(void *param);\n```\n> Timer callback \n",
"lang": "c"
},
{
"name": "mgos_set_timer",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\nmgos_timer_id mgos_set_timer(int msecs, int flags, timer_callback cb,\n void *cb_arg);\n```\n> \n> Setup a timer with `msecs` timeout and `cb` as a callback.\n> \n> `flags` is a bitmask, currently there's only one flag available:\n> `MGOS_TIMER_REPEAT` (see above). `arg` is a parameter to pass to `cb`.\n> Return numeric timer ID.\n> \n> Note that this is a software timer, with fairly low accuracy and high jitter.\n> However, number of software timers is not limited.\n> If you need intervals < 10ms, use mgos_set_hw_timer.\n> \n> Example:\n> ```c\n> static void my_timer_cb(void *arg) {\n> bool val = mgos_gpio_toggle(mgos_sys_config_get_pins_led());\n> LOG(LL_INFO, (\"uptime: %.2lf\", mgos_uptime()));\n> (void) arg;\n> }\n> \n> enum mgos_app_init_result mgos_app_init(void) {\n> mgos_set_timer(1000, MGOS_TIMER_REPEAT, my_timer_cb, NULL);\n> return MGOS_APP_INIT_SUCCESS;\n> }\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_set_hw_timer",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\nmgos_timer_id mgos_set_hw_timer(int usecs, int flags, timer_callback cb,\n void *cb_arg);\n```\n> \n> Setup a hardware timer with `usecs` timeout and `cb` as a callback.\n> \n> This is similar to mgos_set_timer, but can be used for shorter intervals\n> (note that time unit is microseconds).\n> \n> Number of hardware timers is limited (ESP8266: 1, ESP32: 4, CC32xx: 4).\n> \n> Callback is executed in ISR context, with all the implications of that.\n> \n",
"lang": "c"
},
{
"name": "mgos_clear_timer",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\nvoid mgos_clear_timer(mgos_timer_id id);\n```\n> \n> Disable timer with a given timer ID.\n> \n",
"lang": "c"
},
{
"name": "mgos_uptime",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\ndouble mgos_uptime(void);\n```\n> Get number of seconds since last reboot \n",
"lang": "c"
},
{
"name": "mgos_strftime",
"file": "[mgos_timers.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_timers.h)",
"doc": "\n```c\nint mgos_strftime(char *s, int size, char *fmt, int time);\n```\n> \n> Format `time` according to a `strftime()`-conformant format.\n> Write the result into the `s,size` buffer. Return resulting string length.\n> \n",
"lang": "c"
},
{
"name": "Timer.set(milliseconds, flags, handler, userdata)",
"file": "[api_timer.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_timer.js)",
"doc": "\n```javascript\nTimer.set(milliseconds, flags, handler, userdata)\n```\nSetup timer with `milliseconds` timeout and `handler` as a callback.\n`flags` can be either 0 or `Timer.REPEAT`. In the latter case, the call\nwill be repeated indefinitely (but can be cancelled with `Timer.del()`),\notherwise it's a one-off.\n\nReturn value: numeric timer ID.\n\nExample:\n```javascript\n// Call every second\nTimer.set(1000, Timer.REPEAT, function() {\n let value = GPIO.toggle(2);\n print(value ? 'Tick' : 'Tock');\n}, null);\n```\n",
"lang": "js"
},
{
"name": "Timer.now()",
"file": "[api_timer.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_timer.js)",
"doc": "\n```javascript\nTimer.now()\n```\nReturn current time as double value, UNIX epoch (seconds since 1970).\n",
"lang": "js"
},
{
"name": "Timer.del(id)",
"file": "[api_timer.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_timer.js)",
"doc": "\n```javascript\nTimer.del(id)\n```\nCancel previously installed timer.\n",
"lang": "js"
},
{
"name": "Timer.fmt(fmt, time)",
"file": "[api_timer.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_timer.js)",
"doc": "\n```javascript\nTimer.fmt(fmt, time)\n```\nFormats the time 'time' according to the strftime-like format\nspecification 'fmt'. The strftime reference can be found e.g.\n[here](http://www.cplusplus.com/reference/ctime/strftime/).\nExample:\n```javascript\nlet now = Timer.now();\nlet s = Timer.fmt(\"Now it's %I:%M%p.\", now);\nprint(s); // Example output: \"Now it's 12:01AM.\"\n```\n",
"lang": "js"
},
{
"name": "mgos_uart_configure",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nbool mgos_uart_configure(int uart_no, const struct mgos_uart_config *cfg);\n```\n> \n> Apply given UART configuration.\n> \n> Example:\n> ```c\n> int uart_no = 0;\n> \n> struct mgos_uart_config ucfg;\n> mgos_uart_config_set_defaults(uart_no, &ucfg);\n> \n> ucfg.baud_rate = 115200;\n> ucfg.rx_buf_size = 1500;\n> ucfg.tx_buf_size = 1500;\n> \n> if (!mgos_uart_configure(uart_no, &ucfg)) {\n> LOG(LL_ERROR, (\"Failed to configure UART%d\", uart_no));\n> }\n> ```\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_config_set_defaults",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nvoid mgos_uart_config_set_defaults(int uart_no, struct mgos_uart_config *cfg);\n```\n> \n> Fill provided `cfg` structure with the default values. See example above.\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_config_get",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nbool mgos_uart_config_get(int uart_no, struct mgos_uart_config *cfg);\n```\n> \n> Fill provided `cfg` structure with the current UART config.\n> Returns false if the specified UART has not bee configured yet.\n> \n",
"lang": "c"
},
{
"name": "(*mgos_uart_dispatcher_t)",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\ntypedef void (*mgos_uart_dispatcher_t)(int uart_no, void *arg);\n```\n> UART dispatcher signature, see `mgos_uart_set_dispatcher()` \n",
"lang": "c"
},
{
"name": "mgos_uart_set_dispatcher",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nvoid mgos_uart_set_dispatcher(int uart_no, mgos_uart_dispatcher_t cb,\n void *arg);\n```\n> \n> Set UART dispatcher: a callback which gets called when there is data in the\n> input buffer or space available in the output buffer.\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_write",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nsize_t mgos_uart_write(int uart_no, const void *buf, size_t len);\n```\n> \n> Write data to the UART.\n> Note: if there is enough space in the output buffer, the call will return\n> immediately, otherwise it will wait for buffer to drain.\n> If you want the call to not block, check mgos_uart_write_avail() first.\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_write_avail",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nsize_t mgos_uart_write_avail(int uart_no);\n```\n> Returns amount of space availabe in the output buffer. \n",
"lang": "c"
},
{
"name": "mgos_uart_printf",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nint mgos_uart_printf(int uart_no, const char *fmt, ...);\n```\n> \n> Write data to UART, printf style.\n> Note: currently this requires that data is fully rendered in memory before\n> sending. There is no fixed limit as heap allocation is used, but be careful\n> when printing longer strings.\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_read",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nsize_t mgos_uart_read(int uart_no, void *buf, size_t len);\n```\n> \n> Read data from UART input buffer.\n> Note: unlike write, read will not block if there are not enough bytes in the\n> input buffer.\n> \n",
"lang": "c"
},
{
"name": "mgos_uart_read_mbuf",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nsize_t mgos_uart_read_mbuf(int uart_no, struct mbuf *mb, size_t len);\n```\n> Like `mgos_uart_read`, but reads into an mbuf. \n",
"lang": "c"
},
{
"name": "mgos_uart_read_avail",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nsize_t mgos_uart_read_avail(int uart_no);\n```\n> Returns the number of bytes available for reading. \n",
"lang": "c"
},
{
"name": "mgos_uart_set_rx_enabled",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nvoid mgos_uart_set_rx_enabled(int uart_no, bool enabled);\n```\n> Controls whether UART receiver is enabled. \n",
"lang": "c"
},
{
"name": "mgos_uart_is_rx_enabled",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nbool mgos_uart_is_rx_enabled(int uart_no);\n```\n> Returns whether UART receiver is enabled. \n",
"lang": "c"
},
{
"name": "mgos_uart_flush",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nvoid mgos_uart_flush(int uart_no);\n```\n> Flush the UART output buffer - waits for data to be sent. \n",
"lang": "c"
},
{
"name": "mgos_uart_schedule_dispatcher",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nvoid mgos_uart_schedule_dispatcher(int uart_no, bool from_isr);\n```\n> Schedule a call to dispatcher on the next `mongoose_poll` \n",
"lang": "c"
},
{
"name": "mgos_uart_get_stats",
"file": "[mgos_uart.h](https://github.com/cesanta/mongoose-os/blob/master/include/mgos_uart.h)",
"doc": "\n```c\nconst struct mgos_uart_stats *mgos_uart_get_stats(int uart_no);\n```\n> Get UART statistics \n",
"lang": "c"
},
{
"name": "UART.setConfig(uartNo, param)",
"file": "[api_uart.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_uart.js)",
"doc": "\n```javascript\nUART.setConfig(uartNo, param)\n```\nSet UART config. `param` is an\nobject with the following optional fields:\n\n- `baudRate`: baud rate, integer, default: 115200;\n- `numDataBits`: Number of data bits, default: 8;\n- `parity`: Parity: 0 - none, 1 - even, 2 - odd; default: none;\n- `numStopBits`: Number of stop bits: 1 - 1 bit, 2 - 2 bits, 3 - 1.5; default: 1;\n- `rxBufSize`: size of the Rx buffer, integer, default: 256;\n- `rxFlowControl`: whether Rx flow control (RTS pin) is enabled, boolean,\n default: false;\n- `rxLingerMicros`: how many microseconds to linger after Rx fifo\n is empty, in case more data arrives. Integer, default: 15;\n- `txBufSize`: size of the Tx buffer, integer, default: 256;\n- `txFlowControl`: whether Tx flow control (CTS pin) is enabled, boolean,\n default: false;\n\nOther than that, there are architecture-dependent settings, grouped in\nthe objects named with the architecture name: \"esp32\", \"esp8266\", etc.\n\nSettings for esp32:\n\n```\n esp32: {\n /*\n * GPIO pin numbers, default values depend on UART.\n *\n * UART 0: Rx: 3, Tx: 1, CTS: 19, RTS: 22\n * UART 1: Rx: 13, Tx: 14, CTS: 15, RTS: 16\n * UART 2: Rx: 17, Tx: 25, CTS: 26, RTS: 27\n */\n gpio: {\n rx: number,\n tx: number,\n cts: number,\n rts: number,\n },\n\n /* Hardware FIFO tweaks */\n fifo: {\n /*\n * A number of bytes in the hardware Rx fifo, should be between 1 and 127.\n * How full hardware Rx fifo should be before \"rx fifo full\" interrupt is\n * fired.\n */\n rxFullThresh: number,\n\n /*\n * A number of bytes in the hardware Rx fifo, should be more than\n * rx_fifo_full_thresh.\n *\n * How full hardware Rx fifo should be before CTS is deasserted, telling\n * the other side to stop sending data.\n */\n rxFcThresh: number,\n\n /*\n * Time in uart bit intervals when \"rx fifo full\" interrupt fires even if\n * it's not full enough\n */\n rxAlarm: number,\n\n /*\n * A number of bytes in the hardware Tx fifo, should be between 1 and 127.\n * When the number of bytes in Tx buffer becomes less than\n * tx_fifo_empty_thresh, \"tx fifo empty\" interrupt fires.\n */\n txEmptyThresh: number,\n },\n }\n```\n",
"lang": "js"
},
{
"name": "UART.setDispatcher(uartNo, callback, userdata)",
"file": "[api_uart.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_uart.js)",
"doc": "\n```javascript\nUART.setDispatcher(uartNo, callback, userdata)\n```\nSet UART dispatcher\ncallback which gets invoked when there is a new data in the input buffer\nor when the space becomes available on the output buffer.\n\nCallback receives the following arguments: `(uartNo, userdata)`.\n",
"lang": "js"
},
{
"name": "UART.write(uartNo, data)",
"file": "[api_uart.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_uart.js)",
"doc": "\n```javascript\nUART.write(uartNo, data)\n```\nWrite data to the buffer. Returns number of bytes written.\n\nExample usage: `UART.write(1, \"foobar\")`, in this case, 6 bytes will be written.\n",
"lang": "js"
},
{
"name": "UART.writeAvail(uartNo)",
"file": "[api_uart.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_uart.js)",
"doc": "\n```javascript\nUART.writeAvail(uartNo)\n```\nReturn amount of space available in the output buffer.\n",
"lang": "js"
},
{
"name": "UART.read(uartNo)",
"file": "[api_uart.js](https://github.com/mongoose-os-libs/mjs/blob/master/fs/api_uart.js)",