Commit Graph

191 Commits (c356f1f9d45a366fa1a89025e39b3aed54860db8)

Author SHA1 Message Date
Teppo Järvelin 89843246ac Separated context activation from connect, increased stack size to 2048 to avoid stack underflows and changed connection callback call. 2018-04-11 09:31:44 +03:00
Teppo Järvelin 83ea9be5f5 temp commit while changing work... 2018-04-11 09:31:44 +03:00
Teppo Järvelin 1661fc2744 Modified state machine, added cellular state and callback. 2018-04-11 09:31:44 +03:00
Max Payne bd47110554 Fix IPv4 address parsing due to not-so-portable scanf modifier
Bug is raised when using newlib-based toolchains.
%hh format is only avaliable in scanf if newlib is compiled
with _WANT_IO_C99_FORMATS option.
2018-04-02 23:33:21 +03:00
Cruz Monrreal 7c30faf69d
Merge pull request #6264 from jarvte/master
Deprecated warnings for feature/netsocket/cellular
2018-03-16 13:32:09 -05:00
Cruz Monrreal 9cac3b2f6b
Merge pull request #6149 from bmcdonnell-ionx/typos
Fix typos in the files
2018-03-15 10:53:03 -05:00
Teppo Järvelin 53455c5528 Fixed correct includes so that compile log is not polluted. 2018-03-13 16:23:15 +02:00
Teppo Järvelin 16e8b77474 PR review findings, updated deprecated comments. 2018-03-13 13:15:29 +02:00
Antti Kauppila 783d0c58f5 MBED_DEPRECATED_SINCE taken into use 2018-03-13 13:15:29 +02:00
Teppo Järvelin 7fd6b71337 Moved APN_db.h under new cellular. 2018-03-13 13:15:29 +02:00
Teppo Järvelin bee31ad1b3 Added deprecation notes to old cellular interfaces. 2018-03-13 13:15:29 +02:00
Amanda Butler a302a4be6d Copy edit OnboardCellularInterface.h
Copy edit file for active voice and removal of Latin abbreviations.
2018-03-02 14:38:08 +02:00
Ari Parkkila e53b93114e Typedef OnboardCellularInterface to EasyCellularConnection 2018-03-02 14:38:07 +02:00
Rob Meades 2fe3223612 Make MBED_CONF_PPP_CELL_IFACE_APN_LOOKUP default in mbed_lib.json while
ensuring that, if there is a user-specified APN, it is still used.
2018-02-26 11:33:40 +00:00
Teemu Kultala 34ef11630c fix issue 6150 by always setting net interface UP in mbed_set_dhcp 2018-02-22 13:00:46 +02:00
Brendan McDonnell c4f10aafee typos 2018-02-20 20:11:19 -05:00
Jarno Lamsa 8bea5ef438 Add some documentation for the callback 2018-02-12 11:02:07 +02:00
Teemu Kultala 5a7482667e NSAPI status callback changes
This is the original content of feature-status-callbacks, reviewed in
https://github.com/ARMmbed/mbed-os/pull/5457
2018-02-09 12:44:31 +02:00
Kevin Bracey 15a3922f58 Correct return value of nsapi_dns_query_multiple
Documentation states that nsapi_dns_query_multiple returns the number of
addresses found on success - it was returning 0.

Overloads using SocketAddress are relying on the return value, meaning
those calls didn't work at all.

Fixes #5921.
2018-01-26 14:08:29 +02:00
Seppo Takalo 6bf0611748 Clarify TCPSocket::recv() and UDPSocket::recvfrom() documentation. 2018-01-12 12:03:56 +02:00
Kevin Bracey 67b97d39c4 Make TCPSocket send all data when blocking
Previously, send() was somewhat soft - it only ever made one send
call to the underlying stack, so it would typically take as much data
as would fit in the buffer, and only block if it was unable to write
anything.

This is not the intent of a POSIX socket/filehandle write. It should try
to send everything if blocking, and only send less if interrupted by a
signal:

 - If the O_NONBLOCK flag is clear, write() shall block the calling
   thread until the data can be accepted.

 - If the O_NONBLOCK flag is set, write() shall not block the thread.
   If some data can be written without blocking the thread, write()
   shall write what it can and return the number of bytes written.
   Otherwise, it shall return -1 and set errno to [EAGAIN].

