Skip to content

Commit 6423f69

Browse files
committed
MCU8MASS-979 Add SMS example sketch and .clang-tidy and .clang-format files
1 parent 7fac8c6 commit 6423f69

File tree

5 files changed

+174
-2
lines changed

5 files changed

+174
-2
lines changed

.clang-format

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
IndentWidth: 4
2+
AllowShortLoopsOnASingleLine: true
3+
AllowShortBlocksOnASingleLine: true
4+
ColumnLimit: 80
5+
BinPackParameters: false
6+
BinPackArguments: false
7+
AllowAllParametersOfDeclarationOnNextLine: false
8+
AlignConsecutiveMacros: true
9+
FixNamespaceComments: false
10+
NamespaceIndentation: All
11+
AlignConsecutiveAssignments: true
12+
AlignEscapedNewlines: true
13+
AlignOperands: Align
14+
AlignTrailingComments: true
15+
AllowAllArgumentsOnNextLine: false
16+
PenaltyBreakAssignment: 50
17+
PointerAlignment: Left
18+
ReferenceAlignment: Left

.clang-tidy

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Checks: "
2+
-*,
3+
clang-diagnostic-*,
4+
clang-analyzer-*,
5+
bugprone-*,
6+
cert-*-c,
7+
misc-*,
8+
performance-*,
9+
portability-*,
10+
readability-*,
11+
modernize-*,
12+
-modernize-avoid-c-arrays,
13+
-modernize-use-nullptr,
14+
-readability-identifier-length
15+
"
16+
WarningsAsErrors: true
17+
HeaderFilterRegex: ''
18+
AnalyzeTemporaryDtors: false
19+
20+
CheckOptions:
21+
- { key: readability-identifier-naming.NamespaceCase, value: lower_case }
22+
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
23+
- { key: readability-identifier-naming.StructCase, value: CamelCase }
24+
- { key: readability-identifier-naming.UnionCase, value: CamelCase }
25+
- { key: readability-identifier-naming.TemplateParameterCase, value: CamelCase }
26+
- { key: readability-identifier-naming.FunctionCase, value: camelCase }
27+
- { key: readability-identifier-naming.VariableCase, value: lower_case }
28+
- { key: readability-identifier-naming.MacroDefinitionCase, value: UPPER_CASE }
29+
- { key: readability-identifier-naming.ConstexprVariableCase, value: UPPER_CASE }
30+
- { key: readability-identifier-naming.ConstantCase, value: lower_case }
31+
- { key: readability-identifier-naming.ConstantParameterCase, value: lower_case }
32+
- { key: readability-identifier-naming.PointerParameterCase, value: CamelCase }
33+
- { key: readability-identifier-naming.PointerParameterPrefix, value: }
34+
- { key: readability-identifier-naming.EnumCase, value: CamelCase }
35+
- { key: readability-identifier-naming.EnumConstantCase, value: CamelCase }

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
.ccls
2-
build/
2+
.cache/
3+
.pytest_cache/
34
.ccls-cache
45
.vscode/c_cpp_properties.json
56
.vscode/arduino.json
67
deploy_sandbox
8+
build/
79
builds
810
lib/cryptoauth/cryptoauthlib
911
lib/cryptoauth/build48

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"C_Cpp.clang_format_fallbackStyle": "{ IndentWidth: 4, AllowShortLoopsOnASingleLine: true, AllowShortBlocksOnASingleLine: true, ColumnLimit: 80, BinPackParameters: false, BinPackArguments: false, AlignConsecutiveMacros: true, FixNamespaceComments: false, NamespaceIndentation: All, AlignConsecutiveAssignments: true, AlignEscapedNewlines: true, AlignOperands: Align, AlignTrailingComments: true, AllowAllParametersOfDeclarationOnNextLine: false, AllowAllArgumentsOnNextLine: false, PenaltyBreakAssignment: 50, PointerAlignment: Left, ReferenceAlignment: Left }",
44
"pytest.testing.cwd": "${workspaceFolder}/test",
55
"python.testing.pytestArgs": [
6-
"--port=COM14",
6+
"--port=COM31",
77
"--ignore=lib",
88
"-s"
99
],

