-
Set
HSE
toCrystal/Ceramic Resonator
and disableLSE
as shown -
Set serial mode to
Asynchronous
for bothUSART1
andUSART2
and ensuregloabl interrupt
is enabled underNVIC Settings
-
See below clock configuration.
- Toggle
PLL
andPLLCLK
- Set input frequency to
8Mhz
- Toggle
-
You might want to set the multiplier
PLLMul
to 11 or above then clickResolve Clock Issues
SAVE AND GENERATE PROJECT
- Inside ./Core/Inc/main.h ensure you have chaged the MQTT-Specific settings with your Africa's Talking Device Group and Password
#define MQTT_USERNAME "<CoolPerson>"
#define MQTT_DEVICE_GROUP "<cooldevicegroup>"
#define MQTT_PASSWORD "<strongpassword>" // Mandatory field
#define AUTH_CREDENTIALS MQTT_USERNAME ":" MQTT_DEVICE_GROUP // Mandatory field; resolves to username:devicegroup
#define MQTT_QOS 1 // Can be 0 or 1 or 2
#define DEVICE_ID "Eris" // Mandatory Field
- Note that you can add new subscription callbacks or modifiy the subscription callback to do something else. See ./Core/Src/main.c
void downStreamCommandHandler(MessageData *messageData)
{
serialPrint("Received a message %s : \r\n", messageData->message->payload);
serialPrint("Topic is %s \r\n", messageData->topicName);
memset((char *)messageData->message->payload, '\0', sizeof(uint8_t));
memset((char *)messageData->topicName, '\0', sizeof(uint8_t));
serialPrint("Sending message \r\n");
char dataMessage[100];
mqttMessage.dup = 0;
mqttMessage.qos = MQTT_QOS;
mqttMessage.id = 0;
mqttMessage.retained = 0;
mqttMessage.payload = dataMessage;
sprintf(dataMessage, "test");
mqttMessage.payloadlen = strlen((char *)mqttMessage.payload) + 1;
if (MQTTPublish(&mqttClient, (char *)DEVICE_UPSTREAM_TOPIC, &mqttMessage) == 0)
{
serialPrint("Message published \r\n");
}
else
{
serialPrint("Unable to publish message \r\n");
sent_failed_count++;
}
}
-
See the APN configuration inside
./Core/Src/main.c
-
Note that the line shown below is commented under
./Core/Src/syscalls.c
extern int __io_putchar(int ch) __attribute__((weak));
-
Also note that an IRQ handler is required for USART1; see
./Core/Src/stm32f1xx_it.c
. -
Note the differences under
./Core/{*}/usart.{*}
- Prevent the device from republishing the
birth message
when connected. - Repurpose the
downStreamCommandHandler(MessageData *messageData)
to blink the LEDPC13
(enabled) for a number of times (N) for (X) seconds when (N,X) is sent to it under the<username>/<devicegroup>/Eris/rec
topic. - Confirm that you can receive the
will message
when disconnected.
- If the hardware fails to connect to the GSM network within 30 seconds,
- Give it more time, the program will try to restart the GSM module
- Manually reset the board
- Your USB host might not be delivering sufficient power or you're using a longer cable