<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CYBT-213043-MESH &#8211; IoT Expert</title>
	<atom:link href="https://iotexpert.com/category/devkits/cybt-213043-mesh/feed/" rel="self" type="application/rss+xml" />
	<link>https://iotexpert.com</link>
	<description>Engineering for the Internet of Things</description>
	<lastBuildDate>Mon, 11 Jan 2021 22:54:29 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://iotexpert.com/wp-content/uploads/2017/01/cropped-Avatar-32x32.jpg</url>
	<title>CYBT-213043-MESH &#8211; IoT Expert</title>
	<link>https://iotexpert.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Mouser Bluetooth Mesh: L7 Modifying the Dimmable Light Code to Add Another Light Element</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:42:10 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6986</guid>

					<description><![CDATA[Summary In this project I will create a Bluetooth Mesh Node that has two Light Lightness Server elements, one to control the red LED and one to control the Green LED.  The purpose is to show an example adding elements to a node. I will start with the BLE_Mesh_LightDimmable and then modify it to add [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>In this project I will create a Bluetooth Mesh Node that has two Light Lightness Server elements, one to control the red LED and one to control the Green LED.  The purpose is to show an example adding elements to a node.</p>
<p>I will start with the BLE_Mesh_LightDimmable and then modify it to add the ability to control the Green LED as well.</p>
<p>To implement this lesson I will follow these steps:</p>
<ol>
<li>Make New Application with BLE_Mesh_LightDimmable Template</li>
<li>Program it to make sure that things are still working</li>
<li>Modify led_control.h to handle two LEDs</li>
<li>Modify led_control.c to handle two LEDs</li>
<li>Modify light_dimmable.c to update the Bluetooth Mesh Configuration</li>
<li>Test</li>
</ol>
<h1>Make New Project with BLE_Mesh_LightDimmable Template</h1>
<p>Use File-&gt;New-&gt;ModusToobox IDE Application</p>
<p><a href="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM.png" rel="attachment wp-att-7027"><img fetchpriority="high" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM-1024x150.png" alt="" class="alignnone wp-image-7027 size-large" width="1024" height="150" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM-1024x150.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM-600x88.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM-300x44.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM-768x113.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.14.39-AM.png 1678w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Pick the &#8220;CYBT-213043-MESH&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-4-28-56-am/" rel="attachment wp-att-7020"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM-1024x611.png" alt="" class="alignnone size-large wp-image-7020" width="1024" height="611" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM-1024x611.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM-600x358.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM-768x458.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.28.56-AM.png 1684w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Choose &#8220;BLE_Mesh_LightDimmable&#8221; and name your project &#8220;VTW_RedGreen&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-4-29-22-am/" rel="attachment wp-att-7019"><img decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM-1024x585.png" alt="" class="alignnone size-large wp-image-7019" width="1024" height="585" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM-1024x585.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM-600x343.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM-300x171.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM-768x439.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.22-AM.png 1754w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click &#8220;Finish&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-4-29-40-am/" rel="attachment wp-att-7018"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM-1024x573.png" alt="" class="alignnone size-large wp-image-7018" width="1024" height="573" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM-1024x573.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM-600x335.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM-300x168.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM-768x429.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.29.40-AM.png 1116w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Program it to make sure that things are still working by clicking &#8220;Launches -&gt; VTW_RedGreen Build + Program&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-4-31-10-am/" rel="attachment wp-att-7021"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM-1024x244.png" alt="" class="alignnone size-large wp-image-7021" width="1024" height="244" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM-1024x244.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM-600x143.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM-300x71.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM-768x183.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.31.10-AM.png 1454w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After it is downloaded you can see that it boots.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-4-32-56-am/" rel="attachment wp-att-7024"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM-1024x454.png" alt="" class="alignnone size-large wp-image-7024" width="1024" height="454" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM-1024x454.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM-600x266.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM-300x133.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM-768x341.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.32.56-AM.png 1366w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Press &#8220;Start Scan&#8221;.  After a while you will see that it found the device.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-9-50-55-am/" rel="attachment wp-att-7030"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM-1024x660.png" alt="" class="alignnone size-large wp-image-7030" width="1024" height="660" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.50.55-AM.png 1970w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now press &#8220;Provision and configure&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-9-54-06-am/" rel="attachment wp-att-7031"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM-1024x659.png" alt="" class="alignnone size-large wp-image-7031" width="1024" height="659" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM-1024x659.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM-768x494.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-9.54.06-AM.png 1978w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Modify led_control.h</h1>
<p>The files led_control.h and .c are used to manage the LED.  I will extend the led_control_set_brightness_level by adding the ability to control two LEDs &#8211; a Red and a Green</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">typedef enum {
	RED,
	GREEN,
} led_control_t;

void led_control_init(void);
void led_control_set_brighness_level(led_control_t whichLED, uint8_t brightness_level);</pre>
<h1>Modify led_control.c</h1>
<p>Now I need to hook up a PWM to the Green LED.  I will use PWM1 (notice that I also change the PWM_CHANNEL to _RED and _GREEN)</p>
<pre class="start-line:53 EnlighterJSRAW" data-enlighter-language="c">#define PWM_CHANNEL_RED           PWM0
#define PWM_CHANNEL_GREEN         PWM1
</pre>
<p>The led_control_init function is used to setup the hardware.  Specifically to configure the two PWMs to be attached to the correct pins.</p>
<pre class="start-line:72 EnlighterJSRAW" data-enlighter-language="c">void led_control_init(void)
{
    pwm_config_t pwm_config;

    /* configure PWM */
    wiced_hal_gpio_select_function(WICED_GPIO_PIN_LED_2, WICED_PWM0);
    wiced_hal_gpio_select_function(WICED_GPIO_PIN_LED_3, WICED_PWM1);

    wiced_hal_aclk_enable(PWM_INP_CLK_IN_HZ, ACLK1, ACLK_FREQ_24_MHZ);
    wiced_hal_pwm_get_params(PWM_INP_CLK_IN_HZ, 0, PWM_FREQ_IN_HZ, &amp;pwm_config);
    wiced_hal_pwm_start(PWM_CHANNEL_RED, PMU_CLK, pwm_config.toggle_count, pwm_config.init_count, 1);
    wiced_hal_pwm_start(PWM_CHANNEL_GREEN, PMU_CLK, pwm_config.toggle_count, pwm_config.init_count, 1);
}</pre>
<p>Finally, I modify the &#8230;set_brightness&#8230; function to handle Red and Green.</p>
<pre class="start-line:85 EnlighterJSRAW" data-enlighter-language="c">void led_control_set_brighness_level(led_control_t whichLED, uint8_t brightness_level)
{
    pwm_config_t pwm_config;

    WICED_BT_TRACE("set brightness:%d\n", brightness_level);

    // ToDo.  For some reason, setting brightness to 100% does not work well on 20719B1 platform. For now just use 99% instead of 100.
    if (brightness_level == 100)
        brightness_level = 99;

    wiced_hal_pwm_get_params(PWM_INP_CLK_IN_HZ, brightness_level, PWM_FREQ_IN_HZ, &amp;pwm_config);
    switch(whichLED)
    {
    case RED:
        wiced_hal_pwm_change_values(PWM_CHANNEL_RED, pwm_config.toggle_count, pwm_config.init_count);

    break;
    case GREEN:
        wiced_hal_pwm_change_values(PWM_CHANNEL_GREEN, pwm_config.toggle_count, pwm_config.init_count);

    	break;
    }
}</pre>
<h1>Modify light_dimmable.c</h1>
<p>Now I need to add a new element to the mesh_elements array.  Before I can do that, it need to create new element array called &#8220;mesh_element2_models&#8221; with the model that I need.  Notice that I also change the original code to have _RED</p>
<pre class="start-line:116 EnlighterJSRAW" data-enlighter-language="c">wiced_bt_mesh_core_config_model_t   mesh_element1_models[] =
{
    WICED_BT_MESH_DEVICE,
    WICED_BT_MESH_MODEL_USER_PROPERTY_SERVER,
    WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER,
};
#define MESH_APP_NUM_MODELS_RED  (sizeof(mesh_element1_models) / sizeof(wiced_bt_mesh_core_config_model_t))




wiced_bt_mesh_core_config_property_t mesh_element1_properties[] =
{
    {
        .id          = WICED_BT_MESH_PROPERTY_DEVICE_FIRMWARE_REVISION,
        .type        = WICED_BT_MESH_PROPERTY_TYPE_USER,
        .user_access = WICED_BT_MESH_PROPERTY_ID_READABLE,
        .max_len     = WICED_BT_MESH_PROPERTY_LEN_DEVICE_FIRMWARE_REVISION,
        .value       = mesh_prop_fw_version
    },
};
#define MESH_APP_NUM_PROPERTIES (sizeof(mesh_element1_properties) / sizeof(wiced_bt_mesh_core_config_property_t))

wiced_bt_mesh_core_config_model_t   mesh_element2_models[] =
{
    WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER,
};
#define MESH_APP_NUM_MODELS_GREEN  (sizeof(mesh_element2_models) / sizeof(wiced_bt_mesh_core_config_model_t))

#define MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX_RED   0
#define MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX_GREEN   1

wiced_bt_mesh_core_config_element_t mesh_elements[] =
{
    {
        .location = MESH_ELEM_LOC_MAIN,                                 // location description as defined in the GATT Bluetooth Namespace Descriptors section of the Bluetooth SIG Assigned Numbers
        .default_transition_time = MESH_DEFAULT_TRANSITION_TIME_IN_MS,  // Default transition time for models of the element in milliseconds
        .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE,     // Default element behavior on power up
        .default_level = 0,                                             // Default value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_min = 1,                                                 // Minimum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_max = 0xffff,                                            // Maximum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .move_rollover = 0,                                             // If true when level gets to range_max during move operation, it switches to min, otherwise move stops.
        .properties_num = MESH_APP_NUM_PROPERTIES,                      // Number of properties in the array models
        .properties = mesh_element1_properties,                         // Array of properties in the element.
        .sensors_num = 0,                                               // Number of sensors in the sensor array
        .sensors = NULL,                                                // Array of sensors of that element
        .models_num = MESH_APP_NUM_MODELS_RED,                          // Number of models in the array models
        .models = mesh_element1_models,                                 // Array of models located in that element. Model data is defined by structure wiced_bt_mesh_core_config_model_t
    },
    {
        .location = MESH_ELEM_LOC_MAIN,                                 // location description as defined in the GATT Bluetooth Namespace Descriptors section of the Bluetooth SIG Assigned Numbers
        .default_transition_time = MESH_DEFAULT_TRANSITION_TIME_IN_MS,  // Default transition time for models of the element in milliseconds
        .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE,     // Default element behavior on power up
        .default_level = 0,                                             // Default value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_min = 1,                                                 // Minimum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_max = 0xffff,                                            // Maximum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .move_rollover = 0,                                             // If true when level gets to range_max during move operation, it switches to min, otherwise move stops.
        .properties_num = 0,                                            // Number of properties in the array models
        .properties = NULL,                                             // Array of properties in the element.
        .sensors_num = 0,                                               // Number of sensors in the sensor array
        .sensors = NULL,                                                // Array of sensors of that element
        .models_num = MESH_APP_NUM_MODELS_GREEN,                              // Number of models in the array models
        .models = mesh_element2_models,                                 // Array of models located in that element. Model data is defined by structure wiced_bt_mesh_core_config_model_t
    },

};</pre>
<p>In the mesh_app_init function you need to initialize the new light lightness server model. We will use the same message handler for both light lightness server models.</p>
<pre class="start-line:282 EnlighterJSRAW" data-enlighter-language="c">    wiced_bt_mesh_model_light_lightness_server_init(MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX_GREEN, mesh_app_message_handler, is_provisioned);
</pre>
<p>Search and replace all of the &#8220;led_control_set_brighness_level(attention_brightness);&#8221; to be &#8220;led_control_set_brighness_level(<span>RED</span>,attention_brightness);&#8221;</p>
<p>The last step is to update the mesh_app_process_set_level callback to handle the two cases.</p>
<pre class="start-line:341 EnlighterJSRAW" data-enlighter-language="c">/*
 * Command from the level client is received to set the new level
 */
void mesh_app_process_set_level(uint8_t element_idx, wiced_bt_mesh_light_lightness_status_t *p_status)
{
    WICED_BT_TRACE("mesh light srv set level element:%d present actual:%d linear:%d remaining_time:%d\n",
        element_idx, p_status-&gt;lightness_actual_present, p_status-&gt;lightness_linear_present, p_status-&gt;remaining_time);

    last_known_brightness = (uint8_t)((uint32_t)p_status-&gt;lightness_actual_present * 100 / 65535);
    if(element_idx == MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX_RED)
    		led_control_set_brighness_level(RED,last_known_brightness);

    if(element_idx == MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX_GREEN)
    		led_control_set_brighness_level(GREEN,last_known_brightness);

    // If we were alerting user, stop it.
    wiced_stop_timer(&amp;attention_timer);
}
</pre>
<h1>Test</h1>
<p>Do a &#8220;Node Reset&#8221; to remove the old node from the network.  It doesn&#8217;t really matter&#8230; but I find it less confusing to have it gone.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-05-47-am/" rel="attachment wp-att-7033"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM-1024x660.png" alt="" class="alignnone size-large wp-image-7033" width="1024" height="660" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.05.47-AM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Program the kit using the launch &#8220;VTW_RedGreen Build + Program&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-07-41-am/" rel="attachment wp-att-7034"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.07.41-AM-1024x211.png" alt="" class="alignnone size-large wp-image-7034" width="1024" height="211" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.07.41-AM-1024x211.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.07.41-AM-600x123.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.07.41-AM-300x62.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.07.41-AM-768x158.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Press &#8220;Scan Unprovisioned&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-08-25-am/" rel="attachment wp-att-7035"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM-1024x660.png" alt="" class="alignnone size-large wp-image-7035" width="1024" height="660" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.08.25-AM.png 1970w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Press &#8220;Provision and configure&#8221;.  It takes a minute.  When it is done you will see &#8220;&#8230;done&#8221; in the trace window.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-09-09-am/" rel="attachment wp-att-7036"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM-1024x659.png" alt="" class="alignnone size-large wp-image-7036" width="1024" height="659" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM-1024x659.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.09.09-AM.png 1972w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now I can &#8220;Control&#8221; the two LEDs.  Notice that the address of the first one is 0002 and the second is 0003.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-10-14-am/" rel="attachment wp-att-7037"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM-1024x661.png" alt="" class="alignnone size-large wp-image-7037" width="1024" height="661" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM-1024x661.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.14-AM.png 1972w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>When I do &#8220;Set&#8221; I can turn on the Green LED.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/screen-shot-2019-05-27-at-10-10-38-am/" rel="attachment wp-att-7038"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM-1024x660.png" alt="" class="alignnone size-large wp-image-7038" width="1024" height="660" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.10.38-AM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L6 The Dimmable Light Code</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l6-the-dimmable-light-code/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l6-the-dimmable-light-code/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:38:36 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6985</guid>

					<description><![CDATA[Summary This is a programming class.  So let&#8217;s take a closer look at the Light Dimmable Project.  It is not very hard.  The project is broken up into three main files led_control.h &#8211; which is the public interface to control the LED. led_control.c &#8211; the actual functions to control the LED. light_dimmable.c &#8211; the user [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>This is a programming class.  So let&#8217;s take a closer look at the Light Dimmable Project.  It is not very hard.  The project is broken up into three main files</p>
<ol>
<li>led_control.h &#8211; which is the public interface to control the LED.</li>
<li>led_control.c &#8211; the actual functions to control the LED.</li>
<li>light_dimmable.c &#8211; the user application part of the Bluetooth Mesh.</li>
</ol>
<p>We will dig through these files one at a time.</p>
<h1>led_control.h</h1>
<p>This file is the public API for controlling the LED.  There are two functions, the first &#8220;led_control_init&#8221; which must setup the hardware for the LED.  And a function to set the brightness level.  OK that is simple enough.</p>
<pre class="EnlighterJSRAW" data-enlighter-language="c">#ifndef __LED_CONTROL__H
#define __LED_CONTROL__H

#ifdef __cplusplus
extern "C" {
#endif

void led_control_init(void);
void led_control_set_brighness_level(uint8_t brightness_level);

#ifdef __cplusplus
}
#endif

#endif
</pre>
<h1>led_control.c</h1>
<p>The two functions in this file are led_control_init which just sets up a PWM to control the LED.  We are using the CYW20819A1.  The wiced_had_gpio_select_function just tells the pin to connect the pin mux to PWM0.</p>
<pre class="start-line:73 EnlighterJSRAW" data-enlighter-language="c"">void led_control_init(void)
{
    pwm_config_t pwm_config;

    /* configure PWM */
#ifdef CYW20719B1
    wiced_hal_pwm_configure_pin(led_pin, PWM_CHANNEL);
#endif

#ifdef CYW20819A1
    wiced_hal_gpio_select_function(WICED_GPIO_PIN_LED_2, WICED_PWM0);
#endif
    wiced_hal_aclk_enable(PWM_INP_CLK_IN_HZ, ACLK1, ACLK_FREQ_24_MHZ);
    wiced_hal_pwm_get_params(PWM_INP_CLK_IN_HZ, 0, PWM_FREQ_IN_HZ, &amp;pwm_config);
    wiced_hal_pwm_start(PWM_CHANNEL, PMU_CLK, pwm_config.toggle_count, pwm_config.init_count, 1);
}</pre>
<p>You can see the API documentation by clicking Help-&gt;ModusToolbox API Reference&#8211;&gt;WICED API Reference</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/screen-shot-2019-05-27-at-4-49-07-pm/" rel="attachment wp-att-7174"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM-1024x605.png" alt="" width="1024" height="605" class="alignnone size-large wp-image-7174" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM-1024x605.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM-600x355.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM-300x177.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM-768x454.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.49.07-PM.png 1340w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>I look down through the documentation until I find the wiced_hal_gpio_select_function</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/screen-shot-2019-05-27-at-4-50-10-pm/" rel="attachment wp-att-7175"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.50.10-PM-1024x542.png" alt="" width="1024" height="542" class="alignnone size-large wp-image-7175" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.50.10-PM-1024x542.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.50.10-PM-600x318.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.50.10-PM-300x159.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-4.50.10-PM-768x407.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>The led_control_set_brighness_level takes an input level from 0-100 and picks out the right PWM duty cycle.</p>
<pre class="start-line:90 EnlighterJSRAW" data-enlighter-language="c"">void led_control_set_brighness_level(uint8_t brightness_level)
{
    pwm_config_t pwm_config;

    WICED_BT_TRACE("set brightness:%d\n", brightness_level);

    // ToDo.  For some reason, setting brightness to 100% does not work well on 20719B1 platform. For now just use 99% instead of 100.
    if (brightness_level == 100)
        brightness_level = 99;

    wiced_hal_pwm_get_params(PWM_INP_CLK_IN_HZ, brightness_level, PWM_FREQ_IN_HZ, &amp;pwm_config);
    wiced_hal_pwm_change_values(PWM_CHANNEL, pwm_config.toggle_count, pwm_config.init_count);
}
</pre>
<h1>light_dimmable.c</h1>
<p>There are 6 sections of the Bluetooth Mesh User Application firmware.</p>
<ol>
<li>Mesh Element/Model</li>
<li>Mesh Core Configuration</li>
<li>Mesh Application Callbacks</li>
<li>mesh_app_init</li>
<li>Attention Handler (a new concept)</li>
<li>Light Server Handler</li>
</ol>
<h1>light_dimmable.c &#8211; Mesh Element/Model</h1>
<p>This project will have one element, which holds three models including a property server (which has one property)</p>
<pre class="start-line:116 EnlighterJSRAW" data-enlighter-language="c"">wiced_bt_mesh_core_config_model_t   mesh_element1_models[] =
{
    WICED_BT_MESH_DEVICE,
    WICED_BT_MESH_MODEL_USER_PROPERTY_SERVER,
    WICED_BT_MESH_MODEL_LIGHT_LIGHTNESS_SERVER,
};
#define MESH_APP_NUM_MODELS  (sizeof(mesh_element1_models) / sizeof(wiced_bt_mesh_core_config_model_t))

wiced_bt_mesh_core_config_property_t mesh_element1_properties[] =
{
    {
        .id          = WICED_BT_MESH_PROPERTY_DEVICE_FIRMWARE_REVISION,
        .type        = WICED_BT_MESH_PROPERTY_TYPE_USER,
        .user_access = WICED_BT_MESH_PROPERTY_ID_READABLE,
        .max_len     = WICED_BT_MESH_PROPERTY_LEN_DEVICE_FIRMWARE_REVISION,
        .value       = mesh_prop_fw_version
    },
};
#define MESH_APP_NUM_PROPERTIES (sizeof(mesh_element1_properties) / sizeof(wiced_bt_mesh_core_config_property_t))


#define MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX   0

wiced_bt_mesh_core_config_element_t mesh_elements[] =
{
    {
        .location = MESH_ELEM_LOC_MAIN,                                 // location description as defined in the GATT Bluetooth Namespace Descriptors section of the Bluetooth SIG Assigned Numbers
        .default_transition_time = MESH_DEFAULT_TRANSITION_TIME_IN_MS,  // Default transition time for models of the element in milliseconds
        .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE,     // Default element behavior on power up
        .default_level = 0,                                             // Default value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_min = 1,                                                 // Minimum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_max = 0xffff,                                            // Maximum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .move_rollover = 0,                                             // If true when level gets to range_max during move operation, it switches to min, otherwise move stops.
        .properties_num = MESH_APP_NUM_PROPERTIES,                      // Number of properties in the array models
        .properties = mesh_element1_properties,                         // Array of properties in the element.
        .sensors_num = 0,                                               // Number of sensors in the sensor array
        .sensors = NULL,                                                // Array of sensors of that element
        .models_num = MESH_APP_NUM_MODELS,                              // Number of models in the array models
        .models = mesh_element1_models,                                 // Array of models located in that element. Model data is defined by structure wiced_bt_mesh_core_config_model_t
    },
};</pre>
<h1>light_dimmable.c &#8211; Mesh Core Config</h1>
<p>This configuration structure is read by the Bluetooth Mesh stack automatically.  It just tells the stack how to behave.</p>
<pre class="start-line:158 EnlighterJSRAW" data-enlighter-language="c"">wiced_bt_mesh_core_config_t  mesh_config =
{
    .company_id         = MESH_COMPANY_ID_CYPRESS,                  // Company identifier assigned by the Bluetooth SIG
    .product_id         = MESH_PID,                                 // Vendor-assigned product identifier
    .vendor_id          = MESH_VID,                                 // Vendor-assigned product version identifier
    .replay_cache_size  = MESH_CACHE_REPLAY_SIZE,                   // Number of replay protection entries, i.e. maximum number of mesh devices that can send application messages to this device.
    .features           = WICED_BT_MESH_CORE_FEATURE_BIT_FRIEND | WICED_BT_MESH_CORE_FEATURE_BIT_RELAY | WICED_BT_MESH_CORE_FEATURE_BIT_GATT_PROXY_SERVER,   // In Friend mode support friend, relay
    .friend_cfg         =                                           // Configuration of the Friend Feature(Receive Window in Ms, messages cache)
    {
        .receive_window        = 200,                               // Receive Window value in milliseconds supported by the Friend node.
        .cache_buf_len         = 300,                               // Length of the buffer for the cache
        .max_lpn_num           = 4                                  // Max number of Low Power Nodes with established friendship. Must be &gt; 0 if Friend feature is supported. 
    },
    .low_power          =                                           // Configuration of the Low Power Feature
    {
        .rssi_factor           = 0,                                 // contribution of the RSSI measured by the Friend node used in Friend Offer Delay calculations.
        .receive_window_factor = 0,                                 // contribution of the supported Receive Window used in Friend Offer Delay calculations.
        .min_cache_size_log    = 0,                                 // minimum number of messages that the Friend node can store in its Friend Cache.
        .receive_delay         = 0,                                 // Receive delay in 1 ms units to be requested by the Low Power node.
        .poll_timeout          = 0                                  // Poll timeout in 100ms units to be requested by the Low Power node.
    },
    .gatt_client_only          = WICED_FALSE,                       // Can connect to mesh over GATT or ADV
    .elements_num  = (uint8_t)(sizeof(mesh_elements) / sizeof(mesh_elements[0])),   // number of elements on this device
    .elements      = mesh_elements                                  // Array of elements for this device
};
</pre>
<h1>light_dimmable.c &#8211; Mesh Application Callbacks</h1>
<p>The Bluetooth Mesh stack  interacts with your application via callbacks.  This structure tells the stack when you are interested in being called.</p>
<pre class="start-line:184 EnlighterJSRAW" data-enlighter-language="c" ">/*
 * Mesh application library will call into application functions if provided by the application.
 */
wiced_bt_mesh_app_func_table_t wiced_bt_mesh_app_func_table =
{
    mesh_app_init,          // application initialization
    NULL,                   // Default SDK platform button processing
    NULL,                   // GATT connection status
    mesh_app_attention,     // attention processing
    NULL,                   // notify period set
    NULL,                   // WICED HCI command
    NULL,                   // LPN sleep
    NULL                    // factory reset
};
</pre>
<h1>light_dimmable.c &#8211; mesh_app_init</h1>
<p>This function set&#8217;s up things after the stack starts.  Specifically it configures data for the property server. It also sets up the Scan Response packet.  Finally it turns on the servers for the Property and Light Lightness Servers and registers a callback function when messages are received for the light lightness server model.</p>
<pre class="start-line:206 EnlighterJSRAW" data-enlighter-language="c"">/******************************************************
 *               Function Definitions
 ******************************************************/
void mesh_app_init(wiced_bool_t is_provisioned)
{
#if 0
    extern uint8_t wiced_bt_mesh_model_trace_enabled;
    wiced_bt_mesh_model_trace_enabled = WICED_TRUE;
#endif
    wiced_bt_cfg_settings.device_name = (uint8_t *)"Dimmable Light";
    wiced_bt_cfg_settings.gatt_cfg.appearance = APPEARANCE_LIGHT_CEILING;

    mesh_prop_fw_version[0] = 0x30 + (WICED_SDK_MAJOR_VER / 10);
    mesh_prop_fw_version[1] = 0x30 + (WICED_SDK_MAJOR_VER % 10);
    mesh_prop_fw_version[2] = 0x30 + (WICED_SDK_MINOR_VER / 10);
    mesh_prop_fw_version[3] = 0x30 + (WICED_SDK_MINOR_VER % 10);
    mesh_prop_fw_version[4] = 0x30 + (WICED_SDK_REV_NUMBER / 10);
    mesh_prop_fw_version[5] = 0x30 + (WICED_SDK_REV_NUMBER % 10);
    mesh_prop_fw_version[6] = 0x30 + (WICED_SDK_BUILD_NUMBER / 10);
    mesh_prop_fw_version[7] = 0x30 + (WICED_SDK_BUILD_NUMBER % 10);

    // Adv Data is fixed. Spec allows to put URI, Name, Appearance and Tx Power in the Scan Response Data.
    if (!is_provisioned)
    {
        wiced_bt_ble_advert_elem_t  adv_elem[3];
        uint8_t                     buf[2];
        uint8_t                     num_elem = 0;

        adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_NAME_COMPLETE;
        adv_elem[num_elem].len         = (uint16_t)strlen((const char*)wiced_bt_cfg_settings.device_name);
        adv_elem[num_elem].p_data      = wiced_bt_cfg_settings.device_name;
        num_elem++;

        adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_APPEARANCE;
        adv_elem[num_elem].len         = 2;
        buf[0]                         = (uint8_t)wiced_bt_cfg_settings.gatt_cfg.appearance;
        buf[1]                         = (uint8_t)(wiced_bt_cfg_settings.gatt_cfg.appearance &gt;&gt; 8);
        adv_elem[num_elem].p_data      = buf;
        num_elem++;

        wiced_bt_mesh_set_raw_scan_response_data(num_elem, adv_elem);
    }
    led_control_init();

    wiced_init_timer(&amp;attention_timer, attention_timer_cb, 0, WICED_SECONDS_PERIODIC_TIMER);

    // Initialize Light Lightness Server and register a callback which will be executed when it is time to change the brightness of the bulb
    wiced_bt_mesh_model_light_lightness_server_init(MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX, mesh_app_message_handler, is_provisioned);

    // Initialize the Property Server.  We do not need to be notified when Property is set, because our only property is readonly
    wiced_bt_mesh_model_property_server_init(MESH_LIGHT_LIGHTNESS_SERVER_ELEMENT_INDEX, NULL, is_provisioned);
}</pre>
<h1>light_dimmable.c &#8211; Attention</h1>
<p>There are situations where the stack might want to get the user&#8217;s attention.   In the callback we setup the stack to call mesh_app_attention when it wants the user&#8217;s attention.  The parameter is how long the stack wants to alert the user.   This function starts a timer to blink the RED LED. Once the attention time has expired, the timer stops.</p>
<pre class="start-line:259 EnlighterJSRAW" data-enlighter-language="c"">*
 * Mesh library requests to alert user for "time" seconds.
 */
void mesh_app_attention(uint8_t element_idx, uint8_t time)
{
    WICED_BT_TRACE("dimmable light attention:%d sec\n", time);

    // If time is zero, stop alerting and restore the last known brightness
    if (time == 0)
    {
        wiced_stop_timer(&amp;attention_timer);
        led_control_set_brighness_level(last_known_brightness);
        return;
    }
    wiced_start_timer(&amp;attention_timer, 1);
    attention_time = time;
    attention_brightness = (last_known_brightness != 0) ? 0 : 100;
    led_control_set_brighness_level(attention_brightness);
}

/*
 * Attention timer callback is executed every second while user needs to be alerted.
 * Just switch brightness between 0 and 100%
 */
void attention_timer_cb(TIMER_PARAM_TYPE arg)
{
    WICED_BT_TRACE("dimmable light attention timeout:%d\n", attention_time);

    if (--attention_time == 0)
    {
        wiced_stop_timer(&amp;attention_timer);
        led_control_set_brighness_level(last_known_brightness);
        return;
    }
    attention_brightness = (attention_brightness == 0) ? 100 : 0;
    led_control_set_brighness_level(attention_brightness);
}
</pre>
<h1>light_dimmable.c &#8211; Light Server Handler</h1>
<p>When the Node receives a message that has been published to it to change the Light Lightness value, this function is called.  Basically it just calls the hardware API to change the LED brightness.</p>
<pre class="start-line:296 EnlighterJSRAW" data-enlighter-language="c" ">/*
 * Process event received from the models library.
 */
void mesh_app_message_handler(uint8_t element_idx, uint16_t event, void *p_data)
{
    switch (event)
    {
    case WICED_BT_MESH_LIGHT_LIGHTNESS_SET:
        mesh_app_process_set_level(element_idx, (wiced_bt_mesh_light_lightness_status_t *)p_data);
        break;

    default:
        WICED_BT_TRACE("dimmable light unknown msg:%d\n", event);
        break;
    }
}

/*
 * Command from the level client is received to set the new level
 */
void mesh_app_process_set_level(uint8_t element_idx, wiced_bt_mesh_light_lightness_status_t *p_status)
{
    WICED_BT_TRACE("mesh light srv set level element:%d present actual:%d linear:%d remaining_time:%d\n",
        element_idx, p_status-&gt;lightness_actual_present, p_status-&gt;lightness_linear_present, p_status-&gt;remaining_time);

    last_known_brightness = (uint8_t)((uint32_t)p_status-&gt;lightness_actual_present * 100 / 65535);
    led_control_set_brighness_level(last_known_brightness);

    // If we were alerting user, stop it.
    wiced_stop_timer(&amp;attention_timer);
}
</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l6-the-dimmable-light-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L5 Bluetooth Mesh Fundamentals</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/#comments</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:37:59 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6984</guid>

					<description><![CDATA[Summary This lesson walks you through the fundamentals of Bluetooth Mesh Networking.  There is actually quite a bit going on from a detail standpoint to make Bluetooth Mesh work as documented in the 713 pages of Bluetooth Mesh specifications: Bluetooth Mesh Profile (333 pages) Bluetooth Mesh Model (317 pages) Bluetooth Device Properties (63 Pages). However, Cypress [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>This lesson walks you through the fundamentals of Bluetooth Mesh Networking.  There is actually quite a bit going on from a detail standpoint to make Bluetooth Mesh work as documented in the 713 pages of <a href="https://www.bluetooth.com/specifications/mesh-specifications/" target="_blank" rel="noopener noreferrer">Bluetooth Mesh specifications</a>:</p>
<ul>
<li><a href="https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=457092" target="_blank" rel="noopener noreferrer">Bluetooth Mesh Profile</a> (333 pages)</li>
<li><a href="https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=457091" target="_blank" rel="noopener noreferrer">Bluetooth Mesh Model</a> (317 pages)</li>
<li><a href="https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=429635" target="_blank" rel="noopener noreferrer">Bluetooth Device Properties</a> (63 Pages).</li>
</ul>
<p>However, Cypress has abstracted a significant amount of this complexity into our stack so as to ease your journey.</p>
<p>Specifically in this lesson we will talk about:</p>
<ol>
<li>Topology</li>
<li>Elements</li>
<li>Addressing</li>
<li>Messaging</li>
<li>Subscribe &amp; Publish</li>
<li>Models</li>
<li>State</li>
<li>Complexity</li>
<li>Security</li>
<li>Provisioning &amp; Configuration</li>
<li>Bluetooth Mesh Stack</li>
</ol>
<h1>Bluetooth Mesh Topology</h1>
<p>Let&#8217;s start by examining a prototypical Bluetooth Mesh network:</p>
<p>&nbsp;</p>
<div class="page" title="Page 5"><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/mesh-arch/" rel="attachment wp-att-7211"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/mesh-arch.png" alt="" width="862" height="775" class="alignnone size-full wp-image-7211" srcset="https://iotexpert.com/wp-content/uploads/2019/05/mesh-arch.png 862w, https://iotexpert.com/wp-content/uploads/2019/05/mesh-arch-600x539.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/mesh-arch-300x270.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/mesh-arch-768x690.png 768w" sizes="auto, (max-width: 862px) 100vw, 862px" /></a></div>
<div title="Page 5"><strong>Standard Node</strong><br />
The standard node functionality involves sending and receiving mesh messages. Every node in the network must be able to act as a standard node.<br />
<strong>Relay Node</strong><br />
Relay nodes can receive a message for the network and then retransmit it to other devices in range. This is the method by which mesh networks can cover larger distances than the range of any single device. For a network to operate, every node must be within range of at least one relay so that its messages can be forwarded on to nodes that it cannot directly communicate with.<br />
It is common for all except low power nodes to implement a relay feature in order to maximize the possible paths through a mesh network.</div>
<div title="Page 5">Relay nodes keep a cache of messages to prevent messages from cycling.  Each mesh message also has a TTL (time to live) to prevent cycling.<br />
<strong>GATT Proxy Node</strong><br />
Many existing BLE devices support traditional BLE GATT communication but not mesh communication. Most smartphones and tablets fall into this category. Since you may want to interact with a mesh network from one of those devices, the GATT proxy was created. A GATT proxy node has both a mesh interface and a GATT interface. The GATT interface is used to communicate with BLE devices that don&#8217;t possess a mesh stack and then relay those messages to/from the mesh network. That is, the GATT proxy acts as a bridge between the mesh network and the traditional BLE GATT device.<br />
<strong>Friend and Low Power Nodes</strong><br />
Friend and Low Power Nodes are used to optimize power consumption for constrained devices. Devices that are power constrained (e.g. a battery powered device) are designated as low power nodes. Every low power node in the network must be associated with exactly one friend node. Friend nodes are devices which are not power constrained (e.g. a device plugged into AC power) that support 1 or more low power nodes depending on its capabilities (e.g. available RAM).<br />
When a low power node is added to a mesh network it broadcasts a request for a friend. Each friend in range that can handle a new low power node replies and the low power node selects the best friend based on how many messages the friend can store; the RSSI and the timing accuracy.<br />
Once the relationship is established, the friend node will receive and store messages for any low power nodes that it is associated with. The low power node will periodically ask the friend node for any messages that the friend has stored for it. In this way, the low power node does not need to listen continuously for mesh packets. Instead, it can be in a low power mode most of the time and can wake up only periodically for a very short time.<br />
For example, consider a battery powered mesh connected thermostat. It will measure the actual temperature and may publish a mesh message with the temperature once per minute. This can be done with very low power consumption since the device can be sleeping all the time except for a short period each minute to send the value. However, it must also be possible to change the set point of the thermostat. In this case, instead of sending messages, the thermostat must be listening for messages. If it listens constantly for messages the power consumption will be unacceptably high, but if it only listens occasionally for messages it will likely miss messages. By making the thermostat a low power node we get the best of both worlds &#8211; it can send messages once a minute and receive any stored messages regarding the set point from its friend node. No messages are missed even though the thermostat is awake only a very small percentage of the time.</div>
<h1 title="Page 5">Bluetooth Mesh Elements</h1>
<p>An Element is just a &#8220;Thing&#8221; in the network.  For instance a light bulb or a light switch or a temperature sensor.  A physical node can be built up of multiple elements.  Think of a ceiling fan that also has a light bulb.</p>
<p>Each Element in the network will have an address and be uniquely addressable.  This means that a Node may have multiple Bluetooth Mesh addresses, but it will have only one Bluetooth MAC address.</p>
<h1>Bluetooth Mesh Addressing</h1>
<p>Mesh messages have a source address and a destination address. Both addresses are 16-bit values. There are three types of addresses defined for messages. They are:<br />
1. Unicast<br />
2. Group<br />
3. Virtual</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Address Type</th>
<th >Address Range</th>
<th >Number of Addresses</th>
</tr>
</thead>
<tbody>
<tr><td >Unassigned</td>
<td >0b0000000000000000</td>
<td >1</td>
</tr>

<tr><td >Unicast</td>
<td >0b0xxxxxxxxxxxxxxx</td>
<td >32767</td>
</tr>

<tr><td >Group</td>
<td >0b11xxxxxxxxxxxxxx</td>
<td >16384</td>
</tr>

<tr><td >Virtual</td>
<td >0b10xxxxxxxxxxxxxx</td>
<td >16384 hash values</td>
</tr>
</tbody></table></div>
<p><strong>Unicast</strong><br />
A unicast address is used to communicate with a single element in a single node. Each element in a network must have a unicast address that is unique to that network. During provisioning, the primary element in a node is assigned a unique unicast address and each additional element in the node uses the next address.<br />
The source address in any message must be a unicast address. That is, the message must specify the specific element that message was sent by. Group and Virtual addresses are not allowed as the source address.</p>
<p><strong>Group</strong><br />
As the name implies, a group address is used to communicate with one or more elements. Group addresses are either defined by the Bluetooth SIG (known as fixed group addresses) or are assigned dynamically for a given mesh network. There are 16K total group addresses available. The SIG has reserved space for 256 of them to be fixed while the rest can be dynamically chosen by the network.<br />
Of the 256 group addresses that the SIG has reserved for fixed addresses, currently only 4 of them are assigned specific purposes. The rest are reserved for future use. They are:</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Fixed Group Address</th>
<th >Name</th>
</tr>
</thead>
<tbody>
<tr><td >0b1111111100000000 – 0b1111111111111011</td>
<td >Reserved</td>
</tr>

<tr><td >0b1111111111111100</td>
<td >all-proxies</td>
</tr>

<tr><td >0b1111111111111101</td>
<td >all-friends</td>
</tr>

<tr><td >0b1111111111111110</td>
<td >all-relays</td>
</tr>

<tr><td >0b1111111111111111</td>
<td >all-nodes</td>
</tr>
</tbody></table></div>
<p>Other group addresses can be assigned for any logical group in the network. For example, room names such as kitchen, bedroom or living room could be identified as group names to control multiple elements at once. As another example, you can have one switch turn on/off multiple bulbs at the same time with a single message to a group address.</p>
<p><strong>Virtual</strong><br />
A virtual address is assigned to one or more elements across one or more nodes. A virtual address takes the form of a 128-bit UUID that any element can be assigned to, like a label. This 128-bit address is used in calculating the message integrity check.<br />
The 14 LSBs of the virtual address are set to a hash of the label UUID such that each hash represents many label UUIDs. When an access message is received for a virtual address with a matching hash, each corresponding label UUID is compared as part of the authentication to see if there is a matching element.<br />
This may be used by a manufacturer to allow mesh networks including those devices to send messages to all similar devices at one time.</p>
<h1>Bluetooth Mesh Messaging</h1>
<p>The Bluetooth Mesh communication happens using BLE Advertising packets. There are two classes of messages in the Bluetooth Mesh, Control and Access.  By and large the control messages are used for network control, and you never see them as they are handled by the stack.  The Access messages are ones that matter to us as application developers.</p>
<p>We all know that the BLE advertising  packet is only 31 bytes long.  This makes things difficult as most of the packet is used up by network protocol overhead leaving only a few bytes for the actual message.  The good news is that the stack handles splitting up your payload into as many as 32 packets (called segmented) and getting them re-sequenced automatically.</p>
<p>I&#8217;m not very good at limits &#8230; but this is what you have to live with in BLE Mesh:</p>
<div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >Message Type</th>
<th >Max Payload Size (Octets)</th>
</tr>
</thead>
<tbody>
<tr><td >Unsegmented Control or Access</td>
<td >11</td>
</tr>

<tr><td >Segmented Control</td>
<td >256</td>
</tr>

<tr><td >Segmented Access</td>
<td >376 or 380</td>
</tr>
</tbody></table></div>
<p><strong>Acknowledged vs. Unacknowledged</strong><br />
As the name suggests, acknowledged messages require a response from the node that it is addressed to. The response confirms that the message was received and it may also return data back to the sender (e.g. in response to a GET). If a sender does not receive the expected response from a message it may resend it. Messages must be idempotent so that a message received more than once is no different than if it had only been received once.</p>
<p><strong>GET, SET, STATUS</strong><br />
All access messages are of the three broad types of GET, SET, and STATUS.<br />
GET messages request a state value from one or more nodes. A GET message is always acknowledged.<br />
SET messages are used to change the value of a state. A SET message can be either acknowledged or unacknowledged.<br />
STATUS messages are sent in response to a GET, and acknowledged SET, or may also be sent by a node independently, for example, periodically using a timer. A STATUS message is always unacknowledged. Therefore, if a node sends a GET message but never receives a STATUS return message, it may resend the GET message.</p>
<h1>BLE Mesh Publishing</h1>
<p>From the BLE Mesh Spec &#8220;All communication within a mesh network is accomplished by sending messages. Messages operate on states. For each state, there is a defined set of messages that a server supports and a client may use to request a value of a state or to change a state. A server may also transmit unsolicited messages carrying information about states and/or changing states.&#8221;</p>
<p>The BLE Mesh Application communication scheme is based on the Publish/Subscribe &amp; Client/Server paradigm and are embedded automatically into Access messages by the stack.  An Element may publish messages (either to a group or a unicast address).  And an Element may subscribe to messages from one or more groups.</p>
<h1 title="Page 5">Models</h1>
<p>An Element is not very interesting without a mechanism to interact with it.  A Model is exactly that, specifically it is the Bluetooth SIG defined behavior and data/state of an Element.  Each Element in your Node will have one or more Models that are attached to it that you can think of as Servers which hold, send and receive data.</p>
<p>Models fall into three categories. Servers, Clients and Control (hybrid Server/Control)</p>
<p>Server:  Contains data and sends it out in response to Client GET requests or can update the data based on Client SET requests or may send Status based on changes in the Element.</p>
<p>Clients: Send GET requests to Servers or Send SET requests to Servers.</p>
<p>Control: A Hybrid Model that acts both as a Client and a Server.</p>
<p>Here is an example picture from the <a href="https://www.cypress.com/file/473921/download" target="_blank" rel="noopener noreferrer">AN227069 – Getting Started with Bluetooth Mesh</a></p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/screen-shot-2019-05-28-at-10-42-08-am/" rel="attachment wp-att-7236"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM-1024x1002.png" alt="" width="1024" height="1002" class="alignnone size-large wp-image-7236" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM-1024x1002.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM-600x587.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM-300x293.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM-768x751.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-10.42.08-AM.png 1278w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>To make this system work the Bluetooth SIG has also defined the standard behavior for a bunch of different models including:</p>
<h1>States</h1>
<p>From the Bluetooth Spec &#8220;A state is a value representing a condition of an element.&#8221;  States are associated with a particular server model. That is, the spec defines the states that apply to each server model and how they behave.</p>
<h1>Complexity</h1>
<p>There is quite a bit more going on in the Bluetooth Mesh specifications including the abilities to handle:</p>
<ul>
<li>Scenes (e.g. go in a room and have all the lights, sound, hvac go to the right levels)</li>
<li>State binding &#8211; Multiple states are bound together such that when one changes the others change (e.g. you turn the volume so low that it becomes off)</li>
<li>State transition times (e.g. Fade the lights up or down over a set time period)</li>
<li>Alerts (e.g. notify the user with a blinking light)</li>
</ul>
<h1 title="Page 5">Security</h1>
<p>There are three levels of security in a Bluetooth Mesh network and access is governed by three keys.</p>
<div title="Page 5"><strong>NetKey</strong><br />
All nodes in a mesh network must possess the network key. In fact, possession of the NetKey is what makes a node a member of a given mesh network. The NetKey allows a node to decrypt and authenticate messages at the network Layer. The mesh packet header and address are encrypted and authenticated with the network key. This allows a node to perform relay functions, but it does NOT allow the relay node to decrypt the application data that is stored in a message.<br />
<strong>AppKey</strong><br />
The mesh packet payload is encrypted and authenticated with the application key. Therefore, data for a specific application can only be decrypted by nodes that have the AppKey for that application. The AppKeys are used by the upper transport layer to decrypt and authenticate messages before passing them to the access layer.<br />
The existence of AppKeys allows multiple applications to share a mesh network (and therefore gain all the benefits of having more nodes such as increased reliability and range) without each node having access to all messages.<br />
For example, consider a mesh network that has lights, HVAC, and home security devices on it. The light fixtures and light switches would share an AppKey for lighting; the thermostats, furnace, and air conditioner would share an AppKey for HVAC; the door locks and alarm system would share an AppKey for home security. In this way, home security messages can only be decrypted by devices that are part of the home security system, etc.<br />
<strong>DevKey</strong><br />
Each device has its own unique device key known only to itself and the provisioner device. This key is used for secure communication during configuration.</div>
<h1 title="Page 5">Provisioning and Configuration</h1>
<p>When a node turns on for the first time it barely knows its own name.  It definitely does not know any of the security keys, its addresses (unicast or group) or any of its model configuration information.  So what does it do?  Simple &#8211; it starts to send out a BLE Advertising packet in the format of a BLE Mesh Beacon.  Then it waits for a provisioning device to make a BLE GATT connection to provision the node with the network information.  The provisioning process assigns the netkey and the unicast address of the primary  element.</p>
<p>After the device is provisioned it will be able to hear and decode BLE Mesh packets.  But, it won&#8217;t know much else to do until the Elements have been configured.  So, the next step for the provisioning application is to send the rest of the configuration information. e.g. group subscriptions, application keys etc.</p>
<h1 title="Page 5">Bluetooth Mesh Stack</h1>
<div title="Page 5"><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/meshstack/" rel="attachment wp-att-7213"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/meshstack.png" alt="" width="493" height="472" class="alignnone size-full wp-image-7213" srcset="https://iotexpert.com/wp-content/uploads/2019/05/meshstack.png 493w, https://iotexpert.com/wp-content/uploads/2019/05/meshstack-300x287.png 300w" sizes="auto, (max-width: 493px) 100vw, 493px" /></a></div>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L4 Integrating the Modus Toolbox Code Examples</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:37:54 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6982</guid>

					<description><![CDATA[Summary In this lesson I will show you how to find and use code examples.  I&#8217;ll then provision a motion sensor into my Bluetooth Mesh network and test.  Here are the steps: How to Find the Code Examples How to Import the Code Examples Explore the Code Examples How to Use a Code Example Provision [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>In this lesson I will show you how to find and use code examples.  I&#8217;ll then provision a motion sensor into my Bluetooth Mesh network and test.  Here are the steps:</p>
<ol>
<li>How to Find the Code Examples</li>
<li>How to Import the Code Examples</li>
<li>Explore the Code Examples</li>
<li>How to Use a Code Example</li>
<li>Provision the Motion Sensor Into the Network</li>
<li>Test the Motion Sensor</li>
</ol>
<h1>How to Find the Code Examples</h1>
<p>In the ModusToolbox Quick Panel pick &#8220;Search Online for Code Examples&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-21-37-am/" rel="attachment wp-att-7043"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.21.37-AM.png" alt="" width="770" height="184" class="alignnone size-full wp-image-7043" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.21.37-AM.png 770w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.21.37-AM-600x143.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.21.37-AM-300x72.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.21.37-AM-768x184.png 768w" sizes="auto, (max-width: 770px) 100vw, 770px" /></a></p>
<p>You will find yourself in a web browser on the cypressemiconductorco GitHub site.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-23-11-am/" rel="attachment wp-att-7045"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM-1024x1001.png" alt="" width="1024" height="1001" class="alignnone size-large wp-image-7045" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM-1024x1001.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM-600x586.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM-300x293.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM-768x751.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.11-AM.png 1866w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click on the link &#8220;Bluetooth SDK Examples&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-23-40-am/" rel="attachment wp-att-7044"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM-862x1024.png" alt="" width="862" height="1024" class="alignnone size-large wp-image-7044" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM-862x1024.png 862w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM-600x713.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM-253x300.png 253w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM-768x912.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.23.40-AM.png 1928w" sizes="auto, (max-width: 862px) 100vw, 862px" /></a></p>
<p>You can look around on the website at the examples.  Or &#8230;</p>
<h1>How to Import the Code Examples</h1>
<p>Click the &#8220;Clone or download&#8221; button.  This will give you this window which has the SSH or HTTPS address of the site.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-25-10-am/" rel="attachment wp-att-7046"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.25.10-AM.png" alt="" width="858" height="514" class="alignnone size-full wp-image-7046" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.25.10-AM.png 858w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.25.10-AM-600x359.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.25.10-AM-300x180.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.25.10-AM-768x460.png 768w" sizes="auto, (max-width: 858px) 100vw, 858px" /></a></p>
<p>Copy the location of the github repo &#8220;git@github.com:cypresssemiconductorco/Code-Examples-BT-SDK-for-ModusToolbox.git&#8221;.  Then go back to the Workspace Explorer.  Right click and select &#8220;Import&#8230;&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-04-am/" rel="attachment wp-att-7048"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.04-AM.png" alt="" width="450" height="484" class="alignnone size-large wp-image-7048" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.04-AM.png 450w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.04-AM-279x300.png 279w" sizes="auto, (max-width: 450px) 100vw, 450px" /></a></p>
<p>Choose Git&#8211;&gt;Projects from Git</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-26-am/" rel="attachment wp-att-7050"></a><a href="https://iotexpert.com/?attachment_id=7049" rel="attachment wp-att-7049"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM-987x1024.png" alt="" width="987" height="1024" class="alignnone size-large wp-image-7049" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM-987x1024.png 987w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM-600x623.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM-289x300.png 289w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM-768x797.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.14-AM.png 1054w" sizes="auto, (max-width: 987px) 100vw, 987px" /></a><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-26-am/" rel="attachment wp-att-7050"></a></p>
<p>Select &#8220;Clone URI&#8221; (so you can get the examples from the Internet)</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-26-am/" rel="attachment wp-att-7050"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM-970x1024.png" alt="" width="970" height="1024" class="alignnone size-large wp-image-7050" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM-970x1024.png 970w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM-600x633.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM-284x300.png 284w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM-768x811.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.26-AM.png 1042w" sizes="auto, (max-width: 970px) 100vw, 970px" /></a></p>
<p>Paste in the URI (which you copied from the web browser) Then press Next&#8211;&gt;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-39-am/" rel="attachment wp-att-7051"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM-1024x785.png" alt="" width="1024" height="785" class="alignnone size-large wp-image-7051" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM-1024x785.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM-600x460.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM-300x230.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM-768x588.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.39-AM.png 1446w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Pick out the master branch.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-27-59-am/" rel="attachment wp-att-7052"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM-1024x776.png" alt="" width="1024" height="776" class="alignnone size-large wp-image-7052" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM-1024x776.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM-600x455.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM-300x227.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM-768x582.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.27.59-AM.png 1452w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>You will now need to tell Eclipse where you want it to save the repository on your local machine.  I let it select the default location and press Next &#8211;&gt;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-28-08-am/" rel="attachment wp-att-7053"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM-1024x780.png" alt="" width="1024" height="780" class="alignnone size-large wp-image-7053" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM-1024x780.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM-600x457.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM-300x229.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM-768x585.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.28.08-AM.png 1454w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>To make things easy, you can then import that directory full of goodness into your Workspace.  An excellent developer I know says that Code is all of the documentation you need.  Which means that it is nice to be able to browse the code in a good editor.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-32-09-am/" rel="attachment wp-att-7056"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM-1024x776.png" alt="" width="1024" height="776" class="alignnone size-large wp-image-7056" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM-1024x776.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM-600x455.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM-300x227.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM-768x582.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.32.09-AM.png 1452w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Explore the Code Examples</h1>
<p>Now you should have the folder &#8220;Code-Examples-BT-20819A1-1.0-for-ModusToolbox&#8221; inside of your Workspace.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-34-42-am/" rel="attachment wp-att-7057"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM-611x1024.png" alt="" width="611" height="1024" class="alignnone size-large wp-image-7057" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM-611x1024.png 611w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM-600x1006.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM-179x300.png 179w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM-768x1287.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.34.42-AM.png 778w" sizes="auto, (max-width: 611px) 100vw, 611px" /></a></p>
<p>If you double click the &#8220;BT-SDK-1.2-Code-Examples.pdf&#8221; you will get a description of them all</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-36-11-am/" rel="attachment wp-att-7058"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM-855x1024.png" alt="" width="855" height="1024" class="alignnone size-large wp-image-7058" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM-855x1024.png 855w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM-600x718.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM-251x300.png 251w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM-768x919.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.36.11-AM.png 1858w" sizes="auto, (max-width: 855px) 100vw, 855px" /></a></p>
<p>You can walk through them using the Workspace Explorer.  Notice that we created examples for many of the Bluetooth Mesh Models.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-09-30-am/" rel="attachment wp-att-7070"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.09.30-AM-429x1024.png" alt="" width="429" height="1024" class="alignnone size-large wp-image-7070" /></a></p>
<h1>Example Peer Apps</h1>
<p>We had a problem with Peer Apps in the SDK1.2 release and this was fixed by adding the Peer Apps to the Example Projects.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-28-at-5-28-54-pm/" rel="attachment wp-att-7249"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM-1024x560.png" alt="" width="1024" height="560" class="alignnone size-large wp-image-7249" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM-1024x560.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM-600x328.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM-300x164.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM-768x420.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-28-at-5.28.54-PM.png 1602w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>How to use a Code Example</h1>
<p>To create a project from one of the code examples, start by choosing &#8220;File-&gt;New-&gt;ModusToolbox IDE Application&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-40-28-am/" rel="attachment wp-att-7060"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM-1024x147.png" alt="" width="1024" height="147" class="alignnone size-large wp-image-7060" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM-1024x147.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM-600x86.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM-300x43.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM-768x110.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.28-AM.png 1672w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Pick the correct development kit &#8220;CYBT-213043-MESH&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-40-45-am/" rel="attachment wp-att-7061"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM-1024x555.png" alt="" width="1024" height="555" class="alignnone size-large wp-image-7061" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM-1024x555.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM-600x325.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM-300x163.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM-768x416.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.40.45-AM.png 1816w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Select &#8220;Import&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-41-06-am/" rel="attachment wp-att-7062"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.06-AM.png" alt="" width="506" height="694" class="alignnone size-large wp-image-7062" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.06-AM.png 506w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.06-AM-219x300.png 219w" sizes="auto, (max-width: 506px) 100vw, 506px" /></a></p>
<p>Navigate to the file &#8220;modus.mk&#8221; of the example you want.  This will be in the directory on your computer where you cloned the GitHub repository.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-41-47-am/" rel="attachment wp-att-7063"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM-1024x478.png" alt="" width="1024" height="478" class="alignnone size-large wp-image-7063" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM-1024x478.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM-600x280.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM-300x140.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM-768x358.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.41.47-AM.png 1556w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After doing the Import you will have that example as a Starter Application.  Notice that they have an asterisks beside the name.  Type the name of your application if you want to change it.  In this case I pick &#8220;VTW_Mesh_SensorMotion&#8221;.  Then press &#8220;Next-&gt;&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-45-35-am/" rel="attachment wp-att-7064"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM-1024x553.png" alt="" width="1024" height="553" class="alignnone size-large wp-image-7064" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM-1024x553.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM-600x324.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM-300x162.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM-768x414.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.35-AM.png 1816w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Click &#8220;Finish&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-45-43-am/" rel="attachment wp-att-7065"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM-1024x553.png" alt="" width="1024" height="553" class="alignnone size-large wp-image-7065" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM-1024x553.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM-600x324.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM-300x162.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM-768x414.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.45.43-AM.png 1816w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now you will have the application in the Workspace.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-48-02-am/" rel="attachment wp-att-7066"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM-673x1024.png" alt="" width="673" height="1024" class="alignnone size-large wp-image-7066" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM-673x1024.png 673w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM-600x912.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM-197x300.png 197w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM-768x1168.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.02-AM.png 780w" sizes="auto, (max-width: 673px) 100vw, 673px" /></a></p>
<p>You can now press &#8220;VTW_Mesh_SensorMotion Build + Program&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-10-48-44-am/" rel="attachment wp-att-7067"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.44-AM.png" alt="" width="774" height="498" class="alignnone size-full wp-image-7067" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.44-AM.png 774w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.44-AM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.44-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-10.48.44-AM-768x494.png 768w" sizes="auto, (max-width: 774px) 100vw, 774px" /></a></p>
<p>And you will end up with this in your console after sweet Success!!!</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-03-07-am/" rel="attachment wp-att-7068"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM-1024x301.png" alt="" width="1024" height="301" class="alignnone size-large wp-image-7068" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM-1024x301.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM-600x176.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM-300x88.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM-768x226.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.03.07-AM.png 1632w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Provision the Motion Sensor into the Network</h1>
<p>I now have a board programmed with the Motion Sensor Application.  Seems like that it will be a good idea to provision it into the network and see if it is doing anything.  Press &#8220;Scan Unprovisioned&#8221;.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-25-21-am/" rel="attachment wp-att-7074"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM-1024x660.png" alt="" width="1024" height="660" class="alignnone size-large wp-image-7074" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.25.21-AM.png 1966w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Once I see my device, I&#8217;ll stop scanning and then press &#8220;Provision and configure&#8221;.  After a minute our tool will tell you that it is done!</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-26-07-am/" rel="attachment wp-att-7076"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM-1024x659.png" alt="" width="1024" height="659" class="alignnone size-large wp-image-7076" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM-1024x659.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM-768x494.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.26.07-AM.png 1964w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Test the Motion Sensor</h1>
<p>You can request the state of the sensor by clicking &#8220;Control&#8221; and then picking the motion sensor.  Now press the &#8220;Get&#8221; button for the sensor and you will see that the sensor is graced with my presence.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-14-36-am/" rel="attachment wp-att-7073"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM-1024x309.png" alt="" width="1024" height="309" class="alignnone size-large wp-image-7073" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM-1024x309.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM-600x181.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM-300x91.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM-768x232.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.14.36-AM.png 1968w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Each time I click &#8220;Get&#8221; you can see the transaction happening on the development kit.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/screen-shot-2019-05-27-at-11-13-33-am/" rel="attachment wp-att-7072"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM-1024x709.png" alt="" width="1024" height="709" class="alignnone size-large wp-image-7072" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM-1024x709.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM-600x416.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM-300x208.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM-768x532.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-11.13.33-AM.png 1184w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L3 Making a Light Switch Using the Example Code</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:37:48 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6983</guid>

					<description><![CDATA[Summary In the first several lessons I showed you how to build a BLE Mesh Network using the Cypress Android App and the Windows Application.  I don&#8217;t know about you, but even though I live twenty years back in time in Kentucky I still have light switches.  In this lesson Ill show you how to [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>In the first several lessons I showed you how to build a BLE Mesh Network using the Cypress Android App and the Windows Application.  I don&#8217;t know about you, but even though I live twenty years back in time in Kentucky I still have light switches.  In this lesson Ill show you how to add a light switch to your network.  And then we will have a good look a the code because we have run enough demo projects.</p>
<p>Given that I have a working network from the last lesson I will just add the switch to that network.  Meaning, I will use the Mesh Client to provision in the new switch.</p>
<p>For this exercise we will:</p>
<ol>
<li>Create the VTW_MeshOnOffSwitch Project</li>
<li>Provision and Configure the Switch</li>
<li>Firmware Architecture</li>
<li>Examine the Code</li>
</ol>
<h1>Create the VTW_MeshOnOffSwitch Project</h1>
<p>Start a new project with File&#8211;&gt;New&#8211;&gt;ModusToolbox IDE Application</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-19-47-pm/" rel="attachment wp-att-7153"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM-1024x152.png" alt="" width="1024" height="152" class="alignnone size-large wp-image-7153" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM-1024x152.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM-600x89.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM-300x45.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM-768x114.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.19.47-PM.png 1684w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Pick out the CYBT-213043-MESH hardware.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-20-01-pm/" rel="attachment wp-att-7154"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM-1024x565.png" alt="" width="1024" height="565" class="alignnone size-large wp-image-7154" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM-1024x565.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM-600x331.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM-300x165.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM-768x424.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.01-PM.png 1980w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>I will use the BLE_Mesh_OnOffSwitch starter application.  Notice that I named it &#8220;VTW_Mesh_OnOffSwitch&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-20-26-pm/" rel="attachment wp-att-7155"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM-1024x568.png" alt="" width="1024" height="568" class="alignnone size-large wp-image-7155" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM-1024x568.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM-600x333.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM-300x166.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM-768x426.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.26-PM.png 1962w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now press Finish to create the application in your workspace.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-20-35-pm/" rel="attachment wp-att-7156"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM-1024x564.png" alt="" width="1024" height="564" class="alignnone size-large wp-image-7156" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM-1024x564.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM-600x330.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM-300x165.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM-768x423.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.35-PM.png 1980w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now your Project Explorer should look like this.  Notice that in the quick panel there are the launches for this application.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-20-57-pm/" rel="attachment wp-att-7157"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.57-PM-467x1024.png" alt="" width="467" height="1024" class="alignnone size-large wp-image-7157" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.57-PM-467x1024.png 467w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.57-PM-600x1315.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.57-PM-137x300.png 137w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.20.57-PM.png 764w" sizes="auto, (max-width: 467px) 100vw, 467px" /></a></p>
<p>So, press &#8220;VTW_MeshOnOffSwitch Build + Program&#8221;</p>
<h1>Provision and Configure the Switch</h1>
<p>Go back to the Mesh Client application.  Just as before you can add the Switch to the network by scanning for unprovisioned BLE Mesh Nodes.  When the node shows up, give it a name of SW1 and then press &#8220;Provision and configure&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-22-59-pm/" rel="attachment wp-att-7158"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM-1024x664.png" alt="" width="1024" height="664" class="alignnone size-large wp-image-7158" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM-1024x664.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM-600x389.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM-768x498.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.22.59-PM.png 1972w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After a while, your trace window will indicate success via the ever informative &#8220;done&#8221; message.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-23-38-pm/" rel="attachment wp-att-7159"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM-1024x139.png" alt="" width="1024" height="139" class="alignnone size-large wp-image-7159" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM-1024x139.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM-600x81.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM-300x41.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM-768x104.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.38-PM.png 1782w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>If you have a serial terminal attached to the development kit you will see what happens during the provision/configuration process.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-23-56-pm/" rel="attachment wp-att-7160"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM-1024x677.png" alt="" width="1024" height="677" class="alignnone size-large wp-image-7160" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM-1024x677.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM-600x396.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM-300x198.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM-768x507.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.23.56-PM.png 1574w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now test the button on your new Light Switch and notice that both LEDs turn on (both Dimmable and L2).  You can configure the Switch to control only L2 if you want.  On the &#8220;Use Device&#8221; drop down pick &#8220;SW1 (0004)&#8221; then select control &#8220;ONOFF&#8221; and pick the switch &#8220;L2&#8221;.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/screen-shot-2019-05-27-at-3-24-18-pm/" rel="attachment wp-att-7161"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM-1024x658.png" alt="" width="1024" height="658" class="alignnone size-large wp-image-7161" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM-1024x658.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM-600x385.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM-768x493.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-3.24.18-PM.png 1974w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After applying the change you can see that switch only controls L2.  You can then switch it to &#8220;Dimmable&#8221; to control the other LED.</p>
<h1>Firmware Architecture</h1>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/firmware-arch/" rel="attachment wp-att-7221"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/firmware-arch.png" alt="" width="575" height="404" class="alignnone size-full wp-image-7221" srcset="https://iotexpert.com/wp-content/uploads/2019/05/firmware-arch.png 575w, https://iotexpert.com/wp-content/uploads/2019/05/firmware-arch-300x211.png 300w" sizes="auto, (max-width: 575px) 100vw, 575px" /></a></p>
<h1>Examine the Code</h1>
<p>A Cypress Bluetooth Mesh project has several basic sections  Specifically you must configure:</p>
<ol>
<li>Elements &amp; Models</li>
<li>Mesh Config</li>
<li>Application Function Pointers</li>
<li>mesh_app_init</li>
</ol>
<p>Plus for the switch application, you will need to configure the button management code (what happens when the button is pushed).</p>
<ol></ol>
<h1>Elements and Models</h1>
<p>The &#8220;Element&#8221; is a fundamental unit of thingness in a BLE Mesh.  For instance in the projects we have looked at, the LEDs are represented by an Element, and the switch is represented by another element.  Each element will have one or more models that represent the functionality of the element.  For instance, in a switch you will have a &#8220;WICED_BT_MESH_MODEL_ONOFF_CLIENT&#8221;.   If you look at on_off_switch.c you will see that we first define an array of models.  Then we define an array of elements.  The array mesh_element1_models will be associated with the the first element.</p>
<pre class="start-line:111 EnlighterJSRAW" data-enlighter-language="c"">wiced_bt_mesh_core_config_model_t   mesh_element1_models[] =
{
    WICED_BT_MESH_DEVICE,
    WICED_BT_MESH_MODEL_ONOFF_CLIENT,
};
#define MESH_APP_NUM_MODELS  (sizeof(mesh_element1_models) / sizeof(wiced_bt_mesh_core_config_model_t))

#define ONOFF_SWITCH_ELEMENT_INDEX   0

wiced_bt_mesh_core_config_element_t mesh_elements[] =
{
    {
        .location = MESH_ELEM_LOC_MAIN,                                 // location description as defined in the GATT Bluetooth Namespace Descriptors section of the Bluetooth SIG Assigned Numbers
        .default_transition_time = MESH_DEFAULT_TRANSITION_TIME_IN_MS,  // Default transition time for models of the element in milliseconds
        .onpowerup_state = WICED_BT_MESH_ON_POWER_UP_STATE_RESTORE,     // Default element behavior on power up
        .default_level = 0,                                             // Default value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_min = 1,                                                 // Minimum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .range_max = 0xffff,                                            // Maximum value of the variable controlled on this element (for example power, lightness, temperature, hue...)
        .move_rollover = 0,                                             // If true when level gets to range_max during move operation, it switches to min, otherwise move stops.
        .properties_num = 0,                                            // Number of properties in the array models
        .properties = NULL,                                             // Array of properties in the element.
        .sensors_num = 0,                                               // Number of sensors in the sensor array
        .sensors = NULL,                                                // Array of sensors of that element
        .models_num = MESH_APP_NUM_MODELS,                              // Number of models in the array models
        .models = mesh_element1_models,                                 // Array of models located in that element. Model data is defined by structure wiced_bt_mesh_core_config_model_t
    },
};
</pre>
<h1>Mesh Config</h1>
<p>The mesh config structure handles the basic setup for the Cypress Bluetooth Mesh.  This structure is loaded in by the stack when it starts.</p>
<pre class="start-line:139 EnlighterJSRAW" data-enlighter-language="c" ">wiced_bt_mesh_core_config_t  mesh_config =
{
    .company_id         = MESH_COMPANY_ID_CYPRESS,                  // Company identifier assigned by the Bluetooth SIG
    .product_id         = MESH_PID,                                 // Vendor-assigned product identifier
    .vendor_id          = MESH_VID,                                 // Vendor-assigned product version identifier
    .firmware_id        = MESH_FWID,                                // Vendor-assigned firmware version identifier
    .replay_cache_size  = MESH_CACHE_REPLAY_SIZE,                   // Number of replay protection entries, i.e. maximum number of mesh devices that can send application messages to this device.
#if defined(LOW_POWER_NODE) &amp;&amp; (LOW_POWER_NODE == 1)
    .features           = WICED_BT_MESH_CORE_FEATURE_BIT_LOW_POWER, // A bit field indicating the device features. In Low Power mode no Relay, no Proxy and no Friend
    .friend_cfg         =                                           // Empty Configuration of the Friend Feature
    {
        .receive_window = 0,                                        // Receive Window value in milliseconds supported by the Friend node.
        .cache_buf_len  = 0,                                        // Length of the buffer for the cache
        .max_lpn_num    = 0                                         // Max number of Low Power Nodes with established friendship. Must be &gt; 0 if Friend feature is supported. 
    },
    .low_power          =                                           // Configuration of the Low Power Feature
    {
        .rssi_factor           = 2,                                 // contribution of the RSSI measured by the Friend node used in Friend Offer Delay calculations.
        .receive_window_factor = 2,                                 // contribution of the supported Receive Window used in Friend Offer Delay calculations.
        .min_cache_size_log    = 3,                                 // minimum number of messages that the Friend node can store in its Friend Cache.
        .receive_delay         = 100,                               // Receive delay in 1ms units to be requested by the Low Power node.
        .poll_timeout          = 36000                              // Poll timeout in 100ms units to be requested by the Low Power node.
    },
#else
    .features           = 0,                                        // no, support for proxy, friend, or relay
    .friend_cfg         =                                           // Empty Configuration of the Friend Feature
    {
        .receive_window        = 0,                                 // Receive Window value in milliseconds supported by the Friend node.
        .cache_buf_len         = 0,                                 // Length of the buffer for the cache
        .max_lpn_num           = 0                                  // Max number of Low Power Nodes with established friendship. Must be &gt; 0 if Friend feature is supported. 
    },
    .low_power          =                                           // Configuration of the Low Power Feature
    {
        .rssi_factor           = 0,                                 // contribution of the RSSI measured by the Friend node used in Friend Offer Delay calculations.
        .receive_window_factor = 0,                                 // contribution of the supported Receive Window used in Friend Offer Delay calculations.
        .min_cache_size_log    = 0,                                 // minimum number of messages that the Friend node can store in its Friend Cache.
        .receive_delay         = 0,                                 // Receive delay in 1 ms units to be requested by the Low Power node.
        .poll_timeout          = 0                                  // Poll timeout in 100ms units to be requested by the Low Power node.
    },
#endif
    .gatt_client_only          = WICED_FALSE,                       // Can connect to mesh over GATT or ADV
    .elements_num  = (uint8_t)(sizeof(mesh_elements) / sizeof(mesh_elements[0])),   // number of elements on this device
    .elements      = mesh_elements                                  // Array of elements for this device
};
</pre>
<h1>Application Function Pointers</h1>
<p>The Bluetooth Mesh stack interacts with your program via functions that it runs when something is happening.  You can either accept the default behavior, or you can write your own function.</p>
<pre class="start-line:184 EnlighterJSRAW" data-enlighter-language="c" ">/*
 * Mesh application library will call into application functions if provided by the application.
 */
wiced_bt_mesh_app_func_table_t wiced_bt_mesh_app_func_table =
{
    mesh_app_init,          // application initialization
    mesh_app_hardware_init, // hardware initialization
    NULL,                   // GATT connection status
    NULL,                   // attention processing
    NULL,                   // notify period set
    NULL,                   // WICED HCI command
    NULL,                   // LPN sleep
    NULL                    // factory reset
};</pre>
<h1>mesh_app_init</h1>
<p>The function mesh_app_init is called by the stack when the stack starts.  It is your opportunity to get things going.   In the &#8220;if&#8221; we setup information which makes it easier to see what is happening when you provision by adding that information to the scan response packet.</p>
<p>The last thing we do in mesh_app_init function is initialize the onoff client model. This should be done for any models that your device uses. The model initialization functions can accept the name of a function that we want the stack to call when it receives messages from the network for that model. In this case, we don&#8217;t need to do anything in our firmware for onoff client messages, so we specify NULL.</p>
<pre class="start-line:202 EnlighterJSRAW" data-enlighter-language="c"">/******************************************************
 *               Function Definitions
 ******************************************************/
void mesh_app_init(wiced_bool_t is_provisioned)
{
#if 0
    extern uint8_t wiced_bt_mesh_model_trace_enabled;
    wiced_bt_mesh_model_trace_enabled = WICED_TRUE;
#endif
    wiced_bt_cfg_settings.device_name = (uint8_t *)"Switch";
    wiced_bt_cfg_settings.gatt_cfg.appearance = APPEARANCE_CONTROL_DEVICE_SLIDER;

#if defined(LOW_POWER_NODE) &amp;&amp; (LOW_POWER_NODE == 1)
    WICED_BT_TRACE("LPN Switch init provisioned:%d\n", is_provisioned);
#else
    WICED_BT_TRACE("Switch init provisioned:%d\n", is_provisioned);
#endif

    // Adv Data is fixed. Spec allows to put URI, Name, Appearance and Tx Power in the Scan Response Data.
    if (!is_provisioned)
    {
        wiced_bt_ble_advert_elem_t  adv_elem[3];
        uint8_t                     buf[2];
        uint8_t                     num_elem = 0;

        adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_NAME_COMPLETE;
        adv_elem[num_elem].len         = (uint16_t)strlen((const char*)wiced_bt_cfg_settings.device_name);
        adv_elem[num_elem].p_data      = wiced_bt_cfg_settings.device_name;
        num_elem++;

        adv_elem[num_elem].advert_type = BTM_BLE_ADVERT_TYPE_APPEARANCE;
        adv_elem[num_elem].len         = 2;
        buf[0]                         = (uint8_t)wiced_bt_cfg_settings.gatt_cfg.appearance;
        buf[1]                         = (uint8_t)(wiced_bt_cfg_settings.gatt_cfg.appearance &gt;&gt; 8);
        adv_elem[num_elem].p_data      = buf;
        num_elem++;

        wiced_bt_mesh_set_raw_scan_response_data(num_elem, adv_elem);
    }

    // This application does not check result of the transmission or status event from the
    // target device.  Initialize OnOff client library not registering the callback.
    wiced_bt_mesh_model_onoff_client_init(ONOFF_SWITCH_ELEMENT_INDEX, NULL, is_provisioned);
}
</pre>
<h1>Button Management Code</h1>
<p>Now you just need to setup the button hardware in the mesh_app_hardware_init function to generate an interrupt when the button is pressed or released..</p>
<pre class="start-line:247 EnlighterJSRAW" data-enlighter-language="c"">void mesh_app_hardware_init(void)
{
    /* Configure buttons available on the platform */
#if defined(CYW20706A2)
    wiced_hal_gpio_configure_pin(WICED_GPIO_BUTTON, WICED_GPIO_BUTTON_SETTINGS(GPIO_EN_INT_BOTH_EDGE), WICED_GPIO_BUTTON_DEFAULT_STATE);
    wiced_hal_gpio_register_pin_for_interrupt(WICED_GPIO_BUTTON, button_interrupt_handler, NULL);
#elif (defined(CYW20735B0) || defined(CYW20719B0) || defined(CYW20721B0))
    wiced_hal_gpio_register_pin_for_interrupt(WICED_GPIO_PIN_BUTTON, button_interrupt_handler, NULL);
    wiced_hal_gpio_configure_pin(WICED_GPIO_PIN_BUTTON, WICED_GPIO_BUTTON_SETTINGS, GPIO_PIN_OUTPUT_LOW);
#else
    wiced_platform_register_button_callback(WICED_PLATFORM_BUTTON_1, button_interrupt_handler, NULL, GPIO_EN_INT_BOTH_EDGE);
    button_previous_value = platform_button[WICED_PLATFORM_BUTTON_1].default_state;
#endif
}</pre>
<p>The interrupt handler will call the function wiced_bt_mesh_model_onoff_client_set to publish the button pressed message.</p>
<pre class="start-line:262 EnlighterJSRAW" data-enlighter-language="c"">/*
 * Process interrupts from the button.
 */
void button_interrupt_handler(void* user_data, uint8_t pin)
{
    uint32_t value = wiced_hal_gpio_get_pin_input_status(pin);
    uint32_t current_time = wiced_bt_mesh_core_get_tick_count();
    uint32_t button_pushed_duration;

    if (value == button_previous_value)
    {
        WICED_BT_TRACE("interrupt_handler: duplicate pin:%d value:%d current_time:%d\n", pin, value, current_time);
        return;
    }
    button_previous_value = value;

    WICED_BT_TRACE("interrupt_handler: pin:%d value:%d current_time:%d\n", pin, value, current_time);

    if (value == platform_button[WICED_PLATFORM_BUTTON_1].button_pressed_value)
    {
        button_pushed_time = current_time;
        return;
    }
    // button is released
    button_pushed_duration = current_time - button_pushed_time;
    if (button_pushed_duration &lt; 15000)
    {
        process_button_push(ONOFF_SWITCH_ELEMENT_INDEX);
    }
    else
    {
        // More than 15 seconds means factory reset
        mesh_application_factory_reset();
    }
}

void process_button_push(uint8_t element_idx)
{
    static uint8_t onoff = 0;
    wiced_bt_mesh_onoff_set_data_t set_data;

    onoff ^= 1;

    set_data.onoff           = onoff;
    set_data.transition_time = WICED_BT_MESH_TRANSITION_TIME_DEFAULT;
    set_data.delay           = 0;

    wiced_bt_mesh_model_onoff_client_set(element_idx, &amp;set_data);
}
</pre>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L2B Building a Mesh Network Using the Mesh Client</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:37:26 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=7122</guid>

					<description><![CDATA[Summary In this lesson I will show you how to use the Windows Application called &#8220;Mesh Client&#8221; to control your Bluetooth Mesh network.  The Mesh Client program attaches to the Bluetooth adaptor in your computer and lets you control Bluetooth Mesh networks (genius of a marketing name).  This includes provisioning, configuring, operation, etc.  This lesson [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>In this lesson I will show you how to use the Windows Application called &#8220;Mesh Client&#8221; to control your Bluetooth Mesh network.  The Mesh Client program attaches to the Bluetooth adaptor in your computer and lets you control Bluetooth Mesh networks (genius of a marketing name).  This includes provisioning, configuring, operation, etc.  This lesson will mirror the previous one in that I will setup two dimmable lights but this time I will control them via PC based software instead of the Android app.</p>
<p>For this exercise I will take you through the following steps:</p>
<ol>
<li>Reset the Two Kits by Reprogramming</li>
<li>Run the Mesh Client</li>
<li>Create a New Bluetooth Mesh Network</li>
<li>Provision your L1 Dimmable Light to the Network</li>
<li>Control the L1 Dimmable Light</li>
<li>Add the other Dimmable Light to the Network &amp; Test</li>
</ol>
<h1>Reset the Two Kits by Reprogramming</h1>
<p>Click on the &#8220;VTW_Mesh_LightDimmable&#8221; project.  Then select &#8220;VTW_Mesh_LightDimmable Build + Program&#8221;.  Do this to both of your boards so that we can start fresh.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-57-24-pm/" rel="attachment wp-att-7141"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM-514x1024.png" alt="" width="514" height="1024" class="alignnone size-large wp-image-7141" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM-514x1024.png 514w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM-600x1195.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM-151x300.png 151w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM-768x1530.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.57.24-PM.png 780w" sizes="auto, (max-width: 514px) 100vw, 514px" /></a></p>
<h1>Run the Mesh Client</h1>
<p>The Mesh Client application can be found in your ModusToolbox installation directory.  Here is the path:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-47-45-pm/" rel="attachment wp-att-7140"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM-1024x32.png" alt="" width="1024" height="32" class="alignnone size-large wp-image-7140" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM-1024x32.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM-600x18.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM-300x9.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM-768x24.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.47.45-PM.png 1882w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p><strong>Edit: There is a bug in this release.  You need to get the MeshClient from the code example &#8230; Lesson 4</strong></p>
<p>When you run the Mesh Client it will look like this:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-22-48-pm/" rel="attachment wp-att-7125"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM-1024x658.png" alt="" width="1024" height="658" class="alignnone size-large wp-image-7125" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM-1024x658.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM-768x494.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.22.48-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Create a New Network</h1>
<p>Before it will do anything, you need to create a new network by giving it a name such as &#8220;Net2&#8221; and pressing &#8220;Create&#8221;.  This will populate all of the configuration files required to control the network.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-23-02-pm/" rel="attachment wp-att-7126"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM-1024x664.png" alt="" width="1024" height="664" class="alignnone size-large wp-image-7126" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM-1024x664.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM-600x389.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM-300x195.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM-768x498.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.02-PM.png 1974w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After the network is created, press the &#8220;Open&#8221; button.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-23-15-pm/" rel="attachment wp-att-7127"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM-1024x656.png" alt="" width="1024" height="656" class="alignnone size-large wp-image-7127" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM-1024x656.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM-600x385.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM-300x192.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM-768x492.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.15-PM.png 1978w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After the network configuration files load you will see a trace window like this:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-23-25-pm/" rel="attachment wp-att-7128"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM-1024x136.png" alt="" width="1024" height="136" class="alignnone size-large wp-image-7128" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM-1024x136.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM-600x80.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM-300x40.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM-768x102.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.25-PM.png 1972w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Provision your L1 Dimmable Light to the Network</h1>
<p>Now you have a network with no nodes.  Press &#8220;Scan Unprovisioned&#8221; to find an unprovisioned device, which are just BLE devices that are advertising as mesh beacons.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-23-34-pm/" rel="attachment wp-att-7129"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM-1024x661.png" alt="" width="1024" height="661" class="alignnone size-large wp-image-7129" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM-1024x661.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM-768x496.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.23.34-PM.png 1974w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>After a bit, the scanner will find your &#8220;Dimmable Light&#8221;. You will see the device show up in &#8220;Provision UUID&#8221; with a name.   You can click Stop Scanning so that it doesn&#8217;t keep searching for other devices. Right here, I would recommend you change the device name.  Unfortunately I forgot when I captured these screens.  Oh well.  I hope when I do this live I won&#8217;t forget.  Now press &#8220;Provision and configure&#8221;.  After a some time that process will complete.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-24-03-pm/" rel="attachment wp-att-7130"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM-1024x659.png" alt="" width="1024" height="659" class="alignnone size-large wp-image-7130" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM-1024x659.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM-768x494.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.03-PM.png 1978w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>While the provision and configuration process is going on you will see the console of the Dimmable light reacting.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-24-17-pm/" rel="attachment wp-att-7131"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM-1024x396.png" alt="" width="1024" height="396" class="alignnone size-large wp-image-7131" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM-1024x396.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM-600x232.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM-300x116.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM-768x297.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.24.17-PM.png 1592w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Control the L1 Dimmable Light</h1>
<p>Now that you have a provisioned node you can use the Mesh Client to control it.  Start by selecting which Node to control in the drop down dialog box.  In this case I chose &#8220;Dimmable light&#8221; which makes sense as it is the only device in my network.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-26-02-pm/" rel="attachment wp-att-7133"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM-1024x655.png" alt="" width="1024" height="655" class="alignnone size-large wp-image-7133" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM-1024x655.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM-600x384.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM-300x192.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM-768x491.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.02-PM.png 1986w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now select &#8220;On&#8221; and &#8220;Set&#8221; which will turn on the LED.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-26-14-pm/" rel="attachment wp-att-7134"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM-1024x660.png" alt="" width="1024" height="660" class="alignnone size-large wp-image-7134" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.26.14-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Add the other Dimmable Light to the Network &amp; Test</h1>
<p>Unplug the Dimmable Light and plug it into something other than your computer.  Plug in the other unprovisioned board.  Back in the Mesh Client application press &#8220;Scan Unprovisioned&#8221;  When it comes back having found the new board,  give it a name &#8220;L2&#8221; and then press &#8220;Provision and configure&#8221;.  When I do this live during the workshop I will name the first board &#8220;L1&#8221; and the second &#8220;L2&#8221;.  But I&#8217;m not going to recapture these screen shots.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-34-25-pm/" rel="attachment wp-att-7135"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM-1024x664.png" alt="" width="1024" height="664" class="alignnone size-large wp-image-7135" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM-1024x664.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM-600x389.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM-300x195.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM-768x498.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.34.25-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Once L2 is provisioned into the network.  I can control it the same way I did with &#8220;L1&#8221;.  Select &#8220;L2&#8221; (and notice that I called the first light &#8220;Dimmable Light&#8221; rather than giving it a sensible name.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-37-45-pm/" rel="attachment wp-att-7136"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM-1024x660.png" alt="" width="1024" height="660" class="alignnone size-large wp-image-7136" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM-1024x660.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM-600x387.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM-768x495.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.45-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now select &#8220;On&#8221; and then press &#8220;Set&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-37-58-pm/" rel="attachment wp-att-7137"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM-1024x662.png" alt="" width="1024" height="662" class="alignnone size-large wp-image-7137" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM-1024x662.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM-600x388.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM-300x194.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM-768x497.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.37.58-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Finally, test and make sure that the first Dimmable Light is still working by turning it off:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/screen-shot-2019-05-27-at-1-39-40-pm/" rel="attachment wp-att-7138"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM-1024x659.png" alt="" width="1024" height="659" class="alignnone size-large wp-image-7138" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM-1024x659.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM-600x386.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM-300x193.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM-768x494.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-1.39.40-PM.png 1976w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L2A Using the CYBT-213043-MESH &#038; Building a Mesh Network Using the Mesh Lighting App</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Wed, 29 May 2019 11:37:16 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6981</guid>

					<description><![CDATA[Summary In this lesson I will walk you through the process of creating your first Bluetooth Mesh Network.  It will be a simple network with two Dimmable Light nodes which we will control using an Android Application called Mesh Lighting. In this exercise I will: Show you the CYBT-213043-MESH development kit Create a Dimmable Light [&#8230;]]]></description>
										<content:encoded><![CDATA[<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<h1>Summary</h1>
<p>In this lesson I will walk you through the process of creating your first Bluetooth Mesh Network.  It will be a simple network with two Dimmable Light nodes which we will control using an Android Application called Mesh Lighting.</p>
<p>In this exercise I will:</p>
<ol>
<li>Show you the CYBT-213043-MESH development kit</li>
<li>Create a Dimmable Light Bulb Project and Program (two boards)</li>
<li>Create a Mesh Network using MeshLighting Android Application</li>
<li>Add another Dimmable Light to the Mesh</li>
<li>Create Groups (a.k.a. Rooms)</li>
</ol>
<h1>CYBT-213043-MESH</h1>
<p>Here is a picture of one of the development boards.  It has</p>
<ul>
<li>A CYBT-213043-02 module with a PCB antenna.  The module contains a CYW20819</li>
<li>A two channel UART to USB device used for programming and debug printing</li>
<li>Three buttons (Reset, Recover and User)</li>
<li>An Ambient Light Sensor</li>
<li>An RGB LED</li>
<li>A thermistor</li>
<li>A PIR motion sensor</li>
</ul>
<p><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0533/" rel="attachment wp-att-6959"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-1024x504.jpg" alt="" width="1024" height="504" class="alignnone size-large wp-image-6959" srcset="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-1024x504.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-600x295.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-300x148.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-768x378.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Create a Dimmable Light Bulb Project and Program (two boards)</h1>
<p>Start this process by programming two of the boards with the Dimmable Light firmware.  To create this firmware start with File&#8211;&gt;New&#8211;&gt;Modustoolbox IDE Application</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-04-18-pm/" rel="attachment wp-att-7083"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM-1024x149.png" alt="" width="1024" height="149" class="alignnone size-large wp-image-7083" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM-1024x149.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM-600x87.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM-300x44.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM-768x112.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.18-PM.png 1634w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Choose the CY214043-MESH development kit</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-04-29-pm/" rel="attachment wp-att-7084"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.29-PM-1024x348.png" alt="" width="1024" height="348" class="alignnone size-large wp-image-7084" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.29-PM-1024x348.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.29-PM-600x204.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.29-PM-300x102.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.04.29-PM-768x261.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Then pick &#8220;BLE_Mesh_LightDimmable&#8221; and give it a name &#8220;VTW_Mesh_LightDimmable&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-00-32-pm/" rel="attachment wp-att-7080"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.32-PM-1024x348.png" alt="" width="1024" height="348" class="alignnone size-large wp-image-7080" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.32-PM-1024x348.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.32-PM-600x204.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.32-PM-300x102.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.32-PM-768x261.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Now press finish to make the project.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-00-42-pm/" rel="attachment wp-att-7081"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.42-PM-1024x347.png" alt="" width="1024" height="347" class="alignnone size-large wp-image-7081" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.42-PM-1024x347.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.42-PM-600x203.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.42-PM-300x102.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.00.42-PM-768x260.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Modus Toolbox provides a Launches window on a &#8220;quick panel&#8221; right below the workspace explorer.  Pick &#8220;VTW_Mesh_LightDimmable Build + Program&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-01-11-pm/" rel="attachment wp-att-7082"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.01.11-PM.png" alt="" width="766" height="270" class="alignnone size-large wp-image-7082" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.01.11-PM.png 766w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.01.11-PM-600x211.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.01.11-PM-300x106.png 300w" sizes="auto, (max-width: 766px) 100vw, 766px" /></a></p>
<p>The compiler will run and make an executable.  Then it will program the flash of the CYW20819.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-06-30-pm/" rel="attachment wp-att-7085"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.30-PM-1024x213.png" alt="" width="1024" height="213" class="alignnone size-large wp-image-7085" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.30-PM-1024x213.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.30-PM-600x125.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.30-PM-300x62.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.30-PM-768x160.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>On a Serial Console you should see the Application Bootup (notice that the baud rate is 921600). Remember there are 2 UART channels on each kit &#8211; one primarily used for programming and one used for debug messages. Make sure to connect to the second channel called the peripheral UART or PUART.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-12-06-13-pm/" rel="attachment wp-att-7086"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM-1024x794.png" alt="" width="1024" height="794" class="alignnone size-large wp-image-7086" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM-1024x794.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM-600x465.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM-300x233.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM-768x596.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-12.06.13-PM.png 1346w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Create a Mesh Network using MeshLight Android Application</h1>
<p>We provide the Android Application called &#8220;WICED Mesh Lighting App&#8221; and all of the source code as part of the SDK distribution in Modus Toolbox.  You can find it here:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screen-shot-2019-05-27-at-2-21-32-pm/" rel="attachment wp-att-7144"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM-1024x33.png" alt="" width="1024" height="33" class="alignnone size-large wp-image-7144" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM-1024x33.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM-600x19.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM-300x10.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM-768x25.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-27-at-2.21.32-PM.png 1872w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<p>Start the process on your Android phone by running the &#8220;WICED Mesh Lighting App&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-123708/" rel="attachment wp-att-7104"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7104" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123708.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Once the App starts, your screen should look like this:</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121022/" rel="attachment wp-att-7087"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7087" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121022.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Press the three dots icon and select &#8220;Create Network&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121039/" rel="attachment wp-att-7088"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7088" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121039.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Give it a name.  In this case I chose &#8220;test1&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121101/" rel="attachment wp-att-7089"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7089" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121101.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Click on &#8220;ALL&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121107/" rel="attachment wp-att-7090"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7090" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121107.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Then press &#8220;Add Device&#8221;.  Your screen will search for an Unprovisioned Mesh Device.  When it finds one it will bring up the Name of the device along with the UUID.  I give the device the name &#8220;l1&#8221; and I attach that name to the &#8220;Dimmable Light&#8230;.&#8221;.  After you get that done press OK.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121133/" rel="attachment wp-att-7091"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7091" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121133.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>After you press OK the App will provision and configure your Dimmable Light.  After that is done, your screen will look like this.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121155/" rel="attachment wp-att-7092"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7092" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121155.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>The green bar along the bottom of the screen indicates that your phone is connected to the network &#8211; if it is red, you can click on &#8220;Connect to Network&#8221;. You can now control the LED using the little switch icon on the right.  In this picture I have the L1 turned on.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-121254/" rel="attachment wp-att-7093"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7093" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-121254.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<h1>Add another Dimmable Light to the Mesh</h1>
<p>One Dimmable Light, this is not much of a mesh.  To fix that I program another development kit.  Then I click on all and &#8220;Add Device&#8221;  After a bit you can add the next kit to your network.  Notice I call this one &#8220;l2&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122304/" rel="attachment wp-att-7094"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7094" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122304.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>After the provisioning and configuring your screen will look like this.  Once again you can turn the lights on individually or as a group.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122345/" rel="attachment wp-att-7095"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7095" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122345.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<h1>Create Groups (A.K.A. Rooms)</h1>
<p>It is common for the home automation system to have &#8220;Rooms&#8221;.  In the world of Bluetooth Mesh these are called &#8220;Groups&#8221;  To create a group start on the main screen and click the &#8220;+&#8221; to create a new room</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-123459/" rel="attachment wp-att-7107"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7107" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123459.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>On the New Room screen click the pencil icon.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122418/" rel="attachment wp-att-7097"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7097" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122418.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Then type the name of the room.  In this case &#8220;r1&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-123524/" rel="attachment wp-att-7108"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7108" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-123524.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Now do the same thing to make &#8220;r2&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122445/" rel="attachment wp-att-7098"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7098" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122445.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Back in the &#8220;All Screen&#8221; you can click on the individual Dimmable Lights to move them around.  Start by moving l1 by clicking on it.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-125128/" rel="attachment wp-att-7109"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7109" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125128.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Click on the &#8220;Move to Group&#8221; button.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122506/" rel="attachment wp-att-7099"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7099" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122506.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>And assign l1 to r1</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122512/" rel="attachment wp-att-7100"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7100" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122512.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Go back.  Then click on l2.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122526/" rel="attachment wp-att-7101"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7101" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122526.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>And move it to &#8220;r2&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122532/" rel="attachment wp-att-7102"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7102" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122532.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Now you have this.  Three groups.  ALL, r1, and r2.  You can turn everything in those groups on by pressing the switch.  In the screen capture below I turned on &#8220;r2&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-122604/" rel="attachment wp-att-7103"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7103" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-122604.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>One more interesting thing to do is to add l1 and l2 to the All group.</p>
<p>Start on the main screen and click &#8220;r1&#8221;.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-125716/" rel="attachment wp-att-7110"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7110" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125716.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Then click &#8220;l1&#8221;.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-125722/" rel="attachment wp-att-7117"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722-576x1024.jpg" alt="" width="576" height="1024" class="alignnone size-large wp-image-7117" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722-576x1024.jpg 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722-600x1067.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722-169x300.jpg 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722-768x1365.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125722.jpg 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Press &#8220;Add to other Group&#8221; and select &#8220;ALL&#8221;</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-125802/" rel="attachment wp-att-7113"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7113" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125802.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Go back and press on &#8220;r2&#8221;, select &#8220;l2&#8221; and then press &#8220;l2&#8221; and &#8220;Add to other Group&#8221;.</p>
<p><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/screenshot_20190527-125821/" rel="attachment wp-att-7112"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821-576x1024.png" alt="" width="576" height="1024" class="alignnone size-large wp-image-7112" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821-576x1024.png 576w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821-600x1067.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821-169x300.png 169w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821-768x1365.png 768w, https://iotexpert.com/wp-content/uploads/2019/05/Screenshot_20190527-125821.png 1080w" sizes="auto, (max-width: 576px) 100vw, 576px" /></a></p>
<p>Now you can control the &#8220;All&#8221; group, &#8220;r1&#8221; or &#8220;r2&#8221;.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Mouser Bluetooth Mesh: L0 Introduction</title>
		<link>https://iotexpert.com/mouser-bluetooth-mesh-l0-introduction/</link>
					<comments>https://iotexpert.com/mouser-bluetooth-mesh-l0-introduction/#respond</comments>
		
		<dc:creator><![CDATA[Alan Hawse]]></dc:creator>
		<pubDate>Sat, 25 May 2019 21:31:42 +0000</pubDate>
				<category><![CDATA[CYBT-213043-MESH]]></category>
		<category><![CDATA[CYW20819]]></category>
		<category><![CDATA[Mouser Bluetooth Mesh]]></category>
		<guid isPermaLink="false">https://iotexpert.com/?p=6948</guid>

					<description><![CDATA[Summary Register for my Bluetooth Mesh Virtual Workshop on May, 29 at 11:00AM Eastern Time!! Hello everyone.  This is lesson 0 of a series of 10 lessons about creating Bluetooth Mesh applications for the Cypress EZ Bluetooth Mesh Evaluation Kit CYBT-213043-MESH.  This class is called &#8220;How to Design with Bluetooth Mesh&#8221; because that is exactly [&#8230;]]]></description>
										<content:encoded><![CDATA[<h1>Summary</h1>
<p>Register for my Bluetooth Mesh Virtual Workshop on May, 29 at 11:00AM Eastern Time!!</p>
<p><a href="https://event.on24.com/eventRegistration/EventLobbyServlet?target=reg20.jsp&amp;referrer=https%3A%2F%2Fwww.mouser.com%2F&amp;eventid=1985732&amp;sessionid=1&amp;key=A1612BF534E4CFB2F2221A6B6BD6020D&amp;regTag=&amp;sourcepage=register" target="_blank" rel="noopener noreferrer"><img decoding="async" class="img-responsive" src="https://www.mouser.com/images/marketingid/2019/microsites/147534788/900x200_Q219.png" alt="Block Diagram - Cypress Semiconductor CYBT-213043-MESH Bluetooth Evaluation Kit" title="Block Diagram - Cypress Semiconductor CYBT-213043-MESH Bluetooth Evaluation Kit" /></a></p>
<p>Hello everyone.  This is lesson 0 of a series of 10 lessons about creating Bluetooth Mesh applications for the Cypress EZ Bluetooth Mesh Evaluation Kit CYBT-213043-MESH.  This class is called &#8220;How to Design with Bluetooth Mesh&#8221; because that is exactly what we are going to do &#8211; make some applications.  No powerpoint in sight.</p>
<p>I am going to start by showing you the development kit and demonstrating how to use it.  It is actually 4 development kits, which makes sense because you need multiple boards to make an actual Bluetooth Mesh.  I will show you and Android App called the &#8220;Mesh Lighting&#8221; app which I will use to provision, configure and control the mesh.  My plan is to walk you through a bunch of learning resources about Bluetooth Mesh and teach you the key concepts.  Finally, I&#8217;ll show you some code and teach you how to write your own projects.</p>
<p>I will attempt to go slowly enough for you to follow along, but if I go too fast, don’t worry you should be able to follow along with the instructions on this website.</p>
<p>Todays virtual workshop has this agenda table which will show also show up on every page.  The links will work to take you through the different lessons.</p>
<p><span><h1>How To Design With Bluetooth Mesh</h1>
<p><div class="table-responsive"><table  style="width:95%; "  class="easy-table easy-table-default " border="1">
<thead>
<tr><th >#</th>
<th >Lesson</th>
</tr>
</thead>
<tbody>
<tr><td >0</td>
<td ><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/" target="_blank" rel="noopener">Introduction</a></td>
</tr>

<tr><td >1</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l1-developer-resources/" target="_blank" rel="noopener">Developer Resources</a></td>
</tr>

<tr><td >2a</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2a-using-the-cybt-213043-mesh-building-a-mesh-network-using-the-mesh-lighting-app/" target="_blank" rel="noopener">Using the CYBT-213043-MESH &amp; Building a Mesh Network Using the Mesh Lighting App</a></td>
</tr>

<tr><td >2b</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l2b-building-a-mesh-network-using-the-mesh-client/" target="_blank" rel="noopener">Building a Mesh Network Using the Mesh Client</a></td>
</tr>

<tr><td >3</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l3-making-a-light-switch-using-the-example-code/" target="_blank" rel="noopener">Making a Light Switch Using the Example Code</a></td>
</tr>

<tr><td >4</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l4-integrating-the-modus-toolbox-code-examples/" target="_blank" rel="noopener">Integrating the Modus Toolbox Code Examples</a></td>
</tr>

<tr><td >5</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l5-bluetooth-mesh-fundamentals/" target="_blank" rel="noopener">Bluetooth Mesh Fundamentals</a></td>
</tr>

<tr><td >6</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l6-the-dimmable-light-code/" target="_blank" rel="noopener">The Dimmable Light Code</a></td>
</tr>

<tr><td >7</td>
<td ><a href="https://iotexpert.com/2019/05/29/mouser-bluetooth-mesh-l7-modifying-the-dimmable-light-code-to-add-another-light-element/">Modifying the Dimmable Light Code to Add Another Light Element</a></td>
</tr>
</tbody></table></div><br />You can "git" a workspace will all of these files at https://github.com/iotexpert/MouserVTWBluetoothMesh or git@github.com:iotexpert/MouserVTWBluetoothMesh.git</p></span></p>
<p>You will need a few things for this class:</p>
<ul>
<li><a href="https://www.mouser.com/new/cypress-semiconductor/cypress-cybt-213043-mesh-eval-kit/" target="_blank" rel="noopener noreferrer">EZ-BT Mesh Evaluation Kit CYBT-213043-MESH</a></li>
<li><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener noreferrer">Modus Toolbox 1.1</a></li>
<li><a href="https://community.cypress.com/docs/DOC-17416" target="_blank" rel="noopener noreferrer">Bluetooth Mesh SDK 1.2</a></li>
</ul>
<h1>CYBT-213043-MESH</h1>
<p>This &#8220;development kit&#8221; is actually four identical boards (and cables) which will let you build a complete Bluetooth Mesh.  You can purchase the kit from <a href="https://www.mouser.com/new/cypress-semiconductor/cypress-cybt-213043-mesh-eval-kit/" target="_blank" rel="noopener noreferrer">Mouser</a>.</p>
<p><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0532/" rel="attachment wp-att-6958"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-637x1024.jpg" alt="" width="637" height="1024" class="alignnone size-large wp-image-6958" srcset="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-637x1024.jpg 637w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-600x964.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-187x300.jpg 187w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-768x1234.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0532-scaled.jpg 1593w" sizes="auto, (max-width: 637px) 100vw, 637px" /></a> <a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0533/" rel="attachment wp-att-6959"></a></p>
<p><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0533/" rel="attachment wp-att-6959"></a><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0531/" rel="attachment wp-att-6957"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-599x1024.jpg" alt="" width="599" height="1024" class="alignnone size-large wp-image-6957" srcset="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-599x1024.jpg 599w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-600x1026.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-176x300.jpg 176w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-768x1313.jpg 768w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0531-scaled.jpg 1498w" sizes="auto, (max-width: 599px) 100vw, 599px" /></a><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0533/" rel="attachment wp-att-6959"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-1024x504.jpg" alt="" width="1024" height="504" class="alignnone size-large wp-image-6959" srcset="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-1024x504.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-600x295.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-300x148.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0533-768x378.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a> <a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/img_0534/" rel="attachment wp-att-6960"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0534-1024x499.jpg" alt="" width="1024" height="499" class="alignnone size-large wp-image-6960" srcset="https://iotexpert.com/wp-content/uploads/2019/05/IMG_0534-1024x499.jpg 1024w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0534-600x293.jpg 600w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0534-300x146.jpg 300w, https://iotexpert.com/wp-content/uploads/2019/05/IMG_0534-768x375.jpg 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Modus Toolbox 1.1</h1>
<p><a href="https://www.cypress.com/products/modustoolbox-software-environment" target="_blank" rel="noopener noreferrer">Modus Toolbox 1.1</a> is our Eclipse based IDE for developing Bluetooth projects.  You can run this on Windows, Mac and Linux.</p>
<p><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/screen-shot-2019-05-25-at-5-12-33-pm/" rel="attachment wp-att-6961"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.12.33-PM-1024x612.png" alt="" width="1024" height="612" class="alignnone size-large wp-image-6961" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.12.33-PM-1024x612.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.12.33-PM-600x359.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.12.33-PM-300x179.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.12.33-PM-768x459.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
<h1>Bluetooth Mesh SDK 1.2</h1>
<p>Cypress has been working continuously to keep our Bluetooth Mesh SDK up to date with changes in the Bluetooth SIG specifications for Mesh.  Our latest release as of today is <a href="https://community.cypress.com/docs/DOC-17416" target="_blank" rel="noopener noreferrer">Bluetooth SDK 1.2</a> which you will need to have installed.</p>
<p><a href="https://iotexpert.com/2019/05/25/mouser-bluetooth-mesh-l0-introduction/screen-shot-2019-05-25-at-5-14-00-pm/" rel="attachment wp-att-6962"><img loading="lazy" decoding="async" src="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.14.00-PM-1024x775.png" alt="" width="1024" height="775" class="alignnone size-large wp-image-6962" srcset="https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.14.00-PM-1024x775.png 1024w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.14.00-PM-600x454.png 600w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.14.00-PM-300x227.png 300w, https://iotexpert.com/wp-content/uploads/2019/05/Screen-Shot-2019-05-25-at-5.14.00-PM-768x582.png 768w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></a></p>
]]></content:encoded>
					
					<wfw:commentRss>https://iotexpert.com/mouser-bluetooth-mesh-l0-introduction/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