This "send all" behaviour is of slightly limited usefulness in POSIX, as
you still usually have to worry about the interruption possibility:

  - If write() is interrupted by a signal before it writes any data, it
    shall return -1 with errno set to [EINTR].

  - If write() is interrupted by a signal after it successfully writes
    some data, it shall return the number of bytes written.

But as mbed OS does not have the possibility of signal interruption, if we
strengthen send to write everything, we can make applications' lives
easier - they can just do "send(large amount)" confident that it will
all go in one call (if no errors).

So, rework to make multiple sends to the underlying stack, blocking as
necessary, until all data is written.

This change does not apply to recv(), which is correct in only blocking until
some data is available:

 - If O_NONBLOCK is set, read() shall return -1 and set errno to [EAGAIN].

 - If O_NONBLOCK is clear, read() shall block the calling thread until some
   data becomes available.

 - The use of the O_NONBLOCK flag has no effect if there is some data
   available.
2017-11-21 09:51:36 +02:00
Kevin Gilbert b56ced249a Add multicast implementation for UDPSocket. IPv4 and IPv6 both supported. 2017-10-10 18:21:18 -05:00
Jimmy Brisson 908a05b231 Merge pull request #5016 from u-blox/apndb_fix
Fix cellular APN_db.h lookup.
2017-09-27 09:06:46 -05:00
Hasnain Virk 8c9a0b3aa5 Seperatig string literal from macro
From C++11 and beyond string literals must be seperated by space
so that they are recongizable as seperate tokens.

Context macro in PPPCellularInterface (CTX) has been causing issues
as it was not augmented with a space from a nearby string literal.
2017-09-15 17:39:46 +03:00
adbridge 6bd28ecb68 Remove string literal values and revert back to using CTX macro .
The previous fix to replace CTX with string literals was the wrong
solution. All that was actually required was to insert a space before
the macro.
2017-09-11 11:13:54 +01:00
Deepika 0132d31124 Fix IAR8 : user-defined literal operator not found
Cellular example had build issues with IAR8, combination of define and string
as argument to send function resulted in above error. Typecasting to const char *
didn't help, hence replacing the define explicitly.
2017-09-10 09:58:34 -05:00
Rob Meades bce900d8f7 Fix cellular APN_db.h lookup. 2017-09-05 11:50:51 +01:00
Martin Kojtal abafc6e7df Merge pull request #4580 from deepikabhavnani/wifi_34
Use EventFlags instead of Semaphores
2017-09-04 16:54:55 +01:00
Deepika beb5aac640 RTOS: Add EventFlags class
EventFlags class is a wrapper for Event Flag functionality introduced in
RTOS2/RTX5.
2017-08-29 14:07:44 -05:00
Mika Leppänen dd346ec5a8 Either ipv4 or ipv4v6 PPP and IP stacks are enabled based on 3GPP context 2017-08-22 13:14:41 +03:00
Russ Butler 026df0b7cd Turn on doxygen for DEVICE_* features
Enable doxygen for all device features. Also fix the warnings that
showed up once this was enabled.
2017-08-11 15:47:44 -05:00
Martin Kojtal 334c02f7d4 Cellular: not-supported error if MODEM_ON_BOARD not defined
If a test is empty, it leads to undef. Therefore if a test requires additional
details, it should print an error [NOT SUPPORTED].
2017-06-30 10:01:46 +01:00
Jimmy Brisson 8f42c87ab7 Merge pull request #4446 from hasnainvirk/add_cellular_unit_tests
Customer port verification tests for cellular
2017-06-29 11:04:56 -05:00
Hasnain Virk 09b07a49a6 Customer port verification tests for cellular
Basic TCP/UDP tests for PPP based onboard cellular modems.
Tests basic public APIs defined in CellularBase.h
A customer port must pass this test set, hence verifying their
particular implementation.
2017-06-07 14:57:48 +03:00
Jimmy Brisson aabecf633b Remove doxygen warnings in nsapi 2017-06-05 17:32:46 -05:00
Sam Grove 5f138810a9 Merge pull request #4294 from ARMmbed/feature_cmsis5
Update CMSIS-Core and RTX to version 5
2017-06-02 23:44:32 -05:00
Hasnain Virk 24de27c989 Major Refactoring & extensions
For keep supporting external APIs with the same name (supposedly there are a larger
number of users of those APIs), BufferedSerial and ATParser are being renamed.
BufferedSerial becomes UARTSerial, will complement a  future USBSerial etc.
ATParser becomes ATCmdParser.

