@@ -109,7 +109,7 @@ class NanostackSocket {
109
109
110
110
static NanostackSocket * socket_tbl[NS_INTERFACE_SOCKETS_MAX];
111
111
112
- static int map_mesh_error (mesh_error_t err)
112
+ static nsapi_error_t map_mesh_error (mesh_error_t err)
113
113
{
114
114
switch (err) {
115
115
case MESH_ERROR_NONE: return 0 ;
@@ -163,7 +163,7 @@ NanostackSocket::~NanostackSocket()
163
163
close ();
164
164
}
165
165
if (socket_id >= 0 ) {
166
- int ret = socket_free (socket_id);
166
+ nsapi_error_t ret = socket_free (socket_id);
167
167
MBED_ASSERT (0 == ret);
168
168
MBED_ASSERT (socket_tbl[socket_id] == this );
169
169
socket_tbl[socket_id] = NULL ;
@@ -205,7 +205,7 @@ void NanostackSocket::close()
205
205
MBED_ASSERT (mode != SOCKET_MODE_CLOSED);
206
206
207
207
if (socket_id >= 0 ) {
208
- int ret = socket_close (socket_id, (addr_valid ? &ns_address : NULL ));
208
+ nsapi_error_t ret = socket_close (socket_id, (addr_valid ? &ns_address : NULL ));
209
209
MBED_ASSERT (0 == ret);
210
210
} else {
211
211
MBED_ASSERT (SOCKET_MODE_UNOPENED == mode);
@@ -462,7 +462,7 @@ MeshInterfaceNanostack::MeshInterfaceNanostack(NanostackRfPhy *phy)
462
462
// Nothing to do
463
463
}
464
464
465
- int MeshInterfaceNanostack::initialize (NanostackRfPhy *phy)
465
+ nsapi_error_t MeshInterfaceNanostack::initialize (NanostackRfPhy *phy)
466
466
{
467
467
if (this ->phy != NULL ) {
468
468
error (" Phy already set" );
@@ -482,7 +482,7 @@ void MeshInterfaceNanostack::mesh_network_handler(mesh_connection_status_t statu
482
482
nanostack_unlock ();
483
483
}
484
484
485
- int MeshInterfaceNanostack::register_rf ()
485
+ nsapi_error_t MeshInterfaceNanostack::register_rf ()
486
486
{
487
487
nanostack_lock ();
488
488
@@ -500,7 +500,7 @@ int MeshInterfaceNanostack::register_rf()
500
500
return 0 ;
501
501
}
502
502
503
- int MeshInterfaceNanostack::actual_connect ()
503
+ nsapi_error_t MeshInterfaceNanostack::actual_connect ()
504
504
{
505
505
nanostack_assert_locked ();
506
506
@@ -528,7 +528,7 @@ NetworkStack * MeshInterfaceNanostack::get_stack()
528
528
return NanostackInterface::get_stack ();
529
529
}
530
530
531
- int MeshInterfaceNanostack::disconnect ()
531
+ nsapi_error_t MeshInterfaceNanostack::disconnect ()
532
532
{
533
533
nanostack_lock ();
534
534
@@ -558,7 +558,7 @@ const char *MeshInterfaceNanostack::get_mac_address()
558
558
return mac_addr_str;
559
559
}
560
560
561
- int ThreadInterface::connect ()
561
+ nsapi_error_t ThreadInterface::connect ()
562
562
{
563
563
// initialize mesh networking resources, memory, timers, etc...
564
564
mesh_system_init ();
@@ -582,14 +582,14 @@ int ThreadInterface::connect()
582
582
nanostack_unlock ();
583
583
return map_mesh_error (status);
584
584
}
585
- int ret = this ->actual_connect ();
585
+ nsapi_error_t ret = this ->actual_connect ();
586
586
587
587
nanostack_unlock ();
588
588
589
589
return ret;
590
590
}
591
591
592
- int LoWPANNDInterface::connect ()
592
+ nsapi_error_t LoWPANNDInterface::connect ()
593
593
{
594
594
// initialize mesh networking resources, memory, timers, etc...
595
595
mesh_system_init ();
@@ -613,7 +613,7 @@ int LoWPANNDInterface::connect()
613
613
nanostack_unlock ();
614
614
return map_mesh_error (status);
615
615
}
616
- int ret = this ->actual_connect ();
616
+ nsapi_error_t ret = this ->actual_connect ();
617
617
618
618
nanostack_unlock ();
619
619
@@ -642,7 +642,7 @@ const char * NanostackInterface::get_ip_address()
642
642
return NULL ;
643
643
}
644
644
645
- int NanostackInterface::socket_open (void **handle, nsapi_protocol_t protocol)
645
+ nsapi_error_t NanostackInterface::socket_open (void **handle, nsapi_protocol_t protocol)
646
646
{
647
647
// Validate parameters
648
648
if (NULL == handle) {
@@ -683,7 +683,7 @@ int NanostackInterface::socket_open(void **handle, nsapi_protocol_t protocol)
683
683
return 0 ;
684
684
}
685
685
686
- int NanostackInterface::socket_close (void *handle)
686
+ nsapi_error_t NanostackInterface::socket_close (void *handle)
687
687
{
688
688
// Validate parameters
689
689
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -703,7 +703,7 @@ int NanostackInterface::socket_close(void *handle)
703
703
704
704
}
705
705
706
- int NanostackInterface::socket_sendto (void *handle, const SocketAddress &address, const void *data, unsigned int size)
706
+ nsapi_size_or_error_t NanostackInterface::socket_sendto (void *handle, const SocketAddress &address, const void *data, nsapi_size_t size)
707
707
{
708
708
// Validate parameters
709
709
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -718,7 +718,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
718
718
719
719
nanostack_lock ();
720
720
721
- int ret;
721
+ nsapi_size_or_error_t ret;
722
722
if (socket->closed ()) {
723
723
ret = NSAPI_ERROR_NO_CONNECTION;
724
724
} else if (NANOSTACK_SOCKET_TCP == socket->proto ) {
@@ -758,7 +758,7 @@ int NanostackInterface::socket_sendto(void *handle, const SocketAddress &address
758
758
return ret;
759
759
}
760
760
761
- int NanostackInterface::socket_recvfrom (void *handle, SocketAddress *address, void *buffer, unsigned size)
761
+ nsapi_size_or_error_t NanostackInterface::socket_recvfrom (void *handle, SocketAddress *address, void *buffer, nsapi_size_t size)
762
762
{
763
763
// Validate parameters
764
764
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -777,7 +777,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
777
777
778
778
nanostack_lock ();
779
779
780
- int ret;
780
+ nsapi_size_or_error_t ret;
781
781
if (socket->closed ()) {
782
782
ret = NSAPI_ERROR_NO_CONNECTION;
783
783
} else if (NANOSTACK_SOCKET_TCP == socket->proto ) {
@@ -796,7 +796,7 @@ int NanostackInterface::socket_recvfrom(void *handle, SocketAddress *address, vo
796
796
return ret;
797
797
}
798
798
799
- int NanostackInterface::socket_bind (void *handle, const SocketAddress &address)
799
+ nsapi_error_t NanostackInterface::socket_bind (void *handle, const SocketAddress &address)
800
800
{
801
801
// Validate parameters
802
802
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -823,7 +823,7 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
823
823
ns_address.type = ADDRESS_IPV6;
824
824
memcpy (ns_address.address , addr_field, sizeof ns_address.address );
825
825
ns_address.identifier = address.get_port ();
826
- int ret = NSAPI_ERROR_DEVICE_ERROR;
826
+ nsapi_error_t ret = NSAPI_ERROR_DEVICE_ERROR;
827
827
if (0 == ::socket_bind (socket->socket_id , &ns_address)) {
828
828
socket->set_bound ();
829
829
ret = 0 ;
@@ -836,22 +836,22 @@ int NanostackInterface::socket_bind(void *handle, const SocketAddress &address)
836
836
return ret;
837
837
}
838
838
839
- int NanostackInterface::setsockopt (void *handle, int level, int optname, const void *optval, unsigned optlen)
839
+ nsapi_error_t NanostackInterface::setsockopt (void *handle, int level, int optname, const void *optval, unsigned optlen)
840
840
{
841
841
return NSAPI_ERROR_UNSUPPORTED;
842
842
}
843
843
844
- int NanostackInterface::getsockopt (void *handle, int level, int optname, void *optval, unsigned *optlen)
844
+ nsapi_error_t NanostackInterface::getsockopt (void *handle, int level, int optname, void *optval, unsigned *optlen)
845
845
{
846
846
return NSAPI_ERROR_UNSUPPORTED;
847
847
}
848
848
849
- int NanostackInterface::socket_listen (void *handle, int backlog)
849
+ nsapi_error_t NanostackInterface::socket_listen (void *handle, int backlog)
850
850
{
851
851
return NSAPI_ERROR_UNSUPPORTED;
852
852
}
853
853
854
- int NanostackInterface::socket_connect (void *handle, const SocketAddress &addr)
854
+ nsapi_error_t NanostackInterface::socket_connect (void *handle, const SocketAddress &addr)
855
855
{
856
856
// Validate parameters
857
857
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -866,7 +866,7 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
866
866
867
867
nanostack_lock ();
868
868
869
- int ret;
869
+ nsapi_error_t ret;
870
870
ns_address_t ns_addr;
871
871
int random_port = socket->is_bound () ? 0 : 1 ;
872
872
convert_mbed_addr_to_ns (&ns_addr, &addr);
@@ -884,12 +884,12 @@ int NanostackInterface::socket_connect(void *handle, const SocketAddress &addr)
884
884
return ret;
885
885
}
886
886
887
- int NanostackInterface::socket_accept (void *server, void **handle, SocketAddress *address)
887
+ nsapi_error_t NanostackInterface::socket_accept (void *server, void **handle, SocketAddress *address)
888
888
{
889
889
return NSAPI_ERROR_UNSUPPORTED;
890
890
}
891
891
892
- int NanostackInterface::socket_send (void *handle, const void *p, unsigned size)
892
+ nsapi_size_or_error_t NanostackInterface::socket_send (void *handle, const void *p, nsapi_size_t size)
893
893
{
894
894
// Validate parameters
895
895
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -900,7 +900,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
900
900
901
901
nanostack_lock ();
902
902
903
- int ret;
903
+ nsapi_size_or_error_t ret;
904
904
if (socket->closed ()) {
905
905
ret = NSAPI_ERROR_NO_CONNECTION;
906
906
} else if (socket->is_connecting ()) {
@@ -933,7 +933,7 @@ int NanostackInterface::socket_send(void *handle, const void *p, unsigned size)
933
933
return ret;
934
934
}
935
935
936
- int NanostackInterface::socket_recv (void *handle, void *data, unsigned size)
936
+ nsapi_size_or_error_t NanostackInterface::socket_recv (void *handle, void *data, nsapi_size_t size)
937
937
{
938
938
// Validate parameters
939
939
NanostackSocket * socket = static_cast <NanostackSocket *>(handle);
@@ -944,7 +944,7 @@ int NanostackInterface::socket_recv(void *handle, void *data, unsigned size)
944
944
945
945
nanostack_lock ();
946
946
947
- int ret;
947
+ nsapi_size_or_error_t ret;
948
948
if (socket->closed ()) {
949
949
ret = NSAPI_ERROR_NO_CONNECTION;
950
950
} else if (socket->data_available ()) {
0 commit comments