©2014 Seeed Technology Inc.
MB_2014_D02
22
Example of Mode operation
Router receives Coordinator’s greeting and reply to it:
Страница 1: ... 2014 Seeed TechnologyInc MB_2014_D02 1 MeshBee Open Source ZigBee RF Module CookBook 2014 Seeed Technology Inc www seeedstudio com ...
Страница 2: ... 2014 Seeed TechnologyInc MB_2014_D02 2 Doc Version Date Author Remark v0 1 2014 05 07 Oliver Created v0 2 2014 06 18 Oliver v0 3 2016 1 21 Jack Modified the example according to the firmware v1004 ...
Страница 3: ...entation 14 2 2 API Mode 15 Remote led blink example 15 Sending Data packets example 18 2 3 MCU Mode 21 Mechanism 21 Additional documentation 23 Blink example in AUPS 23 2 4 Data Mode 24 Chat example 24 Chapter 3 Handle a sleep node 26 3 1 Typical application scenario 26 3 2 implementation 26 3 3 Configuring Sleep 28 Sleep example in AUPS 28 Chapter 4 Make an RPC 32 4 1 What s a micro RPC 32 4 2 W...
Страница 4: ...actory firmware warps the complicated Zigbee stack operation into a few easy to use serial commands AT commands Slave Mode for a complex mesh network a host application can send API frames to the MeshBee that contain short address and payload information instead of using AT command Transparent Mode MeshBee can also work as a transparent serial communication node that can be part of a simple point ...
Страница 5: ...NXP s website to get some detailed description http www nxp com techzones wireless connectivity smart energy html To create the development environment perform these steps 1 Install JN SW 4041 SDK Toolchain to default disk C 2 Install JN SW 4064 ZigBee Smart Energy SDK to default disk C 3 Install JN SW 4067 JN516x ZigBee Home Automation SDK to default disk C Note MeshBee s factory firmware is deve...
Страница 6: ...ne the latest firmware source code from github 2 Copy the source code folder to C Jennic Application 3 Open Jennic Bash Shell 4 Type these shell commands cd MeshBeeMasterBranch cd build build sh Note The developing toolchain supports windows only For Linux and Mac users a windows VM is recommended Note execute build sh or build_xxx_clean sh build_xxx sh Make sure the clean step was taken ...
Страница 7: ...lly congratulations you have finished allthe preparation work Open eclipse IDE and import the project you can catch a glimpse of the firmware To edit the oscfgdiag file and zpscfg file you should install the eclipse plugins according to the guide in section 6 2 2 in SDK Installation and User Guide pdf ...
Страница 8: ...2014_D02 8 Setting up the MeshBee 1 3 Setting up the MeshBee To assemble your experimental environment perform the following steps 1 Step1 Insert MeshBee into the socket of UartBeeV5 2 Step2 Connecting UartBeeV5 with PC by USB port ...
Страница 9: ... 2014 Seeed TechnologyInc MB_2014_D02 9 Setting up the MeshBee Note Switch the SW to 3V3 and SW3 to Prog position at first ...
Страница 10: ...igBee network includes three types of node 1 Coordinator This is the first node to be started and is responsible for forming the network by allowing other node to join the network through it 2 Router This is the node with routing capability and is also able to send receive data 3 End device Only capability to send receive data Different device role should burn different image Burn the latest firmw...
Страница 11: ...ing up the network 1 5 Setting up the network Zigbee network lifecycle Note When you burn a new binary file which is different from the previous one For example burn an end bin overwrite the coo bin you should erase the EEPROM completely at frist ...
Страница 12: ...nologyInc MB_2014_D02 12 Setting up the network Normally MeshBee will form the Network automatically If a router or end device failed to join network you can use command ATRS to rescan and perform network actions again ...
Страница 13: ...rks in input can go back to AT commandmode 2 1 AT mode The ATcommands that MeshBee radios use for interactive are a descendant of hayescommand set Every ATcommand starts with AT and followed by two characters that indicate which command is being executed then by some optional configuration values To communicate with MeshBee from Win7 we will use SecureCRT In CoolTerm on a Mac the procedure works p...
Страница 14: ...sponse 3 To read a register just typing an ATcommand 4 To set a register type an ATcommand followed by the register value ATcommand contain three different types Additional Documentation For more information about the ATcommand operations please refer to the MeshBee User s manual v0 1 Note The baud rate must be set to 115200 in SecureCRT Make sure MeshBee works in ATmode ...
Страница 15: ...he most important thing to note is that APIs are specifically engineered to enable MeshBee to talk efficiently to other MCU The target of API mode is to transmit highly structured data quickly and reliably Remote led blink example Sending commands over the wireless network to control the remote device is kind of exhilarating it is something you can accomplish in APImode Some kinds of ATcommands ca...
Страница 16: ...Coordinator and control the RSSI led on the UARTSBee where the Router is plugged in You should setup the network first to make the Router connect to the Coordinator then put the Coordinator into API mode with the ATAP command The Rounter can be under any mode it will always accept the remote command Arduino sketch include Arduino h LED Pin int led 13 declaration void remoteATIO_Onoff unsigned char...
Страница 17: ...rm_len sizeof remote_at_req unsigned char sum 0 for int i 0 i frm_len i sum remote_at_req i Serial write 0x7e start delimiter Serial write frm_len length Serial write 0x17 API identifier remote AT require Serial write remote_at_req frm_len API_REMOTE_AT_REQ frame Serial write sum check sum Sending Data packets example Now that you may understand how API mode works It s simple enough to write your ...
Страница 18: ...t 0x01 frame ID 0x00 option 0xf5 unicast addr high byte 0x28 unicast addr low byte 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 unicast long addr 0x07 data length s data begin e e e d r n int frm_len sizeof data_pkt unsigned char sum 0 for int i 0 i frm_len i sum data_pkt i Serial write 0x7e start delimiter Serial write frm_len length Serial write 0x02 API identifier API_DATA_PACKET Serial write data_p...
Страница 19: ...gram s main entry pointfunction has gone It s there but it s hidden under the covers by a task of JenOS A task called Arduino_Loop was runningon background There are several other tasks created on MeshBee too So Arduino_Loop should release CPU periodically to let other task useit A software timer was created to activate Arduino_Loop periodically void ups_init void Init ringbuffer UPS_vInitRingbuff...
Страница 20: ...uart_aups OS_eExitCriticalSection mutexRxRb else arduino_loop If a sleep event has already been scheduled in arduino_loop don t set a new arduino_loop if true bGetSleepStatus return re activate Arduino_Loop if g_sDevice config upsXtalPeriod 0 OS_eStartSWTimer Arduino_LoopTimer APP_TIME_MS g_sDevice config upsXtalPeriod NULL else OS_eActivateTask Arduino_Loop this task is the lowest priority Write ...
Страница 21: ...o_setup void suli_pin_init led_io 9 init led suli_pin_dir led_io HAL_PIN_OUTPUT void arduino_loop void suli_pin_write led_io state if state HAL_PIN_HIGH state HAL_PIN_LOW else state HAL_PIN_HIGH 2 4 Data Mode When operating in Data mode the modules act as a serial line All UART data receivedthrough the UART1 is transmitted to a specified remote device To use a transparent connection take the follo...
Страница 22: ... 2014 Seeed TechnologyInc MB_2014_D02 22 Example of Mode operation Router receives Coordinator s greeting and reply to it ...
Страница 23: ... 2014 Seeed TechnologyInc MB_2014_D02 23 Example of Mode operation Coordinator receives Router s reply ...
Страница 24: ... message for it and this piece of message will be discarded after 7 seconds so make sure the traffic is light weight in a sleep enabled network 3 1 Typical application scenario Using sleep mode the life of an end device powered by battery can stretch into months and sometimes even years 1 If the end devices are only needed to send a heartbeat back to the central nodecyclically you can enable the c...
Страница 25: ... 2014 Seeed TechnologyInc MB_2014_D02 25 Handle a sleep node Figure Implementation of sleep end device ...
Страница 26: ...s are currently undefined and retained for futureuse 3 ATSM4 cyclic sleep mode The node will sleep and wake cyclically Set the sleep time using ATSP set how long before a node goes to sleep using ATST 4 ATSM5 cyclic sleep mode with pin wake This is generally the same as cyclic sleep mode but also waking by PIO any of the digital IO Sleep example in AUPS Sleep demo in AUPS End device sends ten hear...
Страница 27: ...iSpec apiSpec int16 temper suli_analog_read temp_pin sprintf tmp E HeartBeat ld r n temper PCK_vApiSpecDataFrame apiSpec 0xec 0x00 0x0000 tmp strlen tmp Air to Coordinator uint16 size i32CopyApiSpec apiSpec tmp if API_bSendToAirPort UNICAST 0x0000 tmp size suli_uart_printf NULL NULL HeartBeat d r n jobCnt jobCnt if 10 jobCnt jobCnt 0 Sleep 3000 ...
Страница 28: ...make an RPC Each system in peer to peer mode can make an RPC RPC Commands are in the format Object name Method name Arguments separated by spaces This is an example of the RPC command required to turn on a LED on MeshBee myled write HIGH 4 3 Why micro RPC Divide different kinds of remote procedure into groups which is marked by asimple obj_name Time complexity of the function search is highly redu...
Страница 29: ... B_run 0 stop B_stop Step2 Rpc Entity HashKey objName MethodArray MethodNum tsRpcEntity rpcEntity 0 home_obj1 methodEntityA METHOD_ENTITY_SIZE methodEntityA 0 office_obj2 methodEntityB METHOD_ENTITY_SIZE methodEntityB Step3 Rpc Method defined here bool A_run tsArgumentstsArg DBG_vPrintf TRACE_RPC home_obj is running r n return TRUE bool A_stop tsArguments tsArg DBG_vPrintf TRACE_RPC home_obj is st...
Страница 30: ...RPC office_obj2 is running r n return TRUE bool B_stop tsArgumentstsArg DBG_vPrintf TRACE_RPC office_obj2 is stopping r n return TRUE After that you can call these remote functions at any nodes by RPC_vCaller uint64 macAddress char rpcCmd eg RPC_vCaller 0x00158d0000355273 home_obj1 run param1 param2 ...