* UARTSerial moves to /drivers

* APN_db.h is moved from platform to cellular/util/.

* Original CellularInterface is restored for backward compatability (again, supposedly there
  are users of that).

* A new file, CellularBase is added which will now servce as the base class for all
  upcoming drivers.

* Special restructuring for the driver has been undertaken. This makes a clear cut distinction
  between an on-board or an off-board implementation.
  	- PPPCellularInterface is a generic network interface that works with a generic FileHandle
          and PPP. A derived class is needed to pass that FileHandle.
        - PPPCellularInterface provides some base functionality like network registration, AT setup,
          PPP connection etc. Lower level job is delegated to the derived classes and various modem
          specific APIs are provided which are supposed to be overridden.
        - UARTCellularInterface is derived from PPPCellularInterface. It constructs a FileHandle and
          passes it back to PPPCellularInterface as well as provides modem hangupf functionality.
          In future we could proive a USBInterface that would derive from PPPCellularInterface and could
          pass the FileHandle back.
	- OnboardCellularInterface is derived from UARTCellularInterfae and provides hooks to
          the target provided implementation of onbard_modem_api.h. An off-board modem, i.e, a modem on
          a shield has to override the modem_init(), modem_power_up() etc as it cannot use
          onboard_modem_api.h.
2017-05-31 15:02:11 +03:00
Hasnain Virk 658ddf7c30 ARMCC link errors fixed, nsapi_ppp glue layer changed
GCC have not been capable enough to catch some linker errors which arose when
ethernet support for LWIP was disabled. Checks have been added to make sure that
unrefrenced code is not linked in.

nsapi_ppp glue layer is made more transparent to public cellular API. Storage of IP
addresses is removed. PPP layer already stores the addresses, so we pass the pointer back
to the upper layers.

If PPP is not used, we provide dummy functions.
2017-05-31 15:02:11 +03:00
Hasnain Virk 01088647b9 Finalizing the public API for Cellular
* state machine corrections
* adding various standard API methods
* Addition/revision/enhancement of the nsapi_ppp glue layer
* Turning off debug by default
2017-05-31 15:02:11 +03:00
Hasnain Virk 3b44f4758d Adding support for APN lookup
Mainly reutilizing code from ublox C027 support lib.
As we are using external PDP context, i.e., an external IP stack,
we will pass username and password to underlying stack running PPP.
We only support CHAP as the authentication protocol.
2017-05-31 15:02:11 +03:00
Hasnain Virk 87a4580e5f Bug fixes & state machine corrections
In case of carrier lost, we would like to inform PPP data pump.
That involved setting up link status flag down semaphores.
mbed_lwip_bringup() and mbed_lwip_bringdown() had been Ethernet specific only.
We extend these routines to support PPP as well. Currently we support only one interface
at a time. However, future enhancement to multi interface support should be trivial.
2017-05-31 15:02:11 +03:00
Kevin Bracey 7e3c529d21 Unify LWIP Ethernet and PPP initialisation 2017-05-31 15:02:11 +03:00
Bartek Szatkowski b793a3fb89 Update codebase for CMSIS5/RTX5
Update all of mbed-os to use RTX5.
2017-05-30 18:55:52 +01:00
Kevin Bracey 984e87d8e9 NSAPI - Don't send trailing garbage in DNS queries
Observed during investigation of
https://github.com/ARMmbed/mbed-os/issues/4246 - DNS queries sent
the entire buffer, not just the bit filled in.

