-
Notifications
You must be signed in to change notification settings - Fork 0
/
nrf_socket.txt
1678 lines (1502 loc) · 55.5 KB
/
nrf_socket.txt
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
/*
* Copyright (c) 2018 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
/**@file nrf_socket.h
*
*/
#ifndef NRF_SOCKET_H__
#define NRF_SOCKET_H__
#include <stdint.h>
#include <stddef.h>
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(__GNUC__) || (__GNUC__ == 0)
typedef int32_t ssize_t;
#else
#include <sys/types.h>
#ifdef __SES_ARM
typedef int32_t ssize_t;
#endif
#endif
/**@addtogroup nrf_socket_api_utils
*@{
*/
/**@brief Host to network byte-orders on half word. */
#define NRF_HTONS(val) ((uint16_t)((((val)&0xff00) >> 8) | ((((val)&0x00ff) << 8))))
/**@brief Host to network byte-orders on full word. */
#define NRF_HTONL(val) ((((uint32_t)(val)&0xff000000) >> 24) | \
(((uint32_t)(val)&0x00ff0000) >> 8) | \
(((uint32_t)(val)&0x0000ff00) << 8) | \
(((uint32_t)(val)&0x000000ff) << 24))
/**@brief Network to host byte-orders on half word. */
#define NRF_NTOHS(val) NRF_HTONS(val)
/**@brief Network to host byte-orders on full word. */
#define NRF_NTOHL(val) NRF_HTONL(val)
/** Convert byte order from host to network (short). */
#define nrf_htons(x) NRF_HTONS(x)
/** Convert byte order from host to network (long). */
#define nrf_htonl(x) NRF_HTONL(x)
/** Convert byte order from network to host (short). */
#define nrf_ntohs(x) NRF_NTOHS(x)
/** Convert byte order from network to host (long). */
#define nrf_ntohl(x) NRF_NTOHL(x)
/**@brief Maximum length of IPv4 in string form, including null-termination character. */
#define NRF_INET_ADDRSTRLEN 16
/**@brief Maximum length of IPv6 in string form, including null-termination character. */
#define NRF_INET6_ADDRSTRLEN 46
/**@brief Maximum length of PDN authentication username in string form, including null-termination character. */
#define NRF_PDN_MAX_USERNAME_LEN 100
/**@brief Maximum length of PDN authentication password in string form, including null-termination character. */
#define NRF_PDN_MAX_PASSWORD_LEN 100
/**@}*/
/**@defgroup nrf_socket_api_enumerators Socket enumerators.
* @brief Enumerated values that is used as input arguments to multiple socket functions.
* @{
*/
/**@defgroup nrf_socket_families Socket family.
* @{
*/
/** Family to identify protocols/operations local to Nordic device. */
#define NRF_AF_LOCAL 1
/** IPv4 socket family. */
#define NRF_AF_INET 2
/** Raw packet family. */
#define NRF_AF_PACKET 5
/** IPv6 socket family. */
#define NRF_AF_INET6 10
/** Nordic proprietary LTE socket family. */
#define NRF_AF_LTE 102
/**@} */
/**@defgroup nrf_socket_types Socket type.
* @{
*/
/** TCP socket type. */
#define NRF_SOCK_STREAM 1
/** UDP socket type. */
#define NRF_SOCK_DGRAM 2
/** RAW socket type. */
#define NRF_SOCK_RAW 3
/** Nordic specific management socket. Used for system or link management. */
#define NRF_SOCK_MGMT 512
/**@} */
/**@defgroup nrf_socket_protocols Socket protocols.
* @{
*/
/** TCP protocol. */
#define NRF_IPPROTO_TCP 1
/** UDP protocol. */
#define NRF_IPPROTO_UDP 2
/** TLS1v2 protocol. */
#define NRF_SPROTO_TLS1v2 260
/** TLS1v3 protocol. */
#define NRF_SPROTO_TLS1v3 261
/** DTLS1v2 protocol. */
#define NRF_SPROTO_DTLS1v2 270
/** AT command protocol. */
#define NRF_PROTO_AT 513
/** PDN management protocol. */
#define NRF_PROTO_PDN 514
/** DFU protocol. */
#define NRF_PROTO_DFU 515
/** GNSS protocol. */
#define NRF_PROTO_GNSS 516
/**@} */
/**
* @defgroup nrf_fd_set_api Descriptor sets API
* @brief Types and macros used to manipulate the input data argument to the nrf_select() function.
* @details File descriptor sets are used as input to the nrf_select() function for doing I/O
* multiplexing. The maximum number of descriptors contained in a set is defined by
* NRF_FD_SETSIZE.
*
* @{
*/
typedef uint32_t nrf_fd_set;
/** Clear the entire set. */
#define NRF_FD_ZERO(set) (*(set) = 0)
/** Set a bit in the set. */
#define NRF_FD_SET(fd, set) (*(set) |= (1u << (fd)))
/** Clear a bit in the set. */
#define NRF_FD_CLR(fd, set) (*(set) &= ~(1u << (fd)))
/** Check if a bit in the set is set. */
#define NRF_FD_ISSET(fd, set) (*(set) & (1u << (fd)))
/** The max size of a set. */
#define NRF_FD_SETSIZE sizeof(nrf_fd_set)
/**@} */
/**@defgroup nrf_socket_tls TLS socket
* @brief TLS socket API
* @{
*/
/**@brief
* Socket option to set role for the connection.
* Accepts an nrf_sec_role_t with values:
* - 0 - Client role.
* - 1 - Server role.
*/
#define NRF_SO_SEC_ROLE 1
/**@brief
* Socket option to select the security tags to be used.
* @sa nrf_sec_tag_t.
*/
#define NRF_SO_SEC_TAG_LIST 2
/**@brief
* Socket option to control TLS session caching.
* Accepts an nrf_sec_session_cache_t with values:
* - 0 - Disabled.
* - 1 - Enabled.
* @sa nrf_sec_session_cache_t.
*/
#define NRF_SO_SEC_SESSION_CACHE 3
/**@brief
* Socket option to set peer verification level.
* This option accepts an nrf_sec_peer_verify_t with values:
* - 0 - None
* - 1 - Optional
* - 2 - Required
* @sa nrf_sec_peer_verify_t.
*/
#define NRF_SO_SEC_PEER_VERIFY 4
/**@brief
* Socket option to set the hostname used for peer verification.
* This option accepts a string containing the hostname, and its length.
* The length may be set to zero to disable hostname verification.
*/
#define NRF_SO_HOSTNAME 5
/**@brief
* Socket option to select which ciphersuites to use.
* @sa nrf_sec_cipher_t.
*/
#define NRF_SO_CIPHERSUITE_LIST 6
/**@brief
* Socket option to retrieve the ciphersuites used during the handshake.
* Currently unsupported.
* @sa nrf_sec_cipher_t.
*/
#define NRF_SO_CIPHER_IN_USE 7
/**@} */
/**@defgroup nrf_socket_pdn PDN socket
* @brief PDN socket API
* @{
*/
/**@brief
* Socket option control the supported address families on the PDN.
* @sa nrf_pdn_af_list_t.
*/
#define NRF_SO_PDN_AF 1
/**@brief
* Socket option to retrieve the context ID on the PDN.
* @sa nrf_pdn_context_id_t.
*/
#define NRF_SO_PDN_CONTEXT_ID 2
/**@brief
* Socket option to retrieve the PDN state, read-only.
* @sa nrf_pdn_state_t.
*/
#define NRF_SO_PDN_STATE 3
/**@brief
* Socket option to set PDN authentication.
* @sa nrf_pdn_auth_t.
*/
#define NRF_SO_PDN_AUTH 4
/**@} */
/**@defgroup nrf_socket_dfu DFU socket
* @brief DFU socket API
* @{
*/
/**@brief
* Socket option to read the modem firmware version (UUID).
* @sa nrf_dfu_fw_version_t.
*/
#define NRF_SO_DFU_FW_VERSION 1
/**@brief
* Socket option to retrieve the size of the largest firmware image
* that can be transferred to the modem for firmware updates.
* @sa nrf_dfu_resources_t.
*/
#define NRF_SO_DFU_RESOURCES 2
/**@brief
* Socket option to control the timeout to send a firmware fragment.
* @note Not implemented.
*/
#define NRF_SO_DFU_TIMEO 3
/**@brief
* Socket option to schedule a modem firmware update at next boot.
* The result of the update is returned by nrf_modem_init, at next boot.
* The modem needs to be reset once more to run the updated firmware.
*/
#define NRF_SO_DFU_APPLY 4
/**@brief
* Socket option to schedule a rollback of a firmware update at next boot.
*/
#define NRF_SO_DFU_REVERT 5
/**@brief
* Socket option to delete a modem firmware image from the modem's scratch area.
* This option removes the possibility to rollback to a previous version,
* and is necessary to receive new firmware images.
*/
#define NRF_SO_DFU_BACKUP_DELETE 6
/**@brief
* Socket option read and write the offset of the downloaded firmware image
* in the modem's scratch area. This option is used to determine whether
* a firmware image exists in the modem's scratch area and its size.
* A value of 2.5 megabytes (2621440 bytes) is returned if the scratch area
* is dirty, and needs erasing (via NRF_SO_DFU_BACKUP_DELETE).
* If non-zero and different from 2.5 megabytes, the value indicates the size
* of the firmware image received so far.
*/
#define NRF_SO_DFU_OFFSET 7
/**@brief
* Socket option to retrieve the latest DFU error, see @ref nrf_dfu_errors.
* Read-only.
*/
#define NRF_SO_DFU_ERROR 20
/**@} */
/**
* @defgroup nrf_socket_gnss_options GNSS socket options
* @brief Sockets options to configure behaviour of the socket.
* @{
*/
/**
* @brief
* Identifies the option used to set the GNSS fix interval in seconds.
*
* @details
* Single-fix navigation mode is engaged by setting the fix interval to 0.
*
* Continuous navigation mode is engaged by setting fix interval to 1.
*
* Periodic navigation mode is engaged by setting the fix interval to value
* 10...1800. The unit is seconds.
*/
#define NRF_SO_GNSS_FIX_INTERVAL 1
/**
* @brief
* Identifies the option used to set the GNSS fix retry interval in seconds.
*
* @details
* Fix retry parameter controls the maximum time the GNSS receiver is allowed
* to run while trying to produce a valid PVT estimate. If the fix retry time
* is non-zero, the GNSS receiver is turned off after the fix retry time is up
* regardless of whether a valid PVT estimate was produced or not. If fix retry
* parameter is set to zero, the GNSS receiver is allowed to run indefinitely
* until a valid PVT estimate is produced.
*/
#define NRF_SO_GNSS_FIX_RETRY 2
/** Identifies the option used to set and/or get the GNSS system used. See nrf_gnss_system_t for details. */
#define NRF_SO_GNSS_SYSTEM 3
/** Identifies the option used to select the data format of the received data. */
#define NRF_SO_GNSS_NMEA_MASK 4
/** Indicates at which elevation the GPS should stop tracking a satellite. */
#define NRF_SO_GNSS_ELEVATION_MASK 5
/** Indicates the targeted start performance. */
#define NRF_SO_GNSS_USE_CASE 6
/** Identifies the option to start the GPS. nrf_gnss_delete_mask_t given as payload. */
#define NRF_SO_GNSS_START 7
/** Identifies the option to stop the GPS. nrf_gnss_delete_mask_t given as payload. */
#define NRF_SO_GNSS_STOP 8
/** Identifies the option to set power save mode. */
#define NRF_SO_GNSS_POWER_SAVE_MODE 9
/** Identifies the option to enable priority time window (with no payload). */
#define NRF_SO_GNSS_ENABLE_PRIORITY 10
/** Identifies the option to disable priority time window (with no payload). */
#define NRF_SO_GNSS_DISABLE_PRIORITY 11
/** @} */
/**@defgroup nrf_socket_gnss_nmea_str_mask NMEA enable output strings bitmask values
* @brief Use these bitmask values to enable different type of NMEA output strings, the values can be OR'ed together to enable multiple string types
* at the same time. Writing 0 to the bit position will disable the corresponding NMEA string type.
* @{
*/
/** Enables Global Positioning System Fix Data. */
#define NRF_GNSS_NMEA_GGA_MASK 1
/** Enables Geographic Position Latitude/Longitude and time. */
#define NRF_GNSS_NMEA_GLL_MASK 2
/** Enables DOP and active satellites. */
#define NRF_GNSS_NMEA_GSA_MASK 4
/** Enables Satellites in view. */
#define NRF_GNSS_NMEA_GSV_MASK 8
/** Enables Recommended minimum specific GPS/Transit data. */
#define NRF_GNSS_NMEA_RMC_MASK 16
/** @} */
/**@defgroup nrf_socket_gnss_psm_modes Power save mode enumerator
*
* @brief
* Use these values to select which power save mode the GNSS module should use.
*
* @{
*/
#define NRF_GNSS_PSM_DISABLED 0 /** No power save mode is enabled. */
#define NRF_GNSS_PSM_DUTY_CYCLING_PERFORMANCE 1 /** Enables duty-cycling performance policy power save mode. */
#define NRF_GNSS_PSM_DUTY_CYCLING_POWER 2 /** Enables duty-cycling power policy power save mode. */
/** @} */
/**@defgroup nrf_socket_gnss_use_case_modes Use case enumerator
*
* @brief
* Use these bit values to select which use case mode the GNSS module should use. A use case mode
* is a combination of the values of all of the bits.
*
* @{
*/
#define NRF_GNSS_USE_CASE_SINGLE_COLD_START 0 << 0 /** Single cold start performance bit 0 value */
#define NRF_GNSS_USE_CASE_MULTIPLE_HOT_START 1 << 0 /** Mutiple hot start performance bit 0 value */
#define NRF_GNSS_USE_CASE_NORMAL_ACCURACY 0 << 1 /** Normal accuracy fixes bit 1 value */
#define NRF_GNSS_USE_CASE_LOW_ACCURACY 1 << 1 /** Low accuracy fixes allowed bit 1 value */
/** @} */
/**@defgroup nrf_socket_gnss_pvt_flags Bitmask values for flags in the PVT notification.
* @brief These bitmask values can be used to read the different bits in the flags element in the pvt struct.
*
* @{
*/
/** Identifies a valid fix is acquired */
#define NRF_GNSS_PVT_FLAG_FIX_VALID_BIT 0x01
/**
* @brief
* Identifies the validity of leap second.
*
* @details
* The bit 1 in the notification flags tells if receiver has decoded leap second
* from the navigation message. The leap second is needed for determining
* GPS-UTC time offset (in seconds). If it is not decoded (bit is zero), the
* value of 18 seconds is used. This is the effective value since January 1st
* 2017.
*/
#define NRF_GNSS_PVT_FLAG_LEAP_SECOND_VALID 0x02
/** Identifies that at least one sleep period since last PVT notification */
#define NRF_GNSS_PVT_FLAG_SLEEP_BETWEEN_PVT 0x04
/** Identifies that notification deadline missed */
#define NRF_GNSS_PVT_FLAG_DEADLINE_MISSED 0x08
/** Identifies that operation blocked by insufficient time windows */
#define NRF_GNSS_PVT_FLAG_NOT_ENOUGH_WINDOW_TIME 0x10
/**@} */
/**@defgroup nrf_socket_gnss_sv_flags Bitmask values for reading out satellite flags information.
* @brief These bitmask values can be used to read the different bits in the flags element for each satellite.
* @{
*/
/** Indicate that the satellite is used in the position calculation. */
#define NRF_GNSS_SV_FLAG_USED_IN_FIX 2
/** Indicate that the satellite is unhealthy. */
#define NRF_GNSS_SV_FLAG_UNHEALTHY 8
/**@} */
/**@addtogroup nrf_socket_gnss_data_agps
* @brief Use these values in the address field when using sendto to write AGPS models to the GNSS module.
* @{
*/
/** GPS UTC assistance AGPS parameters. */
#define NRF_GNSS_AGPS_UTC_PARAMETERS 1
/** GPS ephemeris assistance AGPS parameters. */
#define NRF_GNSS_AGPS_EPHEMERIDES 2
/** GPS almanac assistance AGPS parameters. */
#define NRF_GNSS_AGPS_ALMANAC 3
/** GPS ionospheric assistance AGPS parameters, Klobuchar model. */
#define NRF_GNSS_AGPS_KLOBUCHAR_IONOSPHERIC_CORRECTION 4
/** GPS ionospheric assistance AGPS parameters, NeQuick model. */
#define NRF_GNSS_AGPS_NEQUICK_IONOSPHERIC_CORRECTION 5
/** GPS system time and SV TOW assistance AGPS parameter. */
#define NRF_GNSS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS 6
/** GPS location assistance AGPS parameters */
#define NRF_GNSS_AGPS_LOCATION 7
/** GPS integrity assistance AGPS parameters */
#define NRF_GNSS_AGPS_INTEGRITY 8
/** @} */
/**@defgroup nrf_socket_options_sockets Generic socket options
* @brief Socket options used with both AT and IP sockets
* @ingroup nrf_socket
* @{
*/
#define NRF_SO_ERROR 4
#define NRF_SO_RCVTIMEO 20
#define NRF_SO_SNDTIMEO 21
#define NRF_SO_BINDTODEVICE 25
#define NRF_SO_SILENCE_ALL 30
#define NRF_SO_SILENCE_IP_ECHO_REPLY 31
#define NRF_SO_SILENCE_IPV6_ECHO_REPLY 32
#define NRF_SO_REUSEADDR 40
/**@} */
/**@defgroup nrf_socket_options_levels Socket option levels enumerator
* @ingroup nrf_socket_api_enumerators
* @{
*/
#define NRF_SOL_SOCKET 1
#define NRF_SOL_SECURE 282
#define NRF_SOL_PDN 514
#define NRF_SOL_DFU 515
#define NRF_SOL_GNSS 516
/**@} */
/**@defgroup nrf_socket_send_recv_flags Socket send/recv flags.
*@ingroup nrf_socket_api_enumerators
* @{
*/
/** Send only to hosts on directly connected networks. */
#define NRF_MSG_DONTROUTE 0x01
/** Enables non-blocking operation. */
#define NRF_MSG_DONTWAIT 0x02
/** Sends out-of-band data on sockets that support this. */
#define NRF_MSG_OOB 0x04
/** Return data from the beginning of receive queue without removing data from the queue. */
#define NRF_MSG_PEEK 0x08
/** Request a blocking operation until the request is satisfied. */
#define NRF_MSG_WAITALL 0x10
/** Control the data truncation. */
#define NRF_MSG_TRUNC 0x20
/**@} */
/**@defgroup nrf_fcnt_commands Descriptor manipulate API
* @brief API used to manipulate the behaviour of AT and IP sockets using nrf_fcntl().
* @ingroup nrf_socket
* @{
*/
/** Set flag. */
#define NRF_F_SETFL 1
/** Get flag. */
#define NRF_F_GETFL 2
/** Use non-blocking I/O. */
#define NRF_O_NONBLOCK 0x01
/**@} */
/**
* @brief Socket port type.
*/
typedef uint16_t nrf_in_port_t;
/**
* @brief Structure specifying time interval.
*/
struct nrf_timeval {
/** Time interval seconds. */
uint32_t tv_sec;
/** Time interval microseconds. */
uint32_t tv_usec;
};
/**
* @brief Socket families.
*
* @details For a list of valid values, refer to nrf_socket_families.
*/
typedef int nrf_socket_family_t;
typedef nrf_socket_family_t nrf_sa_family_t;
/**
* @brief IPv6 address.
*/
struct nrf_in6_addr {
uint8_t s6_addr[16];
};
/**
* @brief IPv4 address.
*/
typedef uint32_t nrf_in_addr_t;
/**
* @brief IPv4 address structure.
*/
struct nrf_in_addr {
nrf_in_addr_t s_addr;
};
/**
* @brief Global IPv6 any-address.
*/
extern const struct nrf_in6_addr nrf_in6addr_any;
/**
* @brief Global IPv4 any-address.
*/
extern const struct nrf_in_addr nrf_inaddr_any;
/**
* @brief Address record for IPv6 addresses.
*
* @details Contains the address and port of the host, as well as other socket options. All fields
* in this structure are compatible with the POSIX variant for API compatibility.
*/
struct nrf_sockaddr_in6 {
/** Length of this data structure. */
uint8_t sin6_len;
/** Socket family. */
nrf_sa_family_t sin6_family;
/** Port, in network byte order. */
nrf_in_port_t sin6_port;
/** IPv6 flow info parameters. Not used. */
uint32_t sin6_flowinfo;
/** IPv6 address. */
struct nrf_in6_addr sin6_addr;
/** IPv6 scope ID. Not used. */
uint32_t sin6_scope_id;
};
/**
* @brief Address record for IPv4 addresses.
*
* @details Contains the address and port of the host. All fields
* in this structure are compatible with the POSIX variant for API compatibility.
*/
struct nrf_sockaddr_in {
/** Length of this data structure. */
uint8_t sin_len;
/** Socket family. */
nrf_sa_family_t sin_family;
/** Port, in network byte order. */
nrf_in_port_t sin_port;
/** IPv4 address. */
struct nrf_in_addr sin_addr;
};
typedef struct nrf_sockaddr nrf_sockaddr_t;
typedef struct nrf_sockaddr_in6 nrf_sockaddr_in6_t;
typedef struct nrf_in6_addr nrf_in6_addr;
typedef struct nrf_in6_addr nrf_in6_addr_t;
typedef struct nrf_sockaddr_in nrf_sockaddr_in_t;
/**@addtogroup nrf_socket_api_utils
* @{
*/
/**
* @brief Socket module size type.
*/
typedef uint32_t nrf_socklen_t;
/**
* @brief Generic socket address.
*
* @details Only provided for API compatibility.
*/
typedef struct nrf_sockaddr {
/** Socket address length */
uint8_t sa_len;
/** Socket address family */
int sa_family;
/** Socket address */
char sa_data[];
} nrf_sockaddr;
/**@brief Address information. */
struct nrf_addrinfo {
/** Input flags. */
int ai_flags;
/** Address family of the socket. */
int ai_family;
/** Socket type. */
int ai_socktype;
/** Protocol of the socket. */
int ai_protocol;
/** Length of the socket address. */
nrf_socklen_t ai_addrlen;
/** Address of the socket. */
struct nrf_sockaddr *ai_addr;
/** Canonical name of service location. */
char *ai_canonname;
/** Pointer to next in list. */
struct nrf_addrinfo *ai_next;
};
/**@} */
/**@addtogroup nrf_socket_tls
* @{
*/
/**@brief
* TLS role for the connection.
* - 0 - TLS client role.
* - 1 - TLS server role.
*/
typedef uint32_t nrf_sec_role_t;
/**@brief
* Security tags used on the TLS socket.
*
* More than one security tags may be used on a socket.
* If more than one tag is used on the socket, pass an array of security tags.
*
* A maximum of 8 tags can be set per socket.
*/
typedef uint32_t nrf_sec_tag_t;
/**@brief
* Session cache configuration for the TLS connection.
* - 0 - Disabled.
* - 1 - Enabled.
*
* By default, the session cache is enabled.
* @note Session cache, may not be used if the peer does not support it.
*/
typedef uint8_t nrf_sec_session_cache_t;
/**@brief
* Peer verification level for the TLS connection.
* - 0 - None.
* - 1 - Optional.
* - 2 - Required.
*
* By default, peer verification is optional.
*/
typedef uint32_t nrf_sec_peer_verify_t;
/**@brief
* A IANA cipher suite identifier.
*/
typedef uint32_t nrf_sec_cipher_t;
/**@brief Data type to combine all security configuration parameters. */
typedef struct {
/** Local role to be played. See nrf_sec_role_t for details. */
nrf_sec_role_t role;
/** Indicates the preference for peer verification. See nrf_sec_peer_verify_t for details. */
nrf_sec_peer_verify_t peer_verify;
/** Indicates the preference for session caching. See nrf_sec_session_cache_t for details. */
nrf_sec_session_cache_t session_cache;
/** Indicates the number of entries in the cipher list. */
uint32_t cipher_count;
/** Indicates the list of ciphers to be used for the session. See nrf_sec_cipher_t for details. */
nrf_sec_cipher_t *p_cipher_list;
/** Indicates the number of entries in the sec tag list. */
uint32_t sec_tag_count;
/** Indicates the list of security tags to be used for the session. See nrf_sec_tag_t for details. */
nrf_sec_tag_t *p_sec_tag_list;
} nrf_sec_config_t;
#define NRF_IFNAMSIZ 64
/**@brief Data type for network interface. */
struct nrf_ifreq {
char ifr_name[NRF_IFNAMSIZ]; /* Interface name */
};
/**@} */
/**@addtogroup nrf_socket_pdn
* @brief Data types defined to set and get socket options on a PDN socket.
* @{
*/
/**@brief
* List of address family(ies) for the PDN.
*/
typedef nrf_sa_family_t *nrf_pdn_af_list_t;
/**@brief
* Context ID for the PDN.
*/
typedef uint8_t nrf_pdn_context_id_t;
/**@brief
* PDN state.
* 1 - PDN is active.
* 0 - PDN is inactive.
*/
typedef uint8_t nrf_pdn_state_t;
/**@brief
* PDN authentication type.
*/
typedef enum {
NRF_PDN_AUTH_TYPE_NONE = 0,
NRF_PDN_AUTH_TYPE_PAP,
NRF_PDN_AUTH_TYPE_CHAP
} nrf_pdn_auth_type_t;
/**@brief
* Structure for PDN authentication socket option.
*/
typedef struct {
char username[NRF_PDN_MAX_USERNAME_LEN];
char password[NRF_PDN_MAX_PASSWORD_LEN];
nrf_pdn_auth_type_t authentication_type;
} nrf_pdn_auth_t;
/**@} */
/**@addtogroup nrf_socket_dfu
* @{
*/
/**@brief
* Universally unique identifier of the modem firmware version.
* The UUID format is defined by RFC 4122.
*/
typedef uint8_t nrf_dfu_fw_version_t[36];
/**@brief
* Maximum size for a firmware image, in bytes.
*/
typedef uint32_t nrf_dfu_resources_t;
/**@brief
* Size of the firmware image stored in flash, in bytes.
*/
typedef uint32_t nrf_dfu_fw_offset_t;
/**@defgroup nrf_dfu_errors DFU errors
* @brief DFU socket errors.
* @{
*/
/**@brief DFU socket error. */
typedef int32_t nrf_dfu_err_t;
#define DFU_NO_ERROR 0
#define DFU_RECEIVER_OUT_OF_MEMORY -1
#define DFU_RECEIVER_BLOCK_TOO_LARGE -2
#define DFU_INVALID_HEADER_DATA -3
#define DFU_ERROR_INTERNAL_00 -4
#define DFU_INVALID_DATA -5
#define DFU_ERROR_INTERNAL_01 -6
#define DFU_ERROR_INTERNAL_02 -7
#define DFU_ERROR_INTERNAL_03 -8
#define DFU_INVALID_UUID -9
#define DFU_INVALID_ADDRESS -10
#define DFU_AREA_NOT_BLANK -11
#define DFU_WRITE_ERROR -12
#define DFU_ERASE_ERROR -13
#define DFU_INVALID_FILE_OFFSET -14
#define DFU_PROGRESS_LOG_INVALID -15
#define DFU_INVALID_RESUME_ATTEMPT -16
#define DFU_ERASE_PENDING -17
#define DFU_OPERATION_NOT_ALLOWED -18
#define DFU_INCOMPLETE_DATA -19
#define DFU_INTERRUPTED_WRITE -20
/** @} */
/** @} */
/**@defgroup nrf_socket_gnss_data_frame GNSS data frames
* @brief GNSS Data frame formats. All data frames will be wrapped with the nrf_gnss_data_frame_t which will identify the frame type in the
* data_id struct element.
* @{
*/
#define NRF_GNSS_MAX_SATELLITES 12
typedef struct {
/** 4-digit representation (Gregorian calendar). */
uint16_t year;
/** 1...12 */
uint8_t month;
/** 1...31 */
uint8_t day;
/** 0...23 */
uint8_t hour;
/** 0...59 */
uint8_t minute;
/** 0...59 */
uint8_t seconds;
/** 0...999 */
uint16_t ms;
} nrf_gnss_datetime_t;
typedef struct {
/** SV number 1...32 for GPS. */
uint16_t sv;
/** Signal type. 0: invalid, 1: GPS L1C/A, other values are reserved for other GNSSes or signals. */
uint8_t signal;
/** 0.1 dB/Hz. */
uint16_t cn0;
/** SV elevation angle in degrees. */
int16_t elevation;
/** SV azimuth angle in degrees. */
int16_t azimuth;
/** Bit mask of measurement and position computation flags. */
uint8_t flags;
} nrf_gnss_sv_t;
typedef struct {
/** Latitude in degrees. */
double latitude;
/** Longitude in degrees. */
double longitude;
/** Altitude above WGS-84 ellipsoid in meters. */
float altitude;
/** Accuracy (2D 1-sigma) in meters. */
float accuracy;
/** Horizontal speed in meters. */
float speed;
/** Heading of user movement in degrees. */
float heading;
nrf_gnss_datetime_t datetime;
/** Position dilution of precision. */
float pdop;
/** Horizontal dilution of precision. */
float hdop;
/** Vertical dilution of precision. */
float vdop;
/** Time dilution of precision. */
float tdop;
/** Bit 0 (LSB): fix validity. Bit 1: Leap second validity. Bit 2: If set, the GNSS operation is blocked, for example, by LTE. */
uint8_t flags;
/** Describes up to 12 of the space vehicles used for the measurement. */
nrf_gnss_sv_t sv[NRF_GNSS_MAX_SATELLITES];
} nrf_gnss_pvt_data_frame_t;
#define NRF_GNSS_NMEA_MAX_LEN 83
/**@brief Single null-terminated NMEA sentence
*/
typedef char nrf_gnss_nmea_data_frame_t[NRF_GNSS_NMEA_MAX_LEN];
#define NRF_GNSS_AGPS_GPS_UTC_REQUEST 0
#define NRF_GNSS_AGPS_KLOBUCHAR_REQUEST 1
#define NRF_GNSS_AGPS_NEQUICK_REQUEST 2
#define NRF_GNSS_AGPS_SYS_TIME_AND_SV_TOW_REQUEST 3
#define NRF_GNSS_AGPS_POSITION_REQUEST 4
#define NRF_GNSS_AGPS_INTEGRITY_REQUEST 5
/**@brief AGPS notification data frame used by the GPS module to let the application know it needs new APGS data.
*/
typedef struct {
/** Bit mask indicating the satellite PRNs for which the assistance GPS ephemeris data is needed. */
uint32_t sv_mask_ephe;
/** Bit mask indicating the satellite PRNs for which the assistance GPS almanac data is needed. */
uint32_t sv_mask_alm;
/** Indicating other AGPS data models is needed by the GNSS module */
uint32_t data_flags;
} nrf_gnss_agps_data_frame_t;
#define NRF_GNSS_PVT_DATA_ID 1
#define NRF_GNSS_NMEA_DATA_ID 2
#define NRF_GNSS_AGPS_DATA_ID 3
/**@brief Wrapper struct that used for all data frames read from the GNSS module
*/
typedef struct {
uint8_t data_id;
union {
/** PVT (Position, Velocity, and Time) data notification frame */
nrf_gnss_pvt_data_frame_t pvt;
/** NMEA data notification frame */
nrf_gnss_nmea_data_frame_t nmea;
/** AGPS data request notification */
nrf_gnss_agps_data_frame_t agps;
};
} nrf_gnss_data_frame_t;
/** @} */
/**@defgroup nrf_socket_gnss_data_agps AGPS data types
* @ingroup nrf_socket_gnss_agps
* @brief AGPS Data types.
* @{
*/
/**@brief Type used to select which AGPS data is written to the GPS module.
* @details Goes into the @c p_servaddr parameter in the @c nrf_sendto function prototype. Possible values:
* - @c NRF_GNSS_AGPS_UTC_PARAMETERS
* - @c NRF_GNSS_AGPS_EPHEMERIDE
* - @c NRF_GNSS_AGPS_ALMANAC
* - @c NRF_GNSS_AGPS_KLOBUCHAR_IONOSPHERIC_CORRECTION
* - @c NRF_GNSS_AGPS_NEQUICK_IONOSPHERIC_CORRECTION
* - @c NRF_GNSS_AGPS_GPS_SYSTEM_CLOCK_AND_TOWS
* - @c NRF_GNSS_AGPS_LOCATION
* - @c NRF_GNSS_AGPS_INTEGRITY
*/
typedef uint16_t nrf_gnss_agps_data_type_t;
typedef struct {
/** First order term of polynomial (sec/sec). Scale factor 2^-50. Range -8388608...8388607 (25 bits). */
int32_t a1;
/** Constant term of polynomial (sec). Scale factor 2^-30. */
int32_t a0;
/** UTC reference GPS time-of-week (sec). Scale factor 2^12. Range 0..147. */
uint8_t tot;
/** UTC reference GPS week number modulo 256. */
uint8_t wn_t;
/** Current or past leap second count (sec). */
int8_t delta_tls;
/** Leap second reference GPS week number modulo 256. */
uint8_t wn_lsf;
/** Leap second reference GPS day-of-week (day). Range 1...7. */
int8_t dn;
/** Current or future leap second count (sec) (total size of the type-specific assistance data). */
int8_t delta_tlsf;
} nrf_gnss_agps_data_utc_t;
typedef struct {
/** Satellite ID (dimensionless). Range 1...32. */
uint8_t sv_id;
/** Satellite health (dimensionless). */
uint8_t health;
/** Issue of data, clock parameters (dimensionless). Range 0...2047 (11 bits). */
uint16_t iodc;
/** Clock parameters reference GPS time-of-week (sec). Scale factor 2^4. Range 0...37799. */
uint16_t toc;
/** Clock drift rate (sec/sec2). Scale factor 2^-55. */
int8_t af2;
/** Clock drift (sec/sec). Scale factor 2^-43. */
int16_t af1;
/** Clock bias (sec). Scale factor 2^-31. Range -2097152...2097151 (22 bit) */
int32_t af0;
/** Group delay (sec). Scale factor 2^-31. */
int8_t tgd;
/** URA index (dimensionless). Range 0...15. */
uint8_t ura;
/** Curve fit interval indication. Range 0...1. */
uint8_t fit_int;
/** Ephemeris parameters reference GPS time-of-week (sec). Scale factor 2^4. Range 0...37799. */
uint16_t toe;
/** Argument of perigee (semi-circle). Scale factor 2^-31. */
int32_t w;
/** Mean motion difference (semi-circle/sec). Scale factor 2^-43. */