is it possible to do serial communication between JN5168 with other microcontroller, such as ATmega8?
and also, is it possible to do it in router device? (since i'm looking the sample code at home automation, every uart function is available only for coordinator)
if there's a way, how? and which sample code i can use as base for this?
thanks
My condition now is use JN-AN-1189 as the base code.
i look for some AN and find that JN-AN-1223 use uart function, but it's for coordinator, meanwhile i need to use my device as router/end device, since i need to command it.
my purpose is to send 8 bytes data and receive 10 bytes data using uart. sending data is triggered either by push button or command from coordinator
my question now,
1. how to use uart.c in other project (from 1223 to 1189)? it doesn't allow me to compile it
2. how to update the oscfg? since i need event and interupt for uart function, but again, not allowed to compile
3. is there any cluster that i can use to send not only command but also some string contain information?
1. Have you added APPSRC += uart.c in the Makefile ? Have you #include "uart.h" ?
2. Start simple, implement interrupt first, ensure that interrupts work (able to trigger ISR/callback and handle it), then make event/buffer work.
For the oscfg, you can probably copy & paste the ISR TickTimer but replace with UART, then call a new APP_isrUART. Then if you want to event/buffer, you could follow the ZBPro "folder"/"group" section by Posting a Message to a Queue, then create a Task to Poll/Read the Queue. Or you could keep it simple and roll your own uint8 UARTBuffer[] code first to test proof of concept.
After editing the oscfg, you'll probably need to update some *.c files to reflect the changes made.
3. Make a custom cluster ? You can right click to New child > Cluster in app.zpscfg in /Common/Source/. You'll then need to know how and where to handle the custom cluster, read & interpret the payload bytes manually. You could dig into their zigbee *.c files to see how they do it.
Yes, you can interface with other MCUs, just like a normal UART interface.
You can find the APIs to use in the Doc JN-UG-3087 under section 22. UART Functions.
To start, just look for the API command of interest, then CTRL+H in your IDE and paste it in the search to see where and how it is used in the AppNote.
Which sample code are you looking at ? JN-AN-xxxx ?
thanks for reply. right now i use JN-AN-1189. because the device i'm going to use is like a switch. if i press button 1, then i want to send command in byte to open, button 2 for close, and so on. the problem is, there's no uart.c/uart.h on JN-AN-1189, nor function to be use. can you tell me how to do it?
by the way. by "interface" it, is it enough just put the rx tx from jn5168 chip directly to other tx rx mcu like this picture?
That circuit connection will be able to RX TX for development purposes but make sure you check voltages. JN is 3.3V only.
>To get started
If you would take a look at JN-UG-3116 under section 9. DBG API, there is a DBG_iGetChar().
Find your application's main loop, then create a function like vUARTParse() and call it in the main loop.
PUBLIC void vUARTParse() {
int temp;
temp = DBG_iGetChar();
switch (temp) {
case 'a': // Single byte command RX
/* Do Stuff */
break;
case 0x01: // Single byte command RX
/* Do Stuff */
break;
}
}
If you want a more proper way, look up JN-UG-3087 under section 22. UART Functions.