Send/receive message to Host PC

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Send/receive message to Host PC

1,644 Views
ming_
Contributor I

Thanks for reply.

Wow. That is not easy to do. I think, using ZTC isn't good idea for my application.

I think should better use UART directly.

Actually what I want to do...

I'd like to send message from coordinator to host PC though UART (using UART2USB) when I rotate the potentiometer of ZED.

(The dimmer switch(ZED) has a potentiometer for changing battery voltage level. )

so far, my understanding is...

(On EndDevice)

The 'BeeApp.c' has BatteryVoltageCallback() handler and it treat potentiometer value.

And the value set to the attribute of 'ZCL_Power'

After than,I think, BeeStack will send this value to coordinator.

(On Coordinator)

main() create Application Task call 'BeeAppTask(event)'

BeeAppTask() jump to event handler when it got the event.

I think the 'BeeAppDataIndication()' handler treat main message in/out. and It calls ZCL_InterpretFrame().

I look up the ZCL_interpretFrame() and it looks like a general treatment of payloads. I cannot found the 'BatteryVoltage'(ZCL_Power) treatment section.

If I found the BatteryVoltage treat handler, I should write the UART code on that. right?

Question 1. Could you help to found the BatteryVoltage treat handler?

One other Questions (on Coordinator)

I show BeeAppHandlerKeys() method that handle key(sw1 or sw2) event.

but it only call by BeeAppInit() that call at the first initialize of main().

Question 2. How it can treat run time of key input (key pushed by ED and send to Coordinator) ?

Question 3. If you can, Could you draw (or describe) the message flowing?

example:

Get message from air -> ?? ->

create 'gKBD_EventSW1_c' and call BeeAppHandleKeys [at ??] ->

call DimmableLight_AppMove() if got 'gKBD_EventSW1_c' [at BeeAppHandleKeys(), BeeApp.c]  ->

call ASL_ZclLevelControlReq() [at DimmableLight_AppMove(),BeeApp.c] -> Create ZCL_frame -> what will be next??

Question 4. On the code, how it identify the device type(coordinator, router or end-device) itself?

Labels (1)
Tags (1)
0 Kudos
Reply
2 Replies

1,376 Views
olehattebol
Contributor II

Dear Min,

I have started to write a Serial Gateway Interface to a ZigBee network. The program is written in Visual Basic .NET using Microsoft Visual Studio 2010. Visual Studio Express can be downloaded free from Microsoft: Free Dev Tools - Visual Studio Community 2013.

The program is able to decode Messages from the network and send an APSDE-DATA.request. It can toggle a HA OnOff light on a solution with ZTC enabled. The network consists of Freescale MC1322x nodes. The network is set up as instructed in Drew Gislasons book "ZigBee Wireless Networking" page 359-363.A zip file is enclosed.

I am neither an expert Visual Basic nor ZigBee programmer, but hopefully the program can help you with Your PC communication.

Ole

0 Kudos
Reply

1,376 Views
AngelC
Senior Contributor I

Dear Min,

You could use either your custom UART code or the ZTC. Choose the one you prefer the most. If you would like to use the ZHA demo images without significant changes, you could use ZTC and simply detect when the battery level is being reported.

In ZigBee End device’s application, a timer is running to read the potentiometer value (ADC) every certain time. This updates the Battery Voltage attribute (gZclAttrPwrConfigBatteryInfBatteryVoltage_c) in a regular basis. It is then the coordinator which configures the end device to send the battery status periodically.

In ZigBee Coordinator’s side, the ZTC interface is used to create the network and configure the end devices to report their battery level via the GUI. In case you would like to use a Linux PC, you would need to do the whole procedure right from start of network to achieve so. The Battery voltage being reported does not go all the way up to the application level since it uses ZTC commands to report when a message has been received.

However, you may also do the majority of steps with TWR boards buttons. SW1 to create (ZC) and join (ZED) the network, long SW1 in both boards to change to application mode. The only step missing would be to send the Configure Reporting commands to the ZED so it can report the Battery status. Here you have several options:

  1. As mentioned, send a ConfigureReporting command so the ZED starts reporting the Battery level in a regular basis. This would require a good understanding of ZTC commands plus a learning curve using TestTool to send the proper command and parameters. It will also need to implement a command parser in the PC side to detect the reported values.

  1. Modify source code to send the potentiometer value when a button is pressed. For this you will have to implement a function to send generic data and not precisely the attribute of power measurement.

The BeeAppHandleKeys() function is actually defines as the default handler of keyboard interrupts when initialized. This means it will be executed every time a switch is pressed. You could simply modify the SW1 or SW2 cases, or add any non-used case to do what you need.

Please refer to Freescale BeeStack Software Reference Manual for ZigBee 2012 and 2007 for details about ZDO state machine and further details about BeeStack implementation.

Regards,

AngelC

0 Kudos
Reply