Skip to content

Commit ab24a3a

Browse files
authored
Merge pull request #3 from sparkfun/release_candidate
v1.1.0 - updates for v2 of the modem firmware
2 parents 30d5621 + c60da98 commit ab24a3a

File tree

6 files changed

+528
-357
lines changed

6 files changed

+528
-357
lines changed

examples/Example16_TxMessageManagement/Example16_TxMessageManagement.ino

Lines changed: 3 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -116,99 +116,23 @@ void loop()
116116

117117
Serial.print(F("There are "));
118118
Serial.print(count);
119-
Serial.println(F(" messages in the TX queue"));
119+
Serial.println(F(" unsent messages in the TX queue"));
120120
Serial.println();
121121

122122
if (count > 0)
123123
{
124-
if (count > 10)
125-
{
126-
count = 10; // Limit the menu to the first ten messages
127-
Serial.println(F("The first 10 messages are:"));
128-
}
129-
else
130-
Serial.println(F("The messages are:"));
131-
132-
uint64_t *ids = new uint64_t[count]; // Create an array of uint64_t to store the message IDs
133-
mySwarm.listTxMessagesIDs(ids, count); // Ask the modem for a list of the IDs
134-
135-
for (uint16_t i = 0; i < count; i++) // Print all the message IDs
136-
{
137-
Serial.print(i);
138-
Serial.print(F(" : "));
139-
serialPrintUint64_t(ids[i]);
140-
Serial.println();
141-
}
142-
143-
Serial.println();
144124
Serial.println(F("Enter:"));
145-
Serial.println(F("L followed by the message number to list a message. E.g. L1"));
146-
Serial.println(F("D followed by the message number to delete a message. E.g. D0"));
147-
Serial.println(F("A to delete all messages"));
125+
Serial.println(F("A to delete all unsent messages"));
148126

149127
while (!Serial.available()) // Wait for the user to enter a character
150128
mySwarm.checkUnsolicitedMsg(); // Keep emptying the backlog
151129

152130
char c = Serial.read(); // Read the serial character
153131

154-
if (c == 'L') // List a message
155-
{
156-
while (!Serial.available()) // Wait for the user to enter the message number
157-
;
158-
c = Serial.read(); // Read the serial character
159-
if ((c >= '0') && (c < ('0' + count)) && (c <= '9')) // Check for a valid number
160-
{
161-
// Allocate storage for the message. The message could be up to 2 * 192 bytes long. Include space for a null on the end.
162-
char *asciiHex = new char[385];
163-
uint32_t epoch;
164-
uint16_t appID;
165-
mySwarm.listTxMessage(ids[c - '0'], asciiHex, 385, &epoch, &appID); // List the message
166-
Serial.println();
167-
Serial.print(F("Message contents in ASCII Hex: "));
168-
Serial.println(asciiHex); // Print the message contents in ASCII Hex
169-
170-
// Convert the ASCII Hex into chars and print if printable
171-
Serial.print(F("Message contents (if printable): "));
172-
for (size_t i = 0; i < strlen(asciiHex); i+= 2)
173-
{
174-
uint8_t cc = ((asciiHex[i] >= '0') && (asciiHex[i] <= '9')) ? ((asciiHex[i] - '0') << 4) :
175-
((asciiHex[i] >= 'a') && (asciiHex[i] <= 'f')) ? ((asciiHex[i] + 10 - 'a') << 4) :
176-
((asciiHex[i] >= 'A') && (asciiHex[i] <= 'F')) ? ((asciiHex[i] + 10 - 'A') << 4) : 0;
177-
cc = cc | (((asciiHex[i+1] >= '0') && (asciiHex[i+1] <= '9')) ? ((asciiHex[i+1] - '0') << 0) :
178-
((asciiHex[i+1] >= 'a') && (asciiHex[i+1] <= 'f')) ? ((asciiHex[i+1] + 10 - 'a') << 0) :
179-
((asciiHex[i+1] >= 'A') && (asciiHex[i+1] <= 'F')) ? ((asciiHex[i+1] + 10 - 'A') << 0) : 0);
180-
if (((cc >= ' ') && (cc <= '~')) || (cc == '\r') || (cc == '\n')) // Check if cc is printable
181-
Serial.write(cc);
182-
}
183-
Serial.println();
184-
185-
Serial.print(F("Message epoch: "));
186-
Serial.print(epoch);
187-
Serial.print(F(" Message appID: "));
188-
Serial.println(appID);
189-
Serial.println();
190-
191-
delete[] asciiHex; // Delete the char storage
192-
}
193-
}
194-
195-
else if (c == 'D') // Delete a message
196-
{
197-
while (!Serial.available()) // Wait for the user to enter the message number
198-
;
199-
c = Serial.read(); // Read the serial character
200-
if ((c >= '0') && (c < ('0' + count)) && (c <= '9')) // Check for a valid number
201-
{
202-
mySwarm.deleteTxMessage(ids[c - '0']); // Delete the message
203-
}
204-
}
205-
206-
else if (c == 'A') // Delete all messages
132+
if (c == 'A') // Delete all messages
207133
{
208134
mySwarm.deleteAllTxMessages();
209135
}
210-
211-
delete[] ids; // Delete the ID storage
212136
}
213137
else
214138
{

examples/Example6_GPIO1Mode/Example6_GPIO1Mode.ino

Lines changed: 66 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,22 @@ void setup()
4949

5050
// Set the GPIO1 pin mode
5151
// Possible choices are:
52-
// SWARM_M138_GPIO1_ANALOG
53-
// SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH
54-
// SWARM_M138_GPIO1_EXIT_SLEEP_HIGH_LOW
55-
// SWARM_M138_GPIO1_OUTPUT_LOW
56-
// SWARM_M138_GPIO1_OUTPUT_HIGH
57-
// SWARM_M138_GPIO1_MESSAGES_PENDING_LOW
58-
// SWARM_M138_GPIO1_MESSAGES_PENDING_HIGH
59-
// SWARM_M138_GPIO1_SLEEP_MODE_LOW
60-
// SWARM_M138_GPIO1_SLEEP_MODE_HIGH
61-
Swarm_M138_Error_e err = mySwarm.setGPIO1Mode(SWARM_M138_GPIO1_OUTPUT_LOW);
52+
// SWARM_M138_GPIO1_ANALOG
53+
// SWARM_M138_GPIO1_ADC
54+
// SWARM_M138_GPIO1_INPUT
55+
// SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH
56+
// SWARM_M138_GPIO1_EXIT_SLEEP_HIGH_LOW
57+
// SWARM_M138_GPIO1_OUTPUT_LOW
58+
// SWARM_M138_GPIO1_OUTPUT_HIGH
59+
// SWARM_M138_GPIO1_MESSAGES_UNREAD_LOW
60+
// SWARM_M138_GPIO1_MESSAGES_UNREAD_HIGH
61+
// SWARM_M138_GPIO1_MESSAGES_UNSENT_LOW
62+
// SWARM_M138_GPIO1_MESSAGES_UNSENT_HIGH
63+
// SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_LOW
64+
// SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_HIGH
65+
// SWARM_M138_GPIO1_SLEEP_MODE_LOW
66+
// SWARM_M138_GPIO1_SLEEP_MODE_HIGH
67+
Swarm_M138_Error_e err = mySwarm.setGPIO1Mode(SWARM_M138_GPIO1_ADC);
6268

6369
if (err == SWARM_M138_SUCCESS)
6470
{
@@ -95,6 +101,12 @@ void setup()
95101
case SWARM_M138_GPIO1_ANALOG:
96102
Serial.println(F(" Analog, pin is internally disconnected and not used (default)"));
97103
break;
104+
case SWARM_M138_GPIO1_ADC:
105+
Serial.println(F(" Analog ADC, pin can be read to measure input voltage (0-3.3V)"));
106+
break;
107+
case SWARM_M138_GPIO1_INPUT:
108+
Serial.println(F(" Input, pin can be read as a general purpose digital input (High or Low)"));
109+
break;
98110
case SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH:
99111
Serial.println(F(" Input, low-to-high transition exits sleep mode"));
100112
break;
@@ -107,22 +119,60 @@ void setup()
107119
case SWARM_M138_GPIO1_OUTPUT_HIGH:
108120
Serial.println(F(" Output (open drain), set high/open"));
109121
break;
110-
case SWARM_M138_GPIO1_MESSAGES_PENDING_LOW:
111-
Serial.println(F(" Output (open drain), low indicates messages pending for client"));
122+
case SWARM_M138_GPIO1_MESSAGES_UNREAD_LOW:
123+
Serial.println(F(" Output (open drain), low indicates unread messages pending for user"));
124+
break;
125+
case SWARM_M138_GPIO1_MESSAGES_UNREAD_HIGH:
126+
Serial.println(F(" Output (open drain), high/open indicates unread messages pending for user"));
127+
break;
128+
case SWARM_M138_GPIO1_MESSAGES_UNSENT_LOW:
129+
Serial.println(F(" Output (open drain), low indicates unsent messages pending for transmit"));
112130
break;
113-
case SWARM_M138_GPIO1_MESSAGES_PENDING_HIGH:
114-
Serial.println(F(" Output (open drain), high/open indicates messages pending for client"));
131+
case SWARM_M138_GPIO1_MESSAGES_UNSENT_HIGH:
132+
Serial.println(F(" Output (open drain), high/open indicates unsent messages pending for transmit"));
133+
break;
134+
case SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_LOW:
135+
Serial.println(F(" Output (open drain), low indicates unread or unsent messages"));
136+
break;
137+
case SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_HIGH:
138+
Serial.println(F(" Output (open drain), high/open indicates unread or unsent messages"));
115139
break;
116140
case SWARM_M138_GPIO1_SLEEP_MODE_LOW:
117-
Serial.println(F(" Output (open drain), low indicates in sleep mode. Otherwise output is high/open"));
141+
Serial.println(F(" Output (open drain), low indicates sleep mode is active. Otherwise output is high/open"));
118142
break;
119143
case SWARM_M138_GPIO1_SLEEP_MODE_HIGH:
120-
Serial.println(F(" Output (open drain), high/open indicates in sleep mode. Otherwise output is low"));
144+
Serial.println(F(" Output (open drain), high/open indicates sleep mode is active. Otherwise output is low"));
121145
break;
122146
default:
123147
Serial.println(F(" UNKNOWN"));
124148
break;
125149
}
150+
151+
// Just to prove we can, call getGPIO1voltage to check the pin voltage (only valid for modes 1 and 2)
152+
float voltage;
153+
err = mySwarm.readGPIO1voltage(&voltage);
154+
155+
if (err == SWARM_M138_SUCCESS)
156+
{
157+
Serial.print(F("GPIO1 voltage is: "));
158+
Serial.println(voltage, 3);
159+
}
160+
else
161+
{
162+
Serial.print(F("Swarm communication error: "));
163+
Serial.print((int)err);
164+
Serial.print(F(" : "));
165+
Serial.print(mySwarm.modemErrorString(err)); // Convert the error into printable text
166+
if (err == SWARM_M138_ERROR_ERR) // If we received a command error (ERR), print it
167+
{
168+
Serial.print(F(" : "));
169+
Serial.print(mySwarm.commandError);
170+
Serial.print(F(" : "));
171+
Serial.println(mySwarm.commandErrorString((const char *)mySwarm.commandError));
172+
}
173+
else
174+
Serial.println();
175+
}
126176
}
127177

128178
void loop()

keywords.txt

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ setGeospatialInfoRate KEYWORD2
4646

4747
getGPIO1Mode KEYWORD2
4848
setGPIO1Mode KEYWORD2
49+
readGPIO1voltage KEYWORD2
4950

5051
getGpsFixQuality KEYWORD2
5152
getGpsFixQualityRate KEYWORD2
@@ -57,6 +58,7 @@ getPowerStatus KEYWORD2
5758
getPowerStatusRate KEYWORD2
5859
setPowerStatusRate KEYWORD2
5960
getTemperature KEYWORD2
61+
getCPUvoltage KEYWORD2
6062

6163
restartDevice KEYWORD2
6264

@@ -74,6 +76,7 @@ markRxMessage KEYWORD2
7476
markAllRxMessages KEYWORD2
7577
getMessageNotifications KEYWORD2
7678
setMessageNotifications KEYWORD2
79+
listMessage KEYWORD2
7780
readMessage KEYWORD2
7881
readOldestMessage KEYWORD2
7982
readNewestMessage KEYWORD2
@@ -82,7 +85,7 @@ getUnsentMessageCount KEYWORD2
8285
deleteTxMessage KEYWORD2
8386
deleteAllTxMessages KEYWORD2
8487
listTxMessage KEYWORD2
85-
listTxMessagesIDs KEYWORD2
88+
# listTxMessagesIDs KEYWORD2
8689