Inefficient, especially for 6LoWPAN, and a security hole - the trailing
data could be previously-used heap.
2017-05-05 11:35:48 +03:00
Christopher Haster aff49d8d1e Renamed files in platform to match source names
critical.h     -> mbed_critical.h
sleep.h        -> mbed_sleep.h
toolchain.h    -> mbed_toolchain.h
rtc_time.h     -> mbed_rtc_time.h
semihost_api.h -> mbed_semihost_api.h
wait_api.h     -> mbed_wait_api.h
2017-02-22 18:17:54 -06:00
Sam Grove 6f6e5c478f Merge pull request #3784 from geky/nsapi-sigio
nsapi: Rename attach -> sigio to decrease confusion on its behaviour
2017-02-21 10:56:40 -06:00
Christopher Haster d4e686be63 nsapi: Renamed attach -> sigio to decrease confusion on its behaviour 2017-02-16 10:47:06 -06:00
Christopher Haster 417524f562 Callback: Adopt better use of assignment/call operators 2017-02-15 15:19:38 -06:00
Christopher Haster d741c135f4 nsapi: Changed initial state of sockets to allow events
Note, the registered callback is still disabled by a call to
socket_attach. This will avoid being called after the socket is closed
unless close is called from the attached callback, which is in irq
context.

As pointed out by kjbracey-arm, the previous behaviour was broken
for sockets that started out listening.
2017-01-20 07:58:34 -06:00
Martin Kojtal 131b23895c Merge pull request #3458 from hasnainvirk/nsapi_levels
[ONME-2844] Avoid option level collisions
2016-12-23 13:07:58 +00:00
Martin Kojtal bba527fdc2 Merge pull request #3457 from hasnainvirk/nsapi_connect
[ONME-2844] Supporting non-blocking connect()
2016-12-23 13:06:55 +00:00
Hasnain Virk fcd55fe65b [ONME-2844] Avoid option level collisions
To allow a network stack to support both NSAPI and its own options, try to make
sure the NSAPI levels don't collide with level numbers likely to be used by
network stacks.

Distinguish between socket and stack options, and tighten up documentation. Add
IP MRU stack options as an example (implementation not immediately planned for
any stack, but could be useful).
2016-12-20 14:03:23 +02:00
Hasnain Virk 35e4896ed3 [ONME-2844] Supporting non-blocking connect()
A few new error codes are added to nsapi_error_t and
support for non-blocking socket connect is added.
Nanostack's connect call will be non-blocking.
Whereas LWIP connect call is currently blocking, and it could be changed now
to be non-blocking.
2016-12-16 15:35:33 +02:00
Christopher Haster 3643b59109 nsapi - Fixed open/close issue in Socket
During open, the socket checked the internal stack variable,
assuming it would alway be null on a socket not connected to
the network. However, when a socket is closed, the stack variable
was not updated, causing the socket to incorrectly return a
parameter error if reopened.

The simple fix was to set the stack to null on close. A non-null
stack is a predicate for a non-null socket variable, so no additional
checks are needed in socket functions.
2016-12-08 16:14:15 -06:00
Bogdan Marinescu 337c1af22c Don't send events on close()
It's currently possible to generate a socket event when a non-blocking socket is closed:

1. _pending is set to 0 in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPSocket.cpp#L22
   when the socket is created.
2. close() calls event() in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/Socket.cpp#L66
3. event() increments _pending, and since _pending is 1 it will call _callback() in https://github.com/ARMmbed/mbed-os/blob/master/features/netsocket/TCPSocket.cpp#L167

However, if send() (for example) is called, this can happen:

- send() is called and sets _pending to 0.
- when the data is sent, event() is called, which sets _pending to 1 and calls _callback().
- if close() is called at this point, there won't be an event generated for close() anymore,
  since _pending will be set to 2.

Same thing for recv. Also, same thing for TCPServer and UDPSocket.

