Skip to content

Commit 70bb851

Browse files
author
Amanda Butler
authored
Merge pull request #482 from theotherjimmy/cleanup-platform
Platform docs cleanup
2 parents ac4e6ad + cad094d commit 70bb851

File tree

3 files changed

+60
-234
lines changed

3 files changed

+60
-234
lines changed

docs/reference/api/platform/ATCmdParser.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<span class="images">![](https://os-doc-builder.test.mbed.com/docs/development/mbed-os-api-doxy/classmbed_1_1_a_t_cmd_parser.png)<span>ATCmdParser class hierarchy</span></span>
44

5-
ATCmdParser is an Mbed OS compatible AT command parser. AT commands are instructions used to communicate with a communication device such as a modem, phone or Wi-Fi module. Each command is a text string in ASCII format, and every command starts with "AT" characters followed by a command specifying the operation to be carried out.
5+
ATCmdParser is an Mbed OS compatible AT command parser and serializer. AT commands are instructions used to communicate with a communication device such as a modem, phone or Wi-Fi module. Each command is a text string in ASCII format, and every command starts with "AT" characters followed by a command specifying the operation to be carried out.
66

77
The ATCmdParser class in Mbed OS implements functionality to send and receive AT commands to devices capable of communicating using AT commands. The ATCmdParser internally uses the driver for the communication channel to talk to the device. It expects the driver to implement the FileHandle interface to invoke the functions on the driver.
88

docs/reference/api/platform/Callback.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,34 @@ This is the technical reference for callbacks. You should read the [Callbacks](/
1313

1414
### Thread example with callbacks
1515

16-
The Callback API provides a convenient way to pass arguments to spawned threads.
16+
The Callback API provides a convenient way to pass arguments to spawned threads. This example uses a C function pointer in the Callback.
1717

1818
[![View code](https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/rtos_threading_with_callback/)](https://os.mbed.com/teams/mbed_example/code/rtos_threading_with_callback/file/d4b2a035ffe3/main.cpp)
1919

2020
### Sonar example
2121

22-
Here is an example that uses everything discussed in the [introduction to callbacks](/docs/development/reference/platform.html#callbacks) document in the form of a minimal Sonar class.
22+
Here is an example that uses everything discussed in the [introduction to callbacks](/docs/development/reference/platform.html#callbacks) document in the form of a minimal Sonar class. This example uses a C++ class and method in the Callback.
2323

2424
[![View code](https://www.mbed.com/embed/?url=https://os.mbed.com/teams/mbed_example/code/callback-sonar-example/)](https://os.mbed.com/teams/mbed_example/code/callback-sonar-example/file/1713cdc51510/main.cpp)
2525

26-
### Related content
26+
### Calling callbacks
2727

28-
- [Platform overview](/docs/development/reference/platform.html).
29-
- [Introduction to callbacks](/docs/development/reference/platform.html#callbacks).
28+
Callbacks overload the function call operator, so you can call a Callback like you would a normal function:
29+
30+
```c++
31+
void run_timer_event(Callback<void(float)> on_timer) {
32+
on_timer(1.0f);
33+
}
34+
```
35+
36+
The only thing to watch out for is that the Callback type has a null Callback, just like a null function pointer. Uninitialized callbacks are null and assert if you call them. If you want a call to always succeed, you need to check if it is null first.
37+
38+
``` c++
39+
void run_timer_event(Callback<void(float)> on_timer) {
40+
if (on_timer) {
41+
on_timer(1.0f);
42+
}
43+
}
44+
```
45+
46+
The Callback class is what’s known in C++ as a “Concrete Type”. That is, the Callback class is lightweight enough to be passed around like an int, pointer or other primitive type.

0 commit comments

Comments
 (0)