A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By martin_g
#70058 To get messages from the local broker (no matter of published locally or from a remote client) you first have to register a callback function with;
Code: Select allMQTT_server_onData(MqttDataCallback dataCb);

where the callback has the signature;
Code: Select allvoid (*MqttDataCallback)(uint32_t *args, const char* topic, uint32_t topic_len, const char *data, uint32_t lengh);


Then you subscribe to all topics you are interested in with various calls to:
Code: Select allMQTT_local_subscribe(uint8_t* topic, uint8_t qos);

Here you may use the wildcards '+' and '#'.

Now you will receive a callback on any matching topic.
User avatar
By walt22
#70155 Hello,

I have made a little test regarding the performance of the uMQTT_broker using the tool sdkperf. With this load generator, you can send a lot of pubs/subs.

Here are the parameters:
-cip Broker-Host-Address:Portnr
-cu User name
-cp User Password
-ptl Topic for Pubs
-mn Total number messages
-mr Number messages/sec
-msa Payload length
-stl Topic for Subs

And the command for 1000 msgs, 100 per sec, payload 20 char:

D:\MQTT\Tools\Sdkperf>sdkperf_mqtt.bat -cip=192.168.4.1:1883 -ptl=mytop
-mn=1000 -mr=100 -msa=20 -stl=mytop -l -lat
Output:
> Getting ready to init clients
Sep 20, 2017 5:18:20 PM com.solacesystems.pubsub.sdkperf.core.AbstractClientCollection connect
Information: Connecting all clients.
Sep 20, 2017 5:18:20 PM com.solacesystems.pubsub.sdkperf.core.AbstractClientCollection connect
Information: Router capabilities: Unavailable due to: null
> Adding subscriptions if required
> Getting ready to start clients.
> Starting publish.
PUB MR(5s)= 0, SUB MR(5s)= 0, CPU=0
PUB MR(5s)= 101, SUB MR(5s)= 101, CPU=0
PUB MR(5s)= 101, SUB MR(5s)= 101, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 99, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 99, SUB MR(5s)= 99, CPU=0
PUB MR(5s)= 100, SUB MR(5s)= 100, CPU=0
PUB MR(5s)= 94, SUB MR(5s)= 95, CPU=0
======>Main thread finish
> Running sdkperf shutdown...
Pausing -ped time to allow clients to finish recv messages (2000 ms)

-------------------------------------------------
Aggregate Stats (Total # clients: 1):
-------------------------------------------------
Total Messages transmitted = 1000
Computed publish rate (msg/sec) = 99.0
-------------------------------------------------
Total Messages received across all subscribers = 1000
Messages received with discard indication = 0
Computed subscriber rate (msg/sec across all subscribers) = 100

You can see, that the broker can handle at least 100 pubs/subs per second. There is
no much degradation, when the payload has been increased to 100 chars.
Very impressive for such a small device!!! Good for small and medium sized projects!
For comparison, my 3Ghz PC with Mosquitto handles around 10.000 messages/sec.

This test gives me a good feeling for my further developments.

Regards Walter
User avatar
By martin_g
#70220 Walter, thank for these measurements - I haven't done any performance tests so far, just functional tests, so this is a valuable info!

For those of you, that don't like the NONOS SDK, I now added the local client calls to the Arduino API, i.e. with
Code: Select allbool MQTT_local_publish(uint8_t* topic, uint8_t* data, uint16_t data_length, uint8_t qos, uint8_t retain);
bool MQTT_local_subscribe(uint8_t* topic, uint8_t qos);
bool MQTT_local_unsubscribe(uint8_t* topic);

void MQTT_server_onData(MqttDataCallback dataCb);
void MQTT_server_onAuth(MqttAuthCallback authCb);

you can now locally interact with the broker from your sketch without the need of TCP connection or an additional pubsub-library. Detail can be found here https://github.com/martin-ger/esp_mqtt#using-the-esp_umqtt_broker-in-an-arduino-project