Comments (6)
@HumamHelfawi : Thx for the hint!
I changed AWS_IOT.cpp as follows, so that the correct topicname is passed to the custom-function:
void iot_subscribe_callback_handler(AWS_IoT_Client *pClient, char *topicName, uint16_t topicNameLen,
IoT_Publish_Message_Params *params,
void *pData)
{
char shortTopic[512];
strncpy(shortTopic, topicName, topicNameLen);
if (subApplCallBackHandler != 0) //User call back if configured
subApplCallBackHandler(shortTopic, params->payloadLen,
(char *) params->payload);
}
from hornbill-examples.
@OllisGit Thank you for your answer but the shortTopic Contains some Junk Characters at the end which can be avoided by adding following line after strncpy(shortTopic, topicName, topicNameLen);
shortTopic[topicNameLen] = 0;
from hornbill-examples.
I have the same error - I need to check the topicName as I'm subscribing to multiple topics. Did you find a solution?
from hornbill-examples.
Found a solution - in your callbackhander, add the following:
int topicNameLen = strlen(topicName);
topicName[(topicNameLen - payloadLen)] = 0;
EDIT: Correction - this doesn't work, because the length of the topicName doesn't get truncated, so it remains the size of the first submission.
from hornbill-examples.
The original handler
hastopicNameLen
parameter which is very important. However, the custom handler does not have this one.You should edit the the library and add this field for custome handler.
One other note, the library supports only one subscription. If you make another subscription, it will override the old one.
from hornbill-examples.
@OllisGit Good spotting! I have also implemented your fix
@muneebmalik78 good work on the null terminator. Always have to be careful of strncpy... it will not null terminate if it hits the n'th character.
You have to do it manually, or use:
snprintf(shortTopic, topicNameLen + 1,"%s", topicName);
from hornbill-examples.
Related Issues (20)
- running out of memory when doing the TLS handshake
- AWS ALPN protocol - not seeing it referenced here in the repo...
- Error parsing root-ca HOT 3
- failed! mbedtls_net_connect returned -0x44 HOT 1
- Wrting a Book using hornbill
- Cannot connect to AWS in the loop.
- # Its showing that the specified zip/folder does not contain a valid library. HOT 1
- AWS_IOT: Error(-28) HOT 1
- Publishing message without internet access
- Unable to connect due to certificate error
- Not receiving MQTT messages when subscribe is done using a non const char HOT 1
- fatal error: mbedtls/config.h: No such file or directory HOT 5
- Feature of Hornbill
- AWS OTA (Over The Air) Update HOT 1
- large payloads do not get returned HOT 1
- sending large payload truncates the string - TX buffer size? HOT 1
- Stops Publishing
- esp8266
- How can I send a file saved in SPIFFS in esp32?
- AWS_iot.h file is not found in directory in current version
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hornbill-examples.