You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The basic mqtt example sketch works as expected. Software serial communication between Teensy 4.1 and BW16 works as expected. However, the two do not work in combination. When trying to implement software serial communication between Teensy 4.1 and BW16 in the loop() function, the mqtt functionality experiences hangups that are not resolvable. Sometimes readouts on the serial monitor will suddenly stop, with no error messages printed. All functionality of the device also stops. Other times there occurs an infinite loop in which I get the readouts; “[INFO] Create socket successfully” and then “[ERROR] Connect to server failed” then [INFO] [ard_socket.c][send_data] err = 0" “failed, rc = 4” and repeats this cycle infinitely.
This does not occur if I remove the software serial communication portion of the code. I tried to implement a watchdog system reset when the reconnect() function fails to connect, however it appears that the watchdog functionality does not execute. Thus the device frequently enters a non-functioning state that can only be resolved with a physical reset, which renders this device completely useless for operation in a remote location.
this problem was detected earlier and reported as "closed" despite the issue still occurring: #75
Sketch
#include"sys_api.h"
#include<WiFi.h>
#include<PubSubClient.h>
#include<SoftwareSerial.h>
SoftwareSerial mySerial(PB2, PB1); // RX, TXchar c;
String dataIn;
char ssid[] = "xxxxx";
char pass[] = "xxxxx";
int status = WL_IDLE_STATUS;
int publishCount = 0;
int characterCount = 0;
int characterCount2 = 0;
char mqttServer[] = "test.mosquitto.org";
char clientId[] = "amebaClient";
char publishTopic[] = "server";
char publishPayload[] = "initialize";
char subscribeTopic[] = "Input";
char key[10] = {0};
voidcallback(char* topic, byte* payload, unsignedint length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (unsignedint i = 0; i < length; i++) {
Serial.print((char)(payload[i]));
}
Serial.println();
}
WiFiClient wifiClient;
PubSubClient client(wifiClient);
voidreconnect() {
// Loop until we're reconnectedwhile (!(client.connected())) {
Serial.print("\r\nAttempting MQTT connection...");
// Attempt to connectif (client.connect(clientId)) {
Serial.println("connected");
//Once connected, publish an announcement and resubscribe
client.publish(publishTopic, publishPayload);
client.subscribe(subscribeTopic);
} else {
Serial.println("failed, rc=");
Serial.print(client.state());
Serial.println(" wait 5 seconds");
delay(5000);
}
}
}
voidsetup() {
//Initialize serial and wait for port to open:
Serial.begin(115200);
mySerial.begin(115200);
//Attempt to connect to WiFi networkwhile (status != WL_CONNECTED) {
//Serial.print("\r\nAttempting to connect to SSID: ");//Serial.println(ssid);// Connect to WPA/WPA2 network. Change this line if using open or WEP network:
status = WiFi.begin(ssid, pass);
// wait 10 seconds for connection:delay(10000);
}
client.setServer(mqttServer, 1883);
client.setCallback(callback);
//Allow Hardware to sort itself outdelay(1500);
}
voidloop()
{
while (mySerial.available()>0)
{
c = mySerial.read();
if (c == '\n') {break;}
else {dataIn+=c;}
}
if (c=='\n')
{
Serial.println(dataIn);
int str_len = dataIn.length() + 1;
dataIn.toCharArray(key, str_len);
if (client.connect(clientId))
{
client.publish(publishTopic, key);
}
c=0;
dataIn="";
}
if (!(client.connected()))
{
//reconnect();sys_reset();
}
client.loop();
}
Error/Debug Message
Sometimes readouts on the serial monitor will suddenly stop, with no error messages printed. All functionality of the device also stops. Other times there occurs an infinite loop in which I get the readouts; “[INFO] Create socket successfully” and then “[ERROR] Connect to server failed” then [INFO] [ard_socket.c][send_data] err = 0" “failed, rc = 4” and repeats this cycle infinitely.
Other times i get:
RTL8721D[Driver]: no beacon for a long time, disconnect or roaming
12:38:41.420 -> dissconn reason code: 65535
12:38:41.420 -> connected stage, loss beacon
12:38:41.420 ->
12:39:49.457 -> Attempting MQTT connection...
12:39:49.457 -> [INFO]server_drv.cpp: start_client
12:39:49.457 -> [INFO] Create socket successfully
12:39:49.457 ->
12:40:07.496 -> [ERROR] Connect to server failed
12:40:07.497 ->
12:40:07.497 -> [INFO] [ard_socket.c][send_data] err = 1583184219
Reproduce remarks
No response
I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
I confirm I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
The text was updated successfully, but these errors were encountered:
Hello, hope this message finds you well. Congrats to your first Issue! We will review it as soon as possiable. Feel free to have a look at https://www.amebaiot.com/en/ameba-arduino-summary/ for more information
I have a similar issue too but it appears that the BW16 gets stuck inside of the client.loop(); until it receives an MQTT event which results in the serial read being useless
Boards
BW16
External Hardware
Teensy 4.1 communication via UART
Hardware Configuration
nothing else attached to BW16
Version
latest dev (checkout manually)
IDE Name
Arudino IDE 2.32.
Operating System
Windows 10
Auto Flash Mode
Disable
Erase All Flash Memory (4MB)
Disable
Standard Lib
Arduino_STD_PRINTF
Upload Speed
1500000
Description
The basic mqtt example sketch works as expected. Software serial communication between Teensy 4.1 and BW16 works as expected. However, the two do not work in combination. When trying to implement software serial communication between Teensy 4.1 and BW16 in the loop() function, the mqtt functionality experiences hangups that are not resolvable. Sometimes readouts on the serial monitor will suddenly stop, with no error messages printed. All functionality of the device also stops. Other times there occurs an infinite loop in which I get the readouts; “[INFO] Create socket successfully” and then “[ERROR] Connect to server failed” then [INFO] [ard_socket.c][send_data] err = 0" “failed, rc = 4” and repeats this cycle infinitely.
This does not occur if I remove the software serial communication portion of the code. I tried to implement a watchdog system reset when the reconnect() function fails to connect, however it appears that the watchdog functionality does not execute. Thus the device frequently enters a non-functioning state that can only be resolved with a physical reset, which renders this device completely useless for operation in a remote location.
this problem was detected earlier and reported as "closed" despite the issue still occurring: #75
Sketch
Error/Debug Message
Reproduce remarks
No response
I have checked online documentation, FAQ, GitHub Wiki and existing/closed issues.
The text was updated successfully, but these errors were encountered: