@@ -49,16 +49,22 @@ void setup()
49
49
50
50
// Set the GPIO1 pin mode
51
51
// 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);
62
68
63
69
if (err == SWARM_M138_SUCCESS)
64
70
{
@@ -95,6 +101,12 @@ void setup()
95
101
case SWARM_M138_GPIO1_ANALOG:
96
102
Serial.println (F (" Analog, pin is internally disconnected and not used (default)" ));
97
103
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 ;
98
110
case SWARM_M138_GPIO1_EXIT_SLEEP_LOW_HIGH:
99
111
Serial.println (F (" Input, low-to-high transition exits sleep mode" ));
100
112
break ;
@@ -107,22 +119,60 @@ void setup()
107
119
case SWARM_M138_GPIO1_OUTPUT_HIGH:
108
120
Serial.println (F (" Output (open drain), set high/open" ));
109
121
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" ));
112
130
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" ));
115
139
break ;
116
140
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" ));
118
142
break ;
119
143
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" ));
121
145
break ;
122
146
default :
123
147
Serial.println (F (" UNKNOWN" ));
124
148
break ;
125
149
}
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
+ }
126
176
}
127
177
128
178
void loop ()
0 commit comments