Commit Graph

83 Commits (16e8b77474d0f243281fb12060ac867743bef259)

Author SHA1 Message Date
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
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