This PR changes the initial value of _pending to 1 instead of 0, so that
events are never generated for close().
2016-12-07 17:52:16 +02:00
Martin Kojtal 98029e3906 Merge pull request #3065 from geky/nsapi-remove-same-thread-asserts
nsapi - Remove assertions on same-thread send/recv
2016-11-16 17:41:13 +00:00
Anna Bridge 405f8937a7 Merge pull request #3191 from tung7970/fix-mbedos
Fix lwip_mac_address buffer overflow and set_ip_bytes out of bound access
2016-11-10 17:05:38 +00:00
Anna Bridge 5fd81b37c3 Merge pull request #3232 from geky/nsapi-fix-gethostbyname-unspec-literal
nsapi - Fix missing NSAPI_UNSPEC check in gethostbyname for ip literals
2016-11-10 16:54:27 +00:00
Bartek Szatkowski db15c1a0a3 WiFi: Minor fixes to docs and includes 2016-11-10 09:40:48 +00:00
Christopher Haster a3ad6181f4 nsapi - Fixed missing NSAPI_UNSPEC check in gethostbyname for ip literals 2016-11-08 18:05:35 -06:00
Martin Kojtal 96e1d5bd73 Merge pull request #3221 from andreaslarssonublox/ublox_odin_w2_drivers_update
u-blox odin w2 drivers update
2016-11-08 10:24:53 +00:00
Sam Grove 074555b715 Merge pull request #3113 from geky/static-assert
Add static assert macro
2016-11-07 10:25:17 -06:00
Christopher Haster 40836b11a5 nsapi - Removed assertions on same-thread send/recv
Initially these assertions were added to protected simultaneous
send/recv from the same socket when similarly purposed mutexes were
removed.

However, simultaneous send/recv can still be useful for UDP if the
payload is guaranteed to be less than the MTU across the entire
connection.
2016-11-07 09:43:09 -06:00
andreas.larsson e111810830 Added emac_stack_mem_copy. Needed by the u-blox ODIN-W2 driver. 2016-11-07 15:52:56 +01:00
Martin Kojtal 7eaf32baa0 Merge pull request #3075 from geky/nsapi-error-size-types-2
nsapi - Add standardized return types for size and errors
2016-11-07 11:13:40 +00:00
Tony Wu 70ad0f5226 netsocket - Fix set_ip_bytes out-of-bound access
set_ip_bytes() does a 16-byte memcpy from the input buffer to
the local nsapi_addr_t despite the address version.

If the address version is ipv4, the input buffer may only be
4-byte in size. This causes a out-of-bound access on the input buffer.

Signed-off-by: Tony Wu <tonywu@realtek.com>
2016-11-04 11:02:34 +08:00
Sam Grove 35dbb3f256 Merge pull request #3166 from kjbracey-arm/ipv6_dns_server
nsapi_dns: Provide 2 IPv6-hosted default servers
2016-11-03 02:17:52 -05:00
Christopher Haster ba748ac1f8 nsapi - Added standardized return types for size and errors
nsapi_error_t         - enum of errors or 0 for NSAPI_ERROR_OK
nsapi_size_t          - unsigned size of data that could be sent
nsapi_size_or_error_t - either a non-negative size or negative error
2016-11-02 15:25:22 -05:00
Christopher Haster 98db3ab1cb Adopted MBED_STATIC_ASSERT where possible 2016-11-01 21:39:48 -05:00
Sam Grove 7829b2f9bf Merge pull request #3161 from geky/nsapi-dns-version-heuristic
nsapi - Add better heuristic for the default record of DNS queries
2016-11-01 14:17:08 -05:00
Kevin Bracey aa583bd8ce nsapi_dns: Provide 2 IPv6-hosted default servers
Replace Comodo and OpenDNS IPv4 servers with Google and DNS.WATCH IPv6
servers, so IPv6-only devices (eg 6LoWPAN) have a default.

3 IPv4 resolvers should be plenty - existing code doesn't remember which
one last worked, so if early list entries were unreachable performance
would be consistently bad anyway. Replacing two entries avoids
increasing image size and RAM consumption.

On an IPv6-only or IPv4-only system, the sendto() for the wrong type of
address should fail immediately - change loop to move on to the next
server for any sendto() error.
2016-10-31 15:48:54 +02:00
Christopher Haster 42105371ef lwip/nsapi - Cleaned up warnings in network code
- cc.h@57,1: "BYTE_ORDER" redefined
- lwip_inet_chksum.c@560,44: passing argument 1 of 'thumb2_checksum'
  discards 'const' qualifier from pointer target type
