This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Provisioning process, invitation and capabilities receiving

Invitation: The provisioner invites the unprovisioned device to send its provisioning capabilities information.

Firmware version from this examle: https://github.com/NordicPlayground/thingy52-mesh-provisioning-demo

In According to the information above and https://www.bluetooth.com/specifications/mesh-specifications/ I would like to send invitation to the Thingy and get response in the form of capabilities.

So I trying to create a byte array and send to Thingy. Service and characteristic for provisioning are good known for me.

If you ask me if I analised nrf Mesh app  source code I will say yes but couldn't find answer for my question.

I m trying to create Proxy pdu:

In according to the core specification above i created byte array witch I want to send to Thingy from my smartphone.

So first Field name  witch is SAR will be 0b00

Second field name is Mesagge type and will be Provisioning_pdu 0x03

The Data Field name will be (from provision protocol):

Padding wil be: 0b00

Type will be 0x00 (Provision invite)

And Atention duration will be for example 5 seconds so the value will be 0x05.

Summarizing by byte array should be:

byte[] data_prov_start = new byte[]{0x03, 0x00, 0x05};

UUID SERVICE_UUID=UUID.fromString           ("00001827-0000-1000-8000-00805F9B34FB");
UUID CHARACTERISTIC_UUID_TX=UUID.fromString    ("00002ADB-0000-1000-8000-00805F9B34FB"); //2ADB data IN to Thingy(DATA WRITE from Xiaomi)

BluetoothGattService service = gatt.getService(SERVICE_UUID);
BluetoothGattCharacteristic characteristic = service.getCharacteristic(CHARACTERISTIC_UUID_TX);

characteristic.setValue(data_prov_start);
gatt.writeCharacteristic(characteristic);



   public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
            super.onCharacteristicWrite(gatt, characteristic, status);

                UUID SERVICE_UUID = UUID.fromString("00001827-0000-1000-8000-00805F9B34FB");
                UUID CHARACTERISTIC_UUID_RX = UUID.fromString("00002ADC-0000-1000-8000-00805F9B34FB");              //2ADC data OUT from Thingy(DATA READ)
                BluetoothGattService service = gatt.getService(SERVICE_UUID);
                characteristic = service.getCharacteristic(CHARACTERISTIC_UUID_RX);

                gatt.setCharacteristicNotification(characteristic, true);
                BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
                descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
                gatt.writeDescriptor(descriptor);


        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
            super.onCharacteristicChanged(gatt, characteristic);
            

            my_recieved_Data= characteristic.getValue();
            Log.d(" my_recieved_Data ",bytesToHex( my_recieved_Data)+"");


        }

I tried to send my data and: 

onCharacteristicWrite and onDescriptorWrite were called but I have no capabilities in response cause I dont have any response :-)
Can someone help? What I m doing wrong?

  • Hi,

    There is a section of code there, that should be done right after connection instead:

    gatt.setCharacteristicNotification(characteristic, true);
    BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"));
    descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
    gatt.writeDescriptor(descriptor);

    As is, you may have gotten to the point where you should get a notification BEFORE you actually configure the CCCD to give you the notification. That is, when the result should be sent, you have not yet enabled notifications, and so no notification containing the response will be sent.

    Regards,
    Terje

Related