Mc1233x Kit - HALightingSolution for star network

cancel
Showing results for 
Search instead for 
Did you mean: 

Mc1233x Kit - HALightingSolution for star network

Jump to solution
1,437 Views
minhcuong
Contributor II

Hi,

I have a kit Mc1322x include three module, 1 Mc1322x Network Node and 2 Mc1322x sensor Node

I config Network Node is Coordinator, sensor Node is End Device.

Now I want to make "star network" with functions below

sw1 on sensor Node1 control led1 on Network Node

sw2 on sensor Node1 control led2 on Network Node

sw1 on sensor Node2 control led3 on Network Node

sw2 on sensor Node2 control led4 on Network Node

and

sw1 on Network Node control led1 on sensor Node1

sw2 on Network Node control led2 on sensor Node2

I used HALightingSolution on Codebase 3.0.11

Can anyone guide me?

Labels (3)
1 Solution
983 Views
AngelC
Senior Contributor I

Hello Cuong,

First of all, I would recommend you to download latest BeeKit release in order to use the latest MC1322x BeeStack codebase (3.1.1). Once done that, I would recommend you to use the following application templates:

Network node = HA OnOffLight

Sensor Nodes = HA OnOffSwitch

Running the application without any modifications will let you use SW1 in sensor node (ZED) to control LED1 on Network node (ZC).  I strongly recommend you to first run the demo without any modifications in order to get familiar with the implementation and its source code.

Once done that, you will need to make further modifications (add endpoints, define LEDs to be used with every endpoint, etc) in order to control the more LEDs from sensor nodes. Also, if you would like the sensor nodes to have LEDs to be controlled, then you will need to add the corresponding endpoints in both coordinator and sensor nodes. In brief, you will need:

Network node: 4 OnOffLight endpoints and 2 OnOffSwitch endpoints

Sensor nodes: 1 OnOffLight endpoint and 2 OnOffSwitch endpoints

Fortunately, BeeKit allows you to add several endpoint to an application in a very easy way. Simply right-click in “endpoints” once in the solution explorer (before exporting it to IAR) and select the “add software component” to add the desired endpoints. You will get something like the following figure:

devices_endpoints.JPG

You will need to change the endpoint numbers since all of them will have the number 8 assigned by default. To change it, simply select the desired endpoint and open its simple descriptor. It should look as follows:

endpointnumber.JPG

After exporting it to IAR, you will need to do some other modifications to the source code that will require to first get familiar with the code. You should first implement a way to bind the different endpoints with their corresponding LEDs/Switches and then change the SW actions to send On/Off commands to the specific endpoints.

You should start running the demo and check the source code, besides reading the corresponding documentation included in BeeKit, before getting to that point.  It might not be that difficult but it requires a good understanding of how ZigBee Home Automation applications work and which functions are used to send/receive commands.

Regards,

AngelC

View solution in original post

6 Replies
984 Views
AngelC
Senior Contributor I

Hello Cuong,

First of all, I would recommend you to download latest BeeKit release in order to use the latest MC1322x BeeStack codebase (3.1.1). Once done that, I would recommend you to use the following application templates:

Network node = HA OnOffLight

Sensor Nodes = HA OnOffSwitch

Running the application without any modifications will let you use SW1 in sensor node (ZED) to control LED1 on Network node (ZC).  I strongly recommend you to first run the demo without any modifications in order to get familiar with the implementation and its source code.

Once done that, you will need to make further modifications (add endpoints, define LEDs to be used with every endpoint, etc) in order to control the more LEDs from sensor nodes. Also, if you would like the sensor nodes to have LEDs to be controlled, then you will need to add the corresponding endpoints in both coordinator and sensor nodes. In brief, you will need:

Network node: 4 OnOffLight endpoints and 2 OnOffSwitch endpoints

Sensor nodes: 1 OnOffLight endpoint and 2 OnOffSwitch endpoints

Fortunately, BeeKit allows you to add several endpoint to an application in a very easy way. Simply right-click in “endpoints” once in the solution explorer (before exporting it to IAR) and select the “add software component” to add the desired endpoints. You will get something like the following figure:

devices_endpoints.JPG

You will need to change the endpoint numbers since all of them will have the number 8 assigned by default. To change it, simply select the desired endpoint and open its simple descriptor. It should look as follows:

endpointnumber.JPG

After exporting it to IAR, you will need to do some other modifications to the source code that will require to first get familiar with the code. You should first implement a way to bind the different endpoints with their corresponding LEDs/Switches and then change the SW actions to send On/Off commands to the specific endpoints.