examples/sms/sms.ino

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
/**
2+
* @brief This example demonstrates how to send SMS messages using the modem on
3+
* the AVR-IoT Cellular Mini.
4+
*/
5+
#include <Arduino.h>
6+
#include <led_ctrl.h>
7+
#include <log.h>
8+
#include <lte.h>
9+
#include <sequans_controller.h>
10+
11+
#define NUMBER "<FILL IN YOUR NUMBER WITH COUNTRY CODE, E.G., +4712345678>"
12+
13+
void setup() {
14+
LedCtrl.begin();
15+
LedCtrl.startupCycle();
16+
17+
Log.begin(115200);
18+
Log.rawf(F("\r\n\r\n"));
19+
Log.info(F("Starting SMS example. NOTE THAT THE TRUPHONE SIM CARD DOES NOT "
20+
"SUPPORT SENDING SMS TO OTHER NUMBERS THAN ITS IOT CONNECT HUB "
21+
"(NUMBER: 6260). USE ANOTHER SIM CARD WITH COMBINED DATA+SMS TO "
22+
"SEND SMS."));
23+
24+
if (!SequansController.begin()) {
25+
Log.error(F("Failed to start the modem"));
26+
return;
27+
}
28+
29+
char response[128] = "";
30+
31+
// Configure UE for EPS combined attach
32+
ResponseResult response_result = SequansController.writeCommand(
33+
F("AT+CEMODE=2"),
34+
response,
35+
sizeof(response));
36+
37+
if (response_result != ResponseResult::OK) {
38+
Log.errorf(F("Error writing combined attach command, the response was: "
39+
"%s\r\n"),
40+
response);
41+
return;
42+
}
43+
44+
// --- Start LTE modem and connect to the operator ---
45+
if (!Lte.begin()) {
46+
Log.error(F("Failed to connect to the operator"));
47+
return;
48+
}
49+
50+
// --- Configure the UE to work under SMS text mode ---
51+
response_result = SequansController.writeCommand(F("AT+CMGF=1"),
52+
response,
53+
sizeof(response));
54+
55+
if (response_result != ResponseResult::OK) {
56+
Log.errorf(F("Failed to configure the UE to work under SMS text mode, "
57+
"the response was: %s\r\n"),
58+
response);
59+
return;
60+
}
61+
62+
// --- Query the SMS service centre address to configure it is already
63+
// correctly configured ---
64+
response_result = SequansController.writeCommand(F("AT+CSCA?"),
65+
response,
66+
sizeof(response));
67+
68+
if (response_result != ResponseResult::OK) {
69+
Log.errorf(F("Failed to query the SMS service centre address, the "
70+
"response was: %s\r\n"),
71+
response);
72+
return;
73+
} else {
74+
char service_center_address[64] = "";
75+
76+
if (!SequansController.extractValueFromCommandResponse(
77+
response,
78+
0,
79+
service_center_address,
80+
sizeof(service_center_address) - 1)) {
81+
Log.error(F("Failed to extract service center address"));
82+
return;
83+
}
84+
85+
Log.infof(F("Got service centre addrees (this is not the SIM cards "
86+
"number by the way): %s\r\n"),
87+
service_center_address);
88+
}
89+
90+
// --- Send SMS ---
91+
Log.infof(F("Sending SMS to %s...\r\n"), NUMBER);
92+
response_result = SequansController.writeCommand(
93+
F("AT+SQNSMSSEND=\"%s\",\"hello world\""),
94+
response,
95+
sizeof(response),
96+
NUMBER);
97+
98+
if (response_result != ResponseResult::OK) {
99+
Log.errorf(F("Failed to send SMS, the response was: %s\r\n"), response);
100+
return;
101+
}
102+
103+
SequansController.clearReceiveBuffer();
104+
105+
Log.info(F("Waiting for send confirmation..."));
106+
if (!SequansController.waitForURC(F("SQNSMSSEND"),
107+
response,
108+
sizeof(response),
109+
40'000)) {
110+
Log.errorf(F("Timed out waiting for SMS confirmation\r\n"));
111+
return;
112+
}
113+
114+
Log.infof(F("Got the following response: %s"), response);
115+
}
116+
117+
void loop() {}

0 commit comments

Comments
 (0)