BLE Mesh 2 way communication

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
RoBe_1502026
Level 4
Level 4
25 replies posted 10 replies posted 5 replies posted

Hi all,

I am using for development the following: cybt-213043-mesh/cyw920819e

in final production plan on using the cybt-213043 modules. using the cyw920819 because the 213043 does not expose the i2c bus for development.

here is what I am trying to accomplish.

1. send a Number to the module(remote relay box from now on) that will then trigger an alarm via a pca9555 (I have this board developed as I have been using it for 10 year but working on an upgrade of the system to BLE- Mesh) I have been able to trigger using a fixed value on a button push, but would like to send the number of the relay to trigger over the ble mesh net.

2. receiving battery voltage from remote relay box.

3. receiving temperature(s) from remote relay box.

So I need to send one value and receive 2-3 values FROM the remote relay box.

I am not sure how to do this? it seems like a module is either a server or a client, can it be both? How.

Also not sure how to transfer this data, which profile or do I make a custom profile.

If a custom profile is needed are there any good guides/videos on how to make one.

I hope I have given enough into.

Thanks for all the help,

Rob Berry

0 Likes
1 Solution

I will pass the message to Alan that you enjoyed his video.  Going back to real work...  BLE mesh uses concepts of subscriptions and publications.  A client model needs to be configured to publish data to an address and to protect data using a specific application key.  The address can be a unicast address, or a group address or a virtual address.  The receiving side by default is subscribed to receive messages with a unicast address of one of its element.  If the client model is configured to publish messages to a group, the destination needs to be configured to subscribe the server model to the same group.  A client and a server need to have the same application key.  In addition to that the models shall be bound to this key.

You can think of a switch and a bulb.  Switch by default does not know where his onoff command need to be send.  So provisioner need to configure publication on the switch.  The publication shall contain information of the destination address, and the key to encrypt the data, i.e. an app key shall be added and on/off client model shall be bound to the key.  If the switch controls group of bulbs, on the bulb side, you need to subscribe the on/off server model to the group address.  The same application key shall be added.  The on/off server model shall be bound to the application key.

If you use Cypress provisioner (Windows, or Android, or iOS), most of the work should be done for you when you are doing provisioning/configuration.  For example, provisioner creates and maintains application keys.  if you have Vendor Specific models, and if you configure device in a group, the model will be subscribed.  I suggest you study configure_queue_remote_device_operations in the wiced_mesh_client.c message to see what is being done.  Note that Cypress provisioner will only configure Vendor Specific models if Vendor is Cypress.

View solution in original post

32 Replies
DheerajPK_41
Moderator
Moderator
Moderator
750 replies posted 500 likes received 500 replies posted

Hi rjberry_1502026

An end application can use Server Models or Client Models, or both along with the control logic. Any combination of Server and Client Models results in a Control Model. Here, I believe, your module should act as a control model, so that it can communicate with the configuration device on one side and it can control the Alarm on the other side.

As per Spec:

Control model: A control model may contain client model functionality to communicate with other server models and server model functionality to communicate with other client models. A control model may also contain control logic, which is a set of rules and behaviors that coordinate the interactions between other models that the control model connects to.

And, Mesh spec allows the developer to create vendor specific models that are not defined in the Mesh model Specification. Also we have a snip app called mesh_vendor_server which will demonstrate this feature. Helper Applications (MeshClient - Windows) will help you to Set vendor data for vendor models.

We have an excellent AppNote of Mesh where you can get the information of basic architecture overview, code example usage, etc. of Mesh.

Getting Started with Bluetooth Mesh

MeshClient guide you can find here: MeshClient and ClientControlMesh App User Guide

Thanks,

-Dheeraj

0 Likes

Dheeraj,

Thanks for the reply. I am reading that doc again with a bit more knowledge then I did the first time.

Best Regards,

Rob Berry

0 Likes

