register device

In the documentation it was mentionned i have to use a tenantid.
But where can i found my tenantID ?

this is my domain name : https://edf.cumulocity.com

here the code i use to obtain the credential for my device. is it OK ?

final String serverUrl = “tcp://mqtt.cumulocity.com:1883”; /* ssl://mqtt.cumulocity.com:8883 for a secure connection */
final String clientId = “my_mqtt_java_client2”;
final String device_name = “14455866”;
final String tenant = “???”;
final String username = “xxxxxx”;
final String password = “xxxxx”;

final MqttConnectOptions options = new MqttConnectOptions();
options.setUserName(tenant + “/” + username);
options.setPassword(password.toCharArray());

    // connect the client to Cumulocity
    final MqttClient client = new MqttClient(serverUrl, clientId, null);
    client.connect(options);

client.subscribe(“s/dcr”, new IMqttMessageListener() {
public void messageArrived (final String topic, final MqttMessage message) throws Exception {
final String payload = new String(message.getPayload());

            System.out.println("Received operation " + payload);
            if (payload.startsWith("70")) {
                // execute the operation in another thread to allow the MQTT client to
                // finish processing this message and acknowledge receipt to the server
            	System.out.println("credential reçue ..."+payload);
               
            }
        }
    });
    
    Executors.newSingleThreadScheduledExecutor().scheduleWithFixedDelay(new Runnable() {
        public void run () {
            try {
            	client.publish("s/ucr", new MqttMessage(("").getBytes()));
            	System.out.println("publish empty message");
            } catch (MqttException e) {
                e.printStackTrace();
            }
        }
    }, 1, 7, TimeUnit.SECONDS);

Best Regards,
Patrick REGINA

Hi Patrick,

sorry for my late reply. Please try edf as tenant ID.

best regards
Michael

Dear Michael,

How should we get static username/password for device provisioning?

I tried the username/password you mentioned in other forum (Cumulocity MQTT bootstrap credentials - IoT - Software AG Tech Community & Forums).

That helps in connecting the device to the MQTT broker but I never receive new credentials in s/crd topic.

Hi Akash,

those credentials should work there as well.

best regards
Michael