-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving AtClient to a separate library. (#2497)
* Initial refactoring. * Add sample. * Add documentation.
- Loading branch information
Showing
11 changed files
with
190 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
At Client | ||
========= | ||
|
||
.. highlight:: c++ | ||
|
||
Introduction | ||
------------ | ||
|
||
AT commands were initially instructions used to control a modem. AT is the abbreviation of ATtention. | ||
Every command line starts with "AT" or "at". | ||
If interested a good background article is `Hayes Command Set <https://en.wikipedia.org/wiki/Hayes_command_set>`__. | ||
|
||
Nowadays also other devices allow communication via AT commands as for example GSM/GPRS modems, GPS trackers, web cameras and more. | ||
|
||
This library simplifies the communication with such devices. | ||
|
||
Usage | ||
----- | ||
|
||
1. Add ``COMPONENT_DEPENDS += AtClient`` to your application componenent.mk file. | ||
2. Add these lines to your application:: | ||
|
||
#include <AtClient.h> | ||
namespace | ||
{ | ||
AtClient* atClient; | ||
// ... | ||
} // namespace | ||
void init() | ||
{ | ||
Serial.begin(SERIAL_BAUD_RATE); | ||
Serial.systemDebugOutput(true); | ||
|
||
atClient = new AtClient(Serial); | ||
atClient->send("ATE0\r"); | ||
// ... | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
COMPONENT_SRCDIRS := src | ||
COMPONENT_INCDIRS := $(COMPONENT_SRCDIRS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
##################################################################### | ||
#### Please don't change this file. Use component.mk instead #### | ||
##################################################################### | ||
|
||
ifndef SMING_HOME | ||
$(error SMING_HOME is not set: please configure it as an environment variable) | ||
endif | ||
|
||
include $(SMING_HOME)/project.mk |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Webcam | ||
====== | ||
|
||
Sample demonstrating communication with a web camera via AT commands using :library:`AtClient` library. | ||
The complete set of commands for the sample web camera are in the docs/ directory. | ||
|
||
More about the web camera module and commands can be found `here <https://raymondtunning.wordpress.com/2016/09/08/a20-the-new-gprsgsm-product/>`__. |
Empty file.
56 changes: 56 additions & 0 deletions
56
Sming/Libraries/AtClient/samples/Webcam/app/application.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <SmingCore.h> | ||
#include <AtClient.h> | ||
|
||
AtClient* atClient; | ||
|
||
namespace | ||
{ | ||
int pictureSize; | ||
|
||
bool processSize(AtClient& atClient, String& reply) | ||
{ | ||
/* | ||
* ================ | ||
AT+CAMCAP capture picture | ||
Set Command: | ||
Capture and store a Picture local and returns bytes of captured picture | ||
AT+CAMCAP | ||
+CAMCAP:<bytes> | ||
OK | ||
on error: | ||
+CME ERROR: | ||
* ================ | ||
*/ | ||
if(reply.indexOf("+CME ERROR") == 0) { | ||
debug_e("Unable to capture image"); | ||
return false; | ||
} | ||
|
||
// Read the size of the captured image | ||
String length = reply.substring(8); | ||
pictureSize = atoi(length.c_str()); | ||
|
||
debug_d("Picture size: %d", pictureSize); | ||
|
||
return true; | ||
} | ||
|
||
} // namespace | ||
|
||
void init() | ||
{ | ||
Serial.begin(SERIAL_BAUD_RATE); | ||
Serial.systemDebugOutput(true); | ||
Serial.swap(); //swap to GPIO13 and GPIO15 | ||
|
||
atClient = new AtClient(Serial); | ||
|
||
// The commands below will be queued and executed | ||
// in the same order as defined below. | ||
// One command needs to finish successfully in order for the next one to start. | ||
atClient->send("ATE0\r"); | ||
atClient->send("AT+CAMSTOP\r"); | ||
|
||
atClient->send("AT+CAMSTART=1\r"); | ||
atClient->send("AT+CAMCAP\r", processSize); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## If project doesn't require networking, saves RAM and build time | ||
DISABLE_NETWORK := 1 | ||
COMPONENT_DEPENDS := AtClient |
Binary file not shown.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.