Are you using the Mesh apps from GIT: GitHub - cypresssemiconductorco/Code-Examples-BT-SDK-for-ModusToolbox: These examples demonstrate th...

Or the ones provided within the SDK? 

AbhayD_36

0 Likes

I updated my question as I was using the files from the cyw920819 on the cybe-213043 by accident.

I am using the GitHub versions and importing them into my environment.

I have not tried yet but can the .data property pass a structure or only int or arrays?

thanks,

Rob

0 Likes

Hi VictorZ_46​ , Could you please give your suggestion and view also for designing this project?

0 Likes

Hi,

I am not sure if I understand your question. Ill recap my project.

I have a main controller, this controller communicates with a 'black box' that has a psoc6 with relays and inputs (digital,A/D,etc)

I need to have the main controller communicate with the black box to obtain values like, battery voltage, temperatures (3 of them from remote probes) and faults from the inputs. ALSO I need the main controller to send a value to the 'black box' to trigger a relay on and off as needed.

There is a reason the controller is separate from the 'black box' as the main controller uses a 4G/LTE modem and the location of the equipment may not be in the range of cellular data. so the ble mesh is the best option to mounting the controller where it has cell service and still be able to talk to the 'black box'

Hope this is clearer, I do have some other modules but I think learning how to do this will help me design them....

Best Regards,

Rob

0 Likes

Sounds that you need vendor specific model. Please use the sample in the SDK.

0 Likes

Victor,

I have the mesh_vendor_server on my device but not sure how to use it.

the help files doesnt 'help' Can you explain more how to use it?

Thanks,

Rob

0 Likes

HI RoBe_1502026

You can use mesh_provision_client and mesh_vendor_server (or mesh_vendor_specific_app) apps from the code examples.

Here mesh_provision_client will act as a client device that can send vendor specific messages to a server and also can receive the status messages. And mesh_vendor_server app can act as a server device that can process the received messages and do some operations if needed.