8790
transmitText KEYWORD2
8891
transmitTextHold KEYWORD2
@@ -128,12 +131,18 @@ SWARM_M138_ERROR_ERR LITERAL1
128131
SWARM_M138_SUCCESS LITERAL1
129132

130133
SWARM_M138_GPIO1_ANALOG LITERAL1
134+
SWARM_M138_GPIO1_ADC LITERAL1
135+
SWARM_M138_GPIO1_INPUT LITERAL1
131136
SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH LITERAL1
132137
SWARM_M138_GPIO1_EXIT_SLEEP_HIGH_LOW LITERAL1
133138
SWARM_M138_GPIO1_OUTPUT_LOW LITERAL1
134139
SWARM_M138_GPIO1_OUTPUT_HIGH LITERAL1
135-
SWARM_M138_GPIO1_MESSAGES_PENDING_LOW LITERAL1
136-
SWARM_M138_GPIO1_MESSAGES_PENDING_HIGH LITERAL1
140+
SWARM_M138_GPIO1_MESSAGES_UNREAD_LOW LITERAL1
141+
SWARM_M138_GPIO1_MESSAGES_UNREAD_HIGH LITERAL1
142+
SWARM_M138_GPIO1_MESSAGES_UNSENT_LOW LITERAL1
143+
SWARM_M138_GPIO1_MESSAGES_UNSENT_HIGH LITERAL1
144+
SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_LOW LITERAL1
145+
SWARM_M138_GPIO1_MESSAGES_UNREAD_UNSENT_HIGH LITERAL1
137146
SWARM_M138_GPIO1_SLEEP_MODE_LOW LITERAL1
138147
SWARM_M138_GPIO1_SLEEP_MODE_HIGH LITERAL1
139148
SWARM_M138_GPIO1_INVALID LITERAL1
@@ -158,6 +167,7 @@ SWARM_M138_MODEM_STATUS_BOOT_POWERON LITERAL1
158167
SWARM_M138_MODEM_STATUS_BOOT_RUNNING LITERAL1
159168
SWARM_M138_MODEM_STATUS_BOOT_UPDATED LITERAL1
160169
SWARM_M138_MODEM_STATUS_BOOT_VERSION LITERAL1
170+
SWARM_M138_MODEM_STATUS_BOOT_DEVICEID LITERAL1
161171
SWARM_M138_MODEM_STATUS_BOOT_RESTART LITERAL1
162172
SWARM_M138_MODEM_STATUS_BOOT_SHUTDOWN LITERAL1
163173
SWARM_M138_MODEM_STATUS_DATETIME LITERAL1

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun Swarm Satellite Arduino Library
2-
version=1.0.0
2+
version=1.1.0
33
author=SparkFun Electronics <techsupport@sparkfun.com>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for the Swarm M138 satellite modem<br/><br/>

0 commit comments

Comments
 (0)