- lwip_pbuf.c@1172,9: variable 'err' set but not used
- SocketAddress.cpp@293,1: control reaches end of non-void function
2016-10-28 14:24:52 -05:00
Christopher Haster d8d2b0a41d nsapi - Added better heuristic for the default record of DNS queries
Takes advantage of the get_ip_address function to predict the IP
address version wanted by the underlying interface. The should avoid
the need for most IPv6 interfaces to overload gethostbyname.

suggested by @kjbracey-arm
2016-10-28 11:41:33 -05:00
Martin Kojtal ba47aa546b Merge pull request #2897 from geky/nsapi-consistent-unspec
nsapi - Standardize support of NSAPI_UNSPEC
2016-10-27 10:26:00 +02:00
Christopher Haster cce82b13ac nsapi - Fixed unaligned writes from <word-sized scanf calls 2016-10-19 16:49:35 -05:00
Christopher Haster bf83cb28cd nsapi - Fixed leftover bytes from suffix during ipv6 parsing
Thanks to @EduardPon for hunting this down
2016-10-19 15:28:32 -05:00
Sam Grove 44dcb5f21f Merge pull request #2994 from 0xc0170/fix_issue#2993
lwip-interface: fix issue #2993
2016-10-13 11:14:10 -05:00
Martin Kojtal f8b682c943 lwip-interface: fix issue #2993
DEVICE_ are passed as command line -D, thus no inclusion is required.
``platform.h`` is C++ header file, should not be pulled in C files
2016-10-13 11:42:31 +01:00
Bartek Szatkowski 3d09b196b7 DNS: Rework DNS query
Don't ask multiple DNS servers in case of successful connection, even if
the response is negative. Make sure the return value is correct.
2016-10-11 10:53:05 -05:00
Bartek Szatkowski 922e9526bf DNS: Fix return value for successful name resolutions 2016-10-07 16:10:15 +01:00
Sam Grove 3a16ca9855 Merge pull request #2911 from theotherjimmy/docs-generation
[Tools] Add documentation generation script
2016-10-06 15:57:08 -05:00
Christopher Haster 1f4eb0aaa1 nsapi - Standardized support of NSAPI_UNSPEC
- Reordered nsapi_version_t to make defaule nsapi_addr_t NSAPI_UNSPEC
- Added support to NSAPI_UNSPEC in SocketAddress
2016-10-05 12:48:10 -05:00
Jimmy Brisson f1a78027d3 Add tags to our code 2016-10-04 15:02:44 -05:00
Christopher Haster 4f1ededb58 Renamed NSAPI_SECURITY_UNSUPPORTED -> NSAPI_SECURITY_UNKNOWN
Returning a wifi access point without information regarding the
security type is only valid if the security type is unknown (from
the perspective of the network-socket API). For clarity in situations
in which scan may return an unsupported, but known security type,
type name has been changed to NSAPI_SECURITY_UNKNOWN.
2016-10-04 14:23:36 -05:00
Bartek Szatkowski febc341672 Fix spelling error: NSAPI_SECURITY_UNSUPPORTED 2016-10-04 17:34:58 +01:00
andreas.larsson e87f013c4d Fixed missing public 2016-10-04 15:52:56 +02:00
andreas.larsson 8ea46eae17 Fixed missing abstract connect method 2016-10-04 15:52:55 +02:00
andreas.larsson b418fce8ac Added function for increasing ref count. 2016-10-04 15:52:55 +02:00
Christopher Haster 5cd2d7869e Merge remote-tracking branch 'upstream/master' into feature_wifi_ublox_merge 2016-10-02 07:29:07 -05:00
Christopher Haster c2d9fc29ff restructure - Fixed include paths damaged by the restructure 2016-09-30 19:18:09 -05:00
Christopher Haster ba99a1f31d restructure - Restructured features/net directory
features/net/network-socket -> features/netsocket
features/net/FEATURE_IPV4 -> features/FEATURE_LWIP
features/net/nanostack-binaries -> features/nanostack
features/net/FEATURE_NANOSTACK -> features/nanostack/FEATURE_NANOSTACK
2016-09-30 19:18:09 -05:00