/
index.d.ts
4654 lines (4122 loc) · 156 KB
/
index.d.ts
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
// Type definitions for Espruino 1.94
// Project: http://www.espruino.com/
// Definitions by: Stanislav Berkov <https://github.com/stasberkov>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
declare function require(module: string): any;
declare interface process {
env: any;
version: string;
memory(): {
free: number, // Memory that is available to be used (in blocks)
usage: number, // Memory that has been used (in blocks)
total: number, // Total memory (in blocks)
history: number, // Memory used for command history - that is freed if memory is low. Note that this is INCLUDED in the figure for 'free'
gc: number, // Memory freed during the GC pass
gctime: number, // Time taken for GC pass (in milliseconds)
stackEndAddress: number, // (on ARM) the address (that can be used with peek/poke/etc) of the END of the stack. The stack grows down, so unless you do a lot of recursion the bytes above this can be used.
flash_start: number, // (on ARM) the address of the start of flash memory (usually 0x8000000)
flash_binary_end: number, // (on ARM) the address in flash memory of the end of Espruino's firmware.
flash_code_start: number, // (on ARM) the address in flash memory of pages that store any code that you save with save().
flash_length: number, // (on ARM) the amount of flash memory this firmware was built for (in bytes). Note: Some STM32 chips actually have more memory than is advertised.
};
on(event: 'uncaughtException', cb: Function): void;
}
declare var process: process;
declare interface Object {
removeListener(event: string, listener: any): any;
emit(event: string, ...args: Array<any>): void;
on(event: string, callback: Function): void;
}
declare module "Wifi" {
/**
* Connect to an access point as a station. If there is an existing connection to an AP it is first disconnected if the SSID or password are different from those passed as parameters. Put differently, if the passed SSID and password are identical to the currently connected AP then nothing is changed. When the connection attempt completes the callback function is invoked with one err parameter, which is NULL if there is no error and a string message if there is an error. If DHCP is enabled the callback occurs once an IP addres has been obtained, if a static IP is set the callback occurs once the AP's network has been joined. The callback is also invoked if a connection already exists and does not need to be changed.
* The options properties may contain:
* - password - Password string to be used to access the network.
* - dnsServers (array of String) - An array of up to two DNS servers in dotted decimal format string.
* Notes:
* - the options should include the ability to set a static IP and associated netmask and gateway, this is a future enhancement.
* - the only error reported in the callback is "Bad password", all other errors (such as access point not found or DHCP timeout) just cause connection retries. If the reporting of such temporary errors is desired, the caller must use its own timeout and the getDetails().status field.
* - the connect call automatically enabled station mode, it can be disabled again by calling disconnect.
*
* Parameters
* - ssid - The access point network id.
* - options - Connection options (optional).
* - callback - A function to be called back on completion (optional).
*/
function connect(ssid: string, options?: {password: string, dnsServers: string[]}, callback?: (err: any) => any): any;
/**
* The 'connected' event is called when an association with an access point has succeeded, i.e., a connection to the AP's network has been established.
* On ESP32/ESP8266 there is a details parameter which includes:
* - ssid - The SSID of the access point to which the association was established
* - mac - The BSSID/mac address of the access point
* - channel - The wifi channel used (an integer, typ 1..14)
*/
function on(event: 'associated', callback: (details: { ssid: string, mac: string, channel: number }) => void): void;
/**
* The 'auth_change' event is called when the authentication mode with the associated access point changes. The details include:
* - oldMode - The old auth mode (string: open, wep, wpa, wpa2, wpa_wpa2)
* - newMode - The new auth mode (string: open, wep, wpa, wpa2, wpa_wpa2)
*/
function on(event: 'auth_change', callback: (details: { oldMode: AuthMode, newMode: AuthMode }) => void): void;
/**
* The 'connected' event is called when the connection with an access point is ready for traffic. In the case of a dynamic IP address configuration this is when an IP address is obtained, in the case of static IP address allocation this happens when an association is formed (in that case the 'associated' and 'connected' events are fired in rapid succession).
* On ESP32/ESP8266 there is a details parameter which includes:
* - ip - The IP address obtained as string
* - netmask - The network's IP range mask as string
* - gw - The network's default gateway as string
*/
function on(event: 'connected', callback: (details: { ip: string, netmask: string, gw: string }) => void): void;
/**
* The 'disconnected' event is called when an association with an access point has been lost.
* On ESP32/ESP8266 there is a details parameter which includes:
* - ssid - The SSID of the access point from which the association was lost
* - mac - The BSSID/mac address of the access point
* - reason - The reason for the disconnection (string)
*/
function on(event: 'disconnected', callback: (details: Object) => void): void;
/**
* The 'dhcp_timeout' event is called when a DHCP request to the connected access point fails and thus no IP address could be acquired (or renewed).
*/
function on(event: 'dhcp_timeout', callback: () => void): void;
/**
* The 'probe_recv' event is called when a probe request is received from some station by the esp8266's access point. The details include:
* - mac - The MAC address of the station in string format (00:00:00:00:00:00)
* - rssi - The signal strength in dB of the probe request
*/
function on(event: 'probe_recv', callback: (details: { mac: string, rssi: number }) => void): void;
/**
* The 'sta_joined' event is called when a station establishes an association (i.e. connects) with the esp8266's access point. The details include:
* - mac - The MAC address of the station in string format (00:00:00:00:00:00)
*/
function on(event: 'sta_joined', callback: (details: { mac: string }) => void): void;
/**
* The 'sta_left' event is called when a station disconnects from the esp8266's access point (or its association times out?). The details include:
* - mac - The MAC address of the station in string format (00:00:00:00:00:00)
*/
function on(event: 'sta_left', callback: (details: { mac: string }) => void): void;
/**
* Disconnect the wifi station from an access point and disable the station mode. It is OK to call disconnect to turn off station mode even if no connection exists (for example, connection attempts may be failing). Station mode can be re-enabled by calling connect or scan.
*/
function disconnect(callback?: Function): void;
/** The authentication required of stations: open, wpa, wpa2, wpa_wpa2. */
type AuthMode = 'open' | 'wep' | 'wpa' | 'wpa2' | 'wpa_wpa2'
/** Station IP */
type Station = {
ip: string,
netmask: number,
gw: number,
mac: number
}
type APDetails = {
/** Current access point status: enabled or disabled */
status: 'enabled' | 'disabled',
/** An array of the stations connected to the access point. This array may be empty. Each entry in the array is an object describing the station which, at a minimum contains ip being the IP address of the station. */
stations: Station[],
/** SSID to broadcast. */
ssid: string,
/** Password for authentication. */
password: string,
authMode: AuthMode,
/** True if the SSID is hidden, false otherwise. */
hidden: boolean,
/** Max number of station connections supported. */
maxConn: number,
/** the SSID to broadcast automatically at boot time, null if the access point is to be disabled at boot. */
savedSsid: string,
};
/**
* Retrieve the current access point configuration and status. The details object has the following properties:
* - status - Current access point status: enabled or disabled
* - stations - an array of the stations connected to the access point. This array may be empty. Each entry in the array is an object describing the station which, at a minimum contains ip being the IP address of the station.
* - ssid - SSID to broadcast.
* - password - Password for authentication.
* - authMode - the authentication required of stations: open, wpa, wpa2, wpa_wpa2.
* - hidden - True if the SSID is hidden, false otherwise.
* - maxConn - Max number of station connections supported.
* - savedSsid - the SSID to broadcast automatically at boot time, null if the access point is to be disabled at boot.
*
* Parameters
* - callback {Function} An optional function to be called back with the current access point details, i.e. the same object as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - An object representing the current access point details, if available immediately.
*/
function getAPDetails(callback?: (details: APDetails) => void): APDetails;
type APIP = {
ip: string,
netmask: string,
gw: string,
mac?: string
}
/**
* Return the access point IP information in an object which contains:
* - ip - IP address as string (typ "192.168.4.1")
* - netmask - The interface netmask as string
* - gw - The network gateway as string
* - mac - The MAC address as string of the form 00:00:00:00:00:00
*
* Parameters
* - callback {Function} An optional function to be called back with the the IP information, i.e. the same object as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - An object representing the esp8266's Access Point IP information, if available immediately (ONLY on ESP8266/ESP32)
*/
function getAPIP(callback?: (details: APIP) => void): APIP;
/**
* Description
* Retrieve the wifi station configuration and status details. The details object has the following properties:
* - status - Details about the wifi station connection, one of off, connecting, wrong_password, no_ap_found, connect_fail, or connected. The off, bad_password and connected states are stable, the other states are transient. The connecting state will either result in connected or one of the error states (bad_password, no_ap_found, connect_fail) and the no_ap_found and connect_fail states will result in a reconnection attempt after some interval.
* - rssi - signal strength of the connected access point in dB, typically in the range -110 to 0, with anything greater than -30 being an excessively strong signal.
* - ssid - SSID of the access point.
* - password - the password used to connect to the access point.
* - authMode - the authentication used: open, wpa, wpa2, wpa_wpa2 (not currently supported).
* - savedSsid - the SSID to connect to automatically at boot time, null if none.
*
* Parameters
* - callback - An optional function to be called back with the wifi details, i.e. the same object as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - An object representing the wifi station details, if available immediately.
*/
type StationConfigDetails = {
status: 'off' | 'connecting' | 'wrong_password' | 'no_ap_found' | 'connect_fail' | 'connected',
rssi: number,
ssid: string,
password: string,
authMode: AuthMode,
savedSsid: string
}
function getDetails(callback?: StationConfigDetails): StationConfigDetails;
/**
* Description
* Lookup the hostname and invoke a callback with the IP address as integer argument. If the lookup fails, the callback is invoked with a null argument. Note: only a single hostname lookup can be made at a time, concurrent lookups are not supported.
*
* Parameters
* - hostname - The hostname to lookup.
* - callback - The callback to invoke when the hostname is returned.
*/
function getHostByName(hostname: string, callback: (ip: number) => void): void;
/**
* Description
* Returns the hostname announced to the DHCP server and broadcast via mDNS when connecting to an access point.
*
* Parameters
* - callback - An optional function to be called back with the hostname, i.e. the same string as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - The currently configured hostname, if available immediately.
*/
function getHostname(callback?: (hostname: string) => void): string;
/**
* Description
* Return the station IP information in an object as follows:
* - ip - IP address as string (e.g. "192.168.1.5")
* - netmask - The interface netmask as string (ESP8266/ESP32 only)
* - gw - The network gateway as string (ESP8266/ESP32 only)
* - mac - The MAC address as string of the form 00:00:00:00:00:00
* - Note that the ip, netmask, and gw fields are omitted if no connection is established:
*
* Parameters
* - callback - An optional function to be called back with the IP information, i.e. the same object as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - An object representing the station IP information, if available immediately (ONLY on ESP8266/ESP32).
*/
function getIP(callback?: (station: Station) => void): Station;
/**
* Description
* Retrieve the current overall WiFi configuration. This call provides general information that pertains to both station and access point modes. The getDetails and getAPDetails calls provide more in-depth information about the station and access point configurations, respectively. The status object has the following properties:
* - station - Status of the wifi station: off, connecting, ...
* - ap - Status of the wifi access point: disabled, enabled.
* - mode - The current operation mode: off, sta, ap, sta+ap.
* - phy - Modulation standard configured: 11b, 11g, 11n (the esp8266 docs are not very clear, but it is assumed that 11n means b/g/n). This setting limits the modulations that the radio will use, it does not indicate the current modulation used with a specific access point.
* - powersave - Power saving mode: none (radio is on all the time), ps-poll (radio is off between beacons as determined by the access point's DTIM setting). Note that in 'ap' and 'sta+ap' modes the radio is always on, i.e., no power saving is possible.
* - savedMode - The saved operation mode which will be applied at boot time: off, sta, ap, sta+ap.
*
* Parameters
* - callback - An optional function to be called back with the current Wifi status, i.e. the same object as returned directly. The callback function is more portable than the direct return value.
*
* Returns
* - An object representing the current WiFi status, if available immediately.
*/
type WifiStatus = {
station: 'off' | 'connecting' | 'wrong_password' | 'no_ap_found' | 'connect_fail' | 'connected',
ap: 'enabled' | 'disabled',
mode: AuthMode,
phy: '11b' | '11g' | '11n',
powersave: 'none' | 'ps-poll',
savedMode: 'off' | 'sta' | 'ap' | 'sta+ap'
}
function getStatus(callback?: (status: WifiStatus) => void): WifiStatus;
/**
* Description
* Issues a ping to the given host, and calls a callback with the time when the ping is received.
*
* Parameters
* - hostname - The host to ping
* - callback - A callback(time) function to invoke when a ping is received
*/
function ping(hostname: string, callback: (time: number) => void): void;
/**
* Description
* Restores the saved Wifi configuration from flash. See Wifi.save().
*/
function restore(): void;
/**
* Description
* On boards where this is not available, just issue the connect commands you need to run at startup from an onInit function.
* Save the current wifi configuration (station and access point) to flash and automatically apply this configuration at boot time, unless what=="clear", in which case the saved configuration is cleared such that wifi remains disabled at boot. The saved configuration includes:
* - mode (off/sta/ap/sta+ap)
* - SSIDs & passwords
* - phy (11b/g/n)
* - powersave setting
* - DHCP hostname
*
* Parameters
* - what - An optional parameter to specify what to save, on the esp8266 the two supported values are clear and sta+ap. The default is sta+ap
*/
function save(what?: 'clear' | 'sta+ap'): void;
/**
* Description
* Perform a scan for access points. This will enable the station mode if it is not currently enabled. Once the scan is complete the callback function is called with an array of APs found, each AP is an object with:
* - ssid: SSID string.
* - mac: access point MAC address in 00:00:00:00:00:00 format.
* - authMode: open, wep, wpa, wpa2, or wpa_wpa2.
* - channel: wifi channel 1..13.
* - hidden: true if the SSID is hidden (ESP32/ESP8266 only)
* - rssi: signal strength in dB in the range -110..0.
* Notes: in order to perform the scan the station mode is turned on and remains on, use Wifi.disconnect() to turn it off again, if desired. only one scan can be in progress at a time.
*
* Parameters
* - callback - A function to be called back on completion.
*/
type AP = {
ssid: string,
mac: string,
authMode: AuthMode,
channel: number,
hidden: boolean,
rssi: number
}
function scan(callback: (aps: AP[]) => void): void;
/**
* Description
* The settings object must contain the following properties.
* - ip IP address as string (e.g. "192.168.5.100")
* - gw The network gateway as string (e.g. "192.168.5.1")
* - netmask The interface netmask as string (e.g. "255.255.255.0")
*
* Parameters
* - settings - Configuration settings
* - callback - The callback to invoke when ip is set
*/
function setAPIP(settings: APIP, callback: Function): void;
/**
* Description
* Sets a number of global wifi configuration settings. All parameters are optional and which are passed determines which settings are updated. The settings available are:
* - phy - Modulation standard to allow: 11b, 11g, 11n (the esp8266 docs are not very clear, but it is assumed that 11n means b/g/n).
* - powersave - Power saving mode: none (radio is on all the time), ps-poll (radio is off between beacons as determined by the access point's DTIM setting). Note that in 'ap' and 'sta+ap' modes the radio is always on, i.e., no power saving is possible.
* - Note: esp8266 SDK programmers may be missing an "opmode" option to set the sta/ap/sta+ap operation mode. Please use connect/scan/disconnect/startAP/stopAP, which all set the esp8266 opmode indirectly.
*
* Parameters
* - settings - An object with the configuration settings to change.
*/
function setConfig(settings: { phy?: '11b' | '11g' | '11n', powersave?: 'none' | 'ps-poll' }): void;
/**
* Description
* Set the hostname. Depending on implemenation, the hostname is sent with every DHCP request and is broadcast via mDNS. The DHCP hostname may be visible in the access point and may be forwarded into DNS as hostname.local. If a DHCP lease currently exists changing the hostname will cause a disconnect and reconnect in order to transmit the change to the DHCP server. The mDNS announcement also includes an announcement for the "espruino" service.
*
* Parameters
* - hostname - The new hostname.
* - callback - An optional function to be called back when the hostname is set
*/
function setHostname(hostname: string, callback?: Function): void;
/**
* Description
* The settings object must contain the following properties.
* - ip IP address as string (e.g. "192.168.5.100")
* - gw The network gateway as string (e.g. "192.168.5.1")
* - netmask The interface netmask as string (e.g. "255.255.255.0")
*
* Parameters
* - settings - Configuration settings
* - callback - The callback to invoke when ip is set
*/
function setIP(settings: { ip: string, gw: string, netmask: string }, callback: Function): void;
/**
* Description
* Starts the SNTP (Simple Network Time Protocol) service to keep the clock synchronized with the specified server. Note that the time zone is really just an offset to UTC and doesn't handle daylight savings time. The interval determines how often the time server is queried and Espruino's time is synchronized. The initial synchronization occurs asynchronously after setSNTP returns.
* Note: This is only available in ESP8266 devices running Espruino
*
* Parameters
* - server - The NTP server to query, for example, us.pool.ntp.org
* - tz_offset - Local time zone offset in the range -11..13.
*/
function setSNTP(server: string, tz_offset: number): void;
/**
* Description
* Create a WiFi access point allowing stations to connect. If the password is NULL or an empty string the access point is open, otherwise it is encrypted. The callback function is invoked once the access point is set-up and receives one err argument, which is NULL on success and contains an error message string otherwise.
* The options object can contain the following properties.
* - authMode - The authentication mode to use. Can be one of "open", "wpa2", "wpa", "wpa_wpa2". The default is open (but open access points are not recommended).
* - password - The password for connecting stations if authMode is not open.
* - channel - The channel to be used for the access point in the range 1..13. If the device is also connected to an access point as a station then that access point determines the channel.
*
* Notes:
* - the options should include the ability to set the AP IP and associated netmask, this is a future enhancement.
* - the startAP call automatically enables AP mode. It can be disabled again by calling stopAP.
*
* Parameters
* - ssid - The network id.
* - options - Configuration options (optional).
* - callback - Optional function to be called when the AP is successfully started.
*/
function startAP(ssid: string, options?: { authMode: AuthMode, password: string, channel: number }, callback?: (err: string) => void): void;
/**
* Description
* Stop being an access point and disable the AP operation mode. Ap mode can be re-enabled by calling startAP.
*
* Parameters
* - callback - An optional function to be called back on successful stop. The callback function receives no argument.
*/
function stopAP(callback?: Function): void;
/**
* Description
* Switch to using a higher communication speed with the WiFi module.
* - true = 921600 baud
* - false = 115200
* - 1843200 (or any number) = use a specific baud rate. * eg. wifi.turbo(true,callback) or wifi.turbo(1843200,callback)
*
* Parameters
* - enable - true (or a baud rate as a number) to enable, false to disable
* - callback - A callback(time) function to invoke when a ping is received
*/
function turbo(enable: boolean, callback: (time: number) => void): void;
}
declare module "InfluxDB" {
function setup(options: any): any;
function write(data: string): any;
}
/**
* <p>This is the built-in class for the Arduino-style pin namings on ST Nucleo boards</p>
*
* @url http://www.espruino.com/Reference#Nucleo
*/
declare interface Nucleo {
/**
*
* @return
*/
constructor(): Nucleo;
}
/**
*
*/
declare namespace Nucleo {
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A0
*/
var A0: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A1
*/
var A1: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A2
*/
var A2: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A3
*/
var A3: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A4
*/
var A4: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_A5
*/
var A5: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D0
*/
var D0: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D1
*/
var D1: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D2
*/
var D2: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D3
*/
var D3: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D4
*/
var D4: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D5
*/
var D5: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D6
*/
var D6: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D7
*/
var D7: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D8
*/
var D8: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D9
*/
var D9: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D10
*/
var D10: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D11
*/
var D11: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D12
*/
var D12: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D13
*/
var D13: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D14
*/
var D14: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_Nucleo_D15
*/
var D15: Pin;
}
/**
* <p>This is a built-in class to allow you to use the ESP8266 NodeMCU boards's pin namings to access pins. It is only available on ESP8266-based boards.</p>
*
* @url http://www.espruino.com/Reference#NodeMCU
*/
declare interface NodeMCU {
/**
*
* @return
*/
constructor(): NodeMCU;
}
/**
*
*/
declare namespace NodeMCU {
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_A0
*/
var A0: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D0
*/
var D0: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D1
*/
var D1: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D2
*/
var D2: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D3
*/
var D3: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D4
*/
var D4: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D5
*/
var D5: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D6
*/
var D6: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D7
*/
var D7: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D8
*/
var D8: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D9
*/
var D9: Pin;
/**
*
* @url http://www.espruino.com/Reference#l_NodeMCU_D10
*/
var D10: Pin;
}
/**
* <p>Creates a Queue Object</p>
*
* @url http://www.espruino.com/Reference#l_Queue_Queue
*/
declare interface Queue {
/**
*
* @param queueName
* @return
*/
constructor(queueName: any): any;
/**
* <p>reads one character from queue, if available</p>
*
* @url http://www.espruino.com/Reference#l_Queue_read
*/
read(): void;
/**
* <p>Writes one character to queue</p>
*
* @param char
* @url http://www.espruino.com/Reference#l_Queue_writeChar
*/
writeChar(char: any): void;
/**
* <p>logs list of queues</p>
*
* @url http://www.espruino.com/Reference#l_Queue_log
*/
log(): void;
}
/**
* <p>Creates a Task Object</p>
*
* @url http://www.espruino.com/Reference#l_Task_Task
*/
declare interface Task {
/**
*
* @param taskName
* @return
*/
constructor(taskName: any): any;
/**
* <p>Suspend task, be careful not to suspend Espruino task itself</p>
*
* @url http://www.espruino.com/Reference#l_Task_suspend
*/
suspend(): void;
/**
* <p>Resumes a suspended task</p>
*
* @url http://www.espruino.com/Reference#l_Task_resume
*/
resume(): void;
/**
* <p>returns name of actual task</p>
*
* @return
* @url http://www.espruino.com/Reference#l_Task_getCurrent
*/
getCurrent(): any;
/**
* <p>Sends a binary notify to task</p>
*
* @url http://www.espruino.com/Reference#l_Task_notify
*/
notify(): void;
/**
* <p>logs list of tasks</p>
*
* @url http://www.espruino.com/Reference#l_Task_log
*/
log(): void;
}
/**
* <p>Creates a Timer Object</p>
*
* @url http://www.espruino.com/Reference#l_Timer_Timer
*/
declare interface Timer {
/**
*
* @param timerName
* @param group
* @param index
* @param isrIndex
* @return
*/
constructor(timerName: any, group: number, index: number, isrIndex: number): any;
/**
* <p>Starts a timer</p>
*
* @param duration
* @url http://www.espruino.com/Reference#l_Timer_start
*/
start(duration: number): void;
/**
* <p>Reschedules a timer, needs to be started at least once</p>
*
* @param duration
* @url http://www.espruino.com/Reference#l_Timer_reschedule
*/
reschedule(duration: number): void;
/**
* <p>logs list of timers</p>
*
* @url http://www.espruino.com/Reference#l_Timer_log
*/
log(): void;
}
// write(data: any[]): any;
// on(event: string, handler: (data: any) => any): any;
// setup(boudrate: number, options: any): any;
// read(chars?: number): string;
/**
* <p>This class allows use of the built-in USARTs</p>
* <p>Methods may be called on the USB, Serial1, Serial2, Serial3, Serial4, Serial5 and Serial6 objects. While different processors provide different numbers of USARTs, you can always rely on at least Serial1 and Serial2</p>
*
* @url http://www.espruino.com/Reference#Serial
*/
declare interface Serial extends Object {
/**
*
* @return
*/
constructor(): Serial;
/**
* <p>Set this Serial port as the port for the JavaScript console (REPL).</p>
* <p>Unless <code>force</code> is set to true, changes in the connection state of the board
* (for instance plugging in USB) will cause the console to change.</p>
*
* @param force
* @url http://www.espruino.com/Reference#l_Serial_setConsole
*/
setConsole(force: boolean): void;
setup(baudrate: number, options: any): void;
/**
* <p>Print a string to the serial port - without a line feed</p>
* <p> <strong>Note:</strong> This function replaces any occurances of <code>\n</code> in the string with <code>\r\n</code>. To avoid this, use <code>Serial.write</code>.</p>
*
* @param string
* @url http://www.espruino.com/Reference#l_Serial_print
*/
print(string: any): void;
on(eventName: string, f: (str: string) => void): void;
/**
* <p>Print a line to the serial port with a newline (<code>\r\n</code>) at the end of it.</p>
* <p> <strong>Note:</strong> This function converts data to a string first, eg <code>Serial.print([1,2,3])</code> is equivalent to <code>Serial.print("1,2,3"). If you'd like to write raw bytes, use</code>Serial.write`.</p>
*
* @param string
* @url http://www.espruino.com/Reference#l_Serial_println
*/
println(string: any): void;
/**
* <p>Write a character or array of data to the serial port</p>
* <p>This method writes unmodified data, eg <code>Serial.write([1,2,3])</code> is equivalent to <code>Serial.write("\1\2\3")</code>. If you'd like data converted to a string first, use <code>Serial.print</code>.</p>
*
* @param data
* @url http://www.espruino.com/Reference#l_Serial_write
*/
write(data: any): void;
/**
* <p>Return how many bytes are available to read. If there is already a listener for data, this will always return 0.</p>
*
* @return
* @url http://www.espruino.com/Reference#l_Serial_available
*/
available(): number;
/**
* <p>Return a string containing characters that have been received</p>
*
* @param chars
* @return
* @url http://www.espruino.com/Reference#l_Serial_read
*/
read(chars?: number): any;
/**
* <p>Pipe this USART to a stream (an object with a 'write' method)</p>
*
* @param destination
* @param options
* @url http://www.espruino.com/Reference#l_Serial_pipe
*/
pipe(destination: any, options: any): void;
/**
* <p>Try and find a USART (Serial) hardware device that will work on this pin (eg. <code>Serial1</code>)</p>
* <p>May return undefined if no device can be found.</p>
*
* @param pin
* @return
* @url http://www.espruino.com/Reference#l_Serial_find
*/
find(pin: Pin): any;
}
/**
* <p>The USB Serial port</p>
*
* @url http://www.espruino.com/Reference#l__global_USB
*/
declare var USB: Serial;
/**
* <p>The first Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial1
*/
declare var Serial1: Serial;
/**
* <p>The second Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial2
*/
declare var Serial2: Serial;
/**
* <p>The third Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial3
*/
declare var Serial3: Serial;
/**
* <p>The fourth Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial4
*/
declare var Serial4: Serial;
/**
* <p>The fifth Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial5
*/
declare var Serial5: Serial;
/**
* <p>The sixth Serial (USART) port</p>
*
* @url http://www.espruino.com/Reference#l__global_Serial6
*/
declare var Serial6: Serial;
/**
* <p>A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa</p>
*
* @url http://www.espruino.com/Reference#l__global_LoopbackA
*/
declare var LoopbackA: Serial;
/**
* <p>A loopback serial device. Data sent to LoopbackA comes out of LoopbackB and vice versa</p>
*
* @url http://www.espruino.com/Reference#l__global_LoopbackB
*/
declare var LoopbackB: Serial;
/**
* <p>A telnet serial device that maps to the built-in telnet console server (devices that have
* built-in wifi only).</p>
*
* @url http://www.espruino.com/Reference#l__global_Telnet
*/
declare var Telnet: {
};
/**
* <p>This module allows access to read and write the STM32's flash memory.</p>
* <p>It should be used with extreme caution, as it is easy to overwrite parts of Flash
* memory belonging to Espruino or even its bootloader. If you damage the bootloader
* then you may need external hardware such as a USB-TTL converter to restore it. For
* more information on restoring the bootloader see <code>Advanced Reflashing</code> in your
* board's reference pages.</p>
* <p>To see which areas of memory you can and can't overwrite, look at the values
* reported by <code>process.memory()</code>.</p>
*
* @url http://www.espruino.com/Reference#l_Flash_undefined
*/
declare interface Flash {
/**