You should start running the demo and check the source code, besides reading the corresponding documentation included in BeeKit, before getting to that point.  It might not be that difficult but it requires a good understanding of how ZigBee Home Automation applications work and which functions are used to send/receive commands.

Regards,

AngelC

983 Views
minhcuong
Contributor II

Dear AngleIC,

Thank you for your answer.

I have running the demo ok.

I have read "3.5 Adding a Second Device Instance"  in "ZigBee Cluster Library Reference Manual" document but it not in detail

pastedImage_0.png

You can guide me add new endpoint (include modifier in each file source code)?

Thanks in advance,

Cuong Minh

0 Kudos
983 Views
AngelC
Senior Contributor I

Hello Cuong,

You could add the endpoints using BeeKit solution explorer as described before and simply modify BeeAppUpdateDevice() function in BeeApp.c file. As the documentation states, endpoint number is ignored in the default template, but you could easily add a check and select the LED to turn ON/OFF based in the endpoint addressed. For instance:

case gZclUI_Off_c:

          if(endPoint== 0x08)

          {

                ASL_SetLed(LED2,gLedOff_c);

          }

          else

          {

                ASL_SetLed(LED3,gLedOff_c);

          }

                ASL_LCDWriteString("Light Off" );

                ExternalDeviceOff();

        break;

Regards,

AngelC

982 Views
minhcuong
Contributor II

Hello AngeIC,

In Ha OnOffLight I creat two HA OnOffLight Endpoint with Endpoint Number  value is 8 and 9

In Ha OnOffSwitch I creat two HA OnOffSwitch Endpoint with Endpoint Number  value is 8 and 9

Capture.PNG

After exporting it to IAR

In BeeApp.c of Ha OnOffLight I add code in  BeeAppUpdateDevice() function to display endPoint value

case gZclUI_Off_c:

      ASL_SetLed(LED2,gLedOff_c);

      ASL_LCDWriteString("Light Off" );

      ExternalDeviceOff();

      LCD_WriteStringValue("endPoint=",endPoint,0,gLCD_HexFormat_c);//mcbk add

      break;

    case gZclUI_On_c:

      ASL_SetLed(LED2,gLedOn_c);

      ASL_LCDWriteString("Light On" );

      ExternalDeviceOn();

      LCD_WriteStringValue("endPoint=",endPoint,0,gLCD_HexFormat_c);//mcbk add

      break;

In BeeApp.c of Ha OnOffSwitch I add modifier code  in  BeeAppHandleKeys() function to send command to the Light

case gKBD_EventSW1_c: /* Sends a Toggle command to the light */

      lastCmd = gZclCmdOnOff_Toggle_c;

     //OnOffSwitch_SetLightState(gSendingNwkData.gAddressMode,aDestAddress,EndPoint,lastCmd, 0);

      OnOffSwitch_SetLightState(gSendingNwkData.gAddressMode,aDestAddress,9,lastCmd, 0); // Add Endpoint = 9

      break;

    case gKBD_EventSW2_c: /* Sends a On command to the light with acknoledge */     

      if ((gSendingNwkData.gAddressMode == gZbAddrModeIndirect_c) || (gSendingNwkData.gAddressMode == gZbAddrMode16Bit_c))

      {

        lastCmd = BeeAppGetSwitchCommand(0);

        OnOffSwitch_SetLightState(gSendingNwkData.gAddressMode,aDestAddress,EndPoint, lastCmd, gApsTxOptionAckTx_c);

      }

      break;

But when I press key1 on OnOffSwitch, LCD on OnOffLight I not receiver endpoint =9, only dispplay endPoint =8

IMAG2421.jpg

How do I get two endpoint difference (8 and 9) on Ha OnOffLight when send command from Ha OnOffSwitch?

Thanks in advance,

Cuong Minh

0 Kudos
982 Views
AngelC
Senior Contributor I

Hello Cuong,

Please make sure you are using direct addressing mode (16-bit). It could be that the default application uses indirect addressing and therefore it is based in the endpoint binding, which you are not implementing for the rest of them added.

I would recommend you to use direct addressing and set the network short address (coordinator is always 0x000). If you would like to use indirect addressing, then you will have to implement a mechanism to bind the different endpoints to their corresponding destination endpoint, which will require some changes to the code.

Regards,

AngelC

0 Kudos
982 Views
namta
Contributor I

Hello AngeIC,

But if I want to bind each switch to each light? how can I change the code? I'm also developing apps to control the light, but RGB light so I need 3 pins to control the light!

0 Kudos