Please follow below instructions to use vendor specific app.

  1. Download mesh_provision_client and mesh_vendor_server apps into two separate boards.
  2. Open MeshClientControl (LightControl tab) and open COMport of mesh_provision_client device.
  3. Create a network, Open it and then Scan and Provision the mesh_vendor_server app. (Please use Helper application guide: https://www.cypress.com/file/462491/download​ if you have doubt in the usage of helper applicaion)
  4. Select the required provisioned device and use Vendor Data field to send required data to the server.
  5. You will be able to see sent messages and received the status message on the ClientControl log itself (Bottom).

NOTE: Instead of using mesh_provision_client and MeshClientControl, you can use MeshClient helper application (windows) to provision and communicate with a vendor specific server app.

BLE MESH application development guides:

Getting Started with Bluetooth Mesh

Please watch How To Design With Bluetooth Mesh (Hands-On) if you prefer video lecture.

Helper application guide: MeshClient and ClientControlMesh App User Guide

Other supported documents: https://www.cypress.com/products/ble-mesh

Please refer to BT SIG Mesh Specification also - https://www.bluetooth.com/specifications/mesh-specifications

Thanks.

-Dheeraj

Dheeraj,

I am going to try these now. I think I am just having a problem with wrapping my head around something. If I have a separate controller and want to send a packet of data through the ble mesh, I would normally do it through a serial link. How do I setup a ble mesh app to listen to a serial link and relay whatever is send through the link out to the mesh? And is there a way to direct data to a specific target board? for example me my application if I have my 'black box' and then another 'black box #2'. Is there a way to direct the traffic or better address the traffic to 'black box #2' ? 

I think part of my problem is understanding where I put my data to be sent out and how that data gets processed once received by a another module.

Sorry if these are very green questions.  I do appreciate your help and I have watched the video with Alan. Very good and he is a great teacher, It gave me a great start but now I need to make some customizing and the video doesn't cover that...

Best Regards,

Rob Berry

0 Likes

I will pass the message to Alan that you enjoyed his video.  Going back to real work...  BLE mesh uses concepts of subscriptions and publications.  A client model needs to be configured to publish data to an address and to protect data using a specific application key.  The address can be a unicast address, or a group address or a virtual address.  The receiving side by default is subscribed to receive messages with a unicast address of one of its element.  If the client model is configured to publish messages to a group, the destination needs to be configured to subscribe the server model to the same group.  A client and a server need to have the same application key.  In addition to that the models shall be bound to this key.

You can think of a switch and a bulb.  Switch by default does not know where his onoff command need to be send.  So provisioner need to configure publication on the switch.  The publication shall contain information of the destination address, and the key to encrypt the data, i.e. an app key shall be added and on/off client model shall be bound to the key.  If the switch controls group of bulbs, on the bulb side, you need to subscribe the on/off server model to the group address.  The same application key shall be added.  The on/off server model shall be bound to the application key.

If you use Cypress provisioner (Windows, or Android, or iOS), most of the work should be done for you when you are doing provisioning/configuration.  For example, provisioner creates and maintains application keys.  if you have Vendor Specific models, and if you configure device in a group, the model will be subscribed.  I suggest you study configure_queue_remote_device_operations in the wiced_mesh_client.c message to see what is being done.  Note that Cypress provisioner will only configure Vendor Specific models if Vendor is Cypress.

Victor,

Thanks, I have emailed Alan a couple of times, I hate doing it as I know he's a busy man.
Ok ,so I have all my boards connected in the same network. I now want to send the number 0x80 to one of the boards, lets say the name of that box is 'relayBox' and there is only on in the network.  also the number 0x80 is coming from another processor via uart port. how do i make it listen to the serial port and then transmit the number?  once its transmitted how does the 'relayBox' receive the number to be processed on the module?

I am sorry if I am asking 'stupid' questions, I really want to understand this fully. Are there any classes or training courses where I can ask question and learn? I am understanding more every day but get stumped. I am so used to the ole'     int main(){} thinking I get somewhat confused when we move to event driven. I dont fully understand where the events get generated and how to define custom events (if that what they are called. I am using that term as the best way to describe it.)

also is the mesh_app_init(is_provisioned) called continuously? i am reading the setting started doc so if its in there, I apologies.

As I look more, it seems like all the 'work' get setup in the mesh_app_init(). Is this correct?

also where is the wiced_mesh_client.c file so I can see the configure_queue_remote_device_operations section. I cant find it in the sample code I have.

Best Regards and Thanks!

Rob

0 Likes
VictorZ_46
Employee
Employee
5 comments on blog 25 sign-ins 250 likes received

If the communication is between your 2 devices, you indeed can use Vendor Specific model and build your protocol on top of that.  There should be a mesh vendor specific data app for that.  If you need to be standard (for example, your temperature measurements need to trigger fan to be turned on), you should try to stick with standard models.  You can have temperature sensor, battery server and whatever else you need on the same device.

Please note that it either case, you will need to use some Provisioner to set up your network.  For example, your provisioner will need to set up your client device to publish data (for example, vendor specific data, or sensor data) to a specific device or to a group of devices.

VictorZ_46
Employee
Employee
5 comments on blog 25 sign-ins 250 likes received

There is plenty of information on BLE Mesh around the web.  Google is your helper.  Cypress community forum (or emails to Alan) is definitely not the place to learn how the mesh works.

You cannot send the message to a device, unless you are a provisioner and you know all devices all keys and everything.  If you are configured for publications, you can publish the message.  If you have a vendor specific model and a provisioner configured this model with appropriate application key and appropriate address to send a message you can publish the message.  Please look at the vendor specific models sample.  Hope it will give you some clue what to do.

Please look at the documentation for mesh_app_init. The function is not called periodically.

0 Likes

Victor,

Things are getting clearer. hopefully one last thing for now. I see reference to 'opcode' and when i do the sample code the opcode shows as '0x3f'. I see any cases in the switch statement that meet the '0x3f' value.

when i search in the 'Getting started in bluetooth mesh' document nothing shows in the search for 'opcode'

what exactly is it and where does it get assigned? If it is used to define the type of data being transferred?

I have been looking online for other code samples but nothing looks like modustoolbox code.

Thanks!

Rob

0 Likes

Each message has an opcode.  Opcode can be 1 or 2 bytes for BT SIG defined messages.  For vendor specific messages, the opcode is 3 bytes.  First 2 has Company ID, and 1 for what you (company) want. 

0 Likes

Thanks! that helps. But now I need to learn how to communicate via the HCI uart.

I see the routine mesh_app_proc_rx_cmd() but there does not seem to be any documentation on the format of the data packet to be sent to it nor how to config the port to accept such data. I have posted a similar question in another post.

Thanks,

Rob

0 Likes

If you want to use WICED HCI UART you can use common\apps\snip\mesh\ClientControl.  All the source code is there and release directory has the binary that you can use. There will be also a document (Mesh Client something) in the doc directory.  Meanwhile, you can use whatever you want to use on the timer, or interrupt.  Don't need to involve second MCU.

0 Likes

So, there is no way from my main controller to send and receive command to the ble module?

why do you have a routine that cant be used? All I want is what is the format of the data to be sent to the module to use the mesh. or is it private and not usable outside the cypress products?

I dont see a common directory in the sample code. where is it?

If this is the case I cant use this and need to go to another product.

0 Likes

You are certainly more than welcome to go to another product. but I think I was pretty clear in my message.  there is a sample "MCU" application which is called ClientControl.  The source code for this application is in common\apps\snip\mesh\ClientControl.  The interface is documented.  In the Modus Toolbox click on the Documentation tab, the WICED API Reference then WICED HCI Control Protocol.

0 Likes

I don't want to go elsewhere, I am using a couple psoc products. I just thought the answer would be something simple like  
<companycode><opcode><data>   or companycode,opcode,data,data_len or  <opcode><comanycode><data><len> 

but I will reverse engineer it as its not a published string that I can find.

Best Regards,

Rob

0 Likes

reverse engineering is illegal.  But you are lucky,  When the source code and documentation are provided, it is not called reverse engineering.

0 Likes

There has to be a format that the routine expects so It knows what value is what, or is the routine smart enough to just throw data at it in any random order and it will figure what is the opcode,company,data and len ...

I'll figure it out, I just thought I could get an answer that will save me an hour or so.

-Rob

****** UPDATE

i think the format is as follows for anyone who is also wondering

XXXX|YYYYyy|AAAA

X = opcode

Y = company code (SIG)

y = is added for custom vendor

A = data

will be testing more Monday and will add as needed.

0 Likes

Please tell me where the Wiced HCI Control Protocal document is here?

Is it in the API doc because I cannot find any reference to

<code>

mesh_app_proc_rx_cmd(uint16_t opcode, uint8_t *p_data, uint32_t length)

</code>

I am not trying to be difficult, I have over 300 current devices and 1000's future devices that I want to use this module on. I just want to finalize my PCB so I can get it made but need to make sure I have the right hardware.

2019-06-28_2157

i did an update last night but it didn’t Save.

i seem to of had a version of the sample code that was missing  like 3 lines of code in the

above mentioned routine. Missing important values like opcode.

donr know how the sync failed like this but it did.

hope this makes things work, still wish the use of an external Controller was documented

using the hci Uart. I did a search in the api pdf and nothing about it. unless I am using the wrong

document....

best regards,

Rob

0 Likes

Hi Robert,

In the ModusToolbox click on the Documentation tab, the WICED API Reference then WICED HCI Control Protocol

Also, please search wiced_bt_mesh_app.h for getting mesh_app_proc_rx_cmd definition.

wiced_bt_mesh_app_proc_rx_cmd_tThis function is called in the mesh_application_proc_rx_cmd() function in mesh_app_hci.c. Implementation of this function in the user application code is optional. If defined in the user application code, this function is called when an HCI UART command is received from the external host. This function is relevant in the case of a hosted MCU implementation; it is not applicable for a standalone chip implementation

Thanks,

-Dheeraj

0 Likes
lock attach
Attachments are accessible only for community members.

Dheeraj,

Thank you. I did find this definition. I think I am looking at the wrong thing because when I try to enter a value like

011201 to the vendor sample I get

Company_id:131 opcode:3f

Then a line starting

Mesh_vendor.... ignored

At the end.

I ultimately want to use any existing external processor to communicate with this module if possible (which it not looking like it is now)

I am using the windows helper app and entering the data in the vendor data field

Here is a screenshot at I can’t log into the community any more. This is a response to your email

Best regards,

Rob Berry

R&J control

When the power fails...

We won't!

0 Likes

Hi Robert,

If you are using old version of BTSDK then please switch to BTSDK1.3​​ (latest). We have fixed a bunch of issue in this release.

I would suggest you to create a new network and provision vendor specific app using MeshClient and then you will be able to send vendor specific data.

Thanks,

-Dheeraj

0 Likes

Ok, so I can’t now but, I will do what you say and I should then be able to send data between two devices via the terminal. And it doesn’t matter the format of the data (location of opcode/company/data/data Len as the system will figure it out. (Can’t wait to see this as I don’t think I have ever seen this happen)

So

1. Rebuild custom app is ver 1.3

2. Put on 2 boards and provision both on a new network

3. Open 2 terminals to the Serial port one for each board

I should be able to see bi-directional data With no data format restrictions.

Just want to be clear so if it doesn’t work, I can say where it failed.

Best regards,

Rob Berry

R&J control

When the power fails...

We won't!

0 Likes

Also, In addition as I still can’t log into the community so can’t edit my last post.

I can do the following;

1. Connect to an existing network

2. Provision a device

3. Select the new device from the drop down

4. Send a value using the custom vendor field and see it in the log window below.

I just can’t see it in the debug data in the terminal.

Rob Berry

R&J control

When the power fails...

We won't!

0 Likes

Hi Robert,

In either way you will be able to communicate to your vendor specific app using MeshClient. But I would suggest you to create a new network on MeshClient and provision vendor specific app for your testing.

You can check MeshClient log for sent messages and the acknowledgement from the server (The logs will be saved in trace.txt). And also you can observe serial logs for each devices.

Thanks,

-Dheeraj

0 Likes
lock attach
Attachments are accessible only for community members.

Thanks about the tip on the logs.

I am wondering if I am not enabling the HCI uart functions properly.

I see the HCI_CONTROL compiler directive. Do all I need to to is add a #define HCI_CONTROL 1 ?

Or is there another way?

ALSO

I can not log into the community any more and get errors. Who do I email to resolve this? I don’t see a tech support email on the page.

Best Regards and thanks for your patients. I love the cypress psoc product and have told many about it. Have also given many dev kits to people to get them interested.

-Rob Berry

Sent from Mail for Windows 10

0 Likes

Hi Robert,

FYI. Sorry, I couldn't open your attachment.

Are you getting any error while sending the Vendor specific messages using MeshClient? Or any difficulty in sending HCI command using MeshClientControl? Could you please provide more information about the issue?

If you see any login issue you can either post Community Help- Login Questions?  (Please go through it) or send e-mail to sara.leslie@cypress.com​.  

For addressing login issues, bugs etc we can research the issue more quickly if you include the following information.

  • Email
  • URL of issue
  • Screen shot
  • Browser being used
  • Day/Time issue occurred
  • Additional information as applicable

Thanks,

-Dheeraj

0 Likes