|
|
View previous topic :: View next topic |
Author |
Message |
mvme5100
Joined: 10 Nov 2016 Posts: 6
|
CCS Wireless Ember Zigbee kit, data problem |
Posted: Tue Jun 27, 2017 11:55 pm |
|
|
Hello,
I'm trying to send a Long data instead of int8 without success.
If sending number above 255 from a device (EX12B.c below)
the 'unicast_data' will show '0'.
I hope someone try this, if does please suggest what I do wrong:
This is the exercise 12B from the exercise book, EX12B.c code:
// Modified messagedata[1] to LONG type
Code: |
#include <16F886.h>
#fuses INTRC, NOWDT, NOLVP, BORV21
#device *=16
#use delay(clock = 4000000)
#use rs232(baud = 9600, xmit=pin_c6, rcv=pin_c7, STREAM=Console)
#define SLEEPY_SENSOR 1
#include <stdlib.h>
#include "EM260.h"
#include "ember_utilities.c"
void main(void)
{
int i;
EmberStatus Status;
EmberEUI64 emLocalEUI64;
EmberApsFrame apsframe;
int messagetag=0x01;
long messagedata[1];
int messageLength;
int16 indexOrDestination;
output_high(POWER_UP_PIN);
if(EmberInitialization())
{
EmberConfig();
EmberInitializeBinding();
ezspGetEUI64(&emLocalEUI64[0]);
EmberAddEndPoint();
EmberJoinNetWork(EMBER_SLEEPY_END_DEVICE);
indexOrDestination = 0x000;
apsframe.profileID=0xC00F;
apsframe.clusterID=0x0001;
apsframe.sourceEndpoint=0x01;
apsframe.destinationEndpoint=0x01;
apsframe.options=0x0000;
apsframe.groupID=0x0000;
apsframe.sequence=0x00;
messageLength=1;
printf("Software was compiled on ");
printf(__DATE__);
while(TRUE)
{
if(input(PUSH_BUTTON1))
{
// i++;
messagedata[0]=256;
printf(" DAT: %lu", messagedata[0]);
ezspSendUnicast(Ember_OUTGOING_DIRECT,indexOrDestination,&apsframe,messagetag,messageLength,&messagedata[0]);
delay_ms(200);
}
if(!input(PUSH_BUTTON2))
{
// i--;
messagedata[0]=100;
ezspSendUnicast(Ember_OUTGOING_DIRECT,indexOrDestination,&apsframe,messagetag,messageLength,&messagedata[0]);
delay_ms(200);
}
}
}
} |
This is the "ember_utilities.c" partial code:
// Modified unicast_data and CoordinatorData[128]; to LONG type.
Code: |
#define INTS_PER_SECOND 15
#IF COORDINATOR
LONG unicast_data;
LONG CoordinatorData[128];
#ELIF ROUTER
int8 RouterData[128];
#ELIF SLEEPY_SENSOR
int8 SensorData[28];
#ENDIF
EmberEUI64 emLocalEUI64;
|
This is the exercise 12A from the exercise book, EX12A.c code:
// This is the Coordinator board which should print the unicast_data LONG data:
Code: |
#include <18F4620.h>
#fuses HS, NOWDT, NOLVP
#use delay(clock = 10000000)
#use rs232(baud = 9600, xmit=pin_c6, rcv=pin_c7)
#define COORDINATOR 1
#include "EM260.h"
#include "ember_utilities.c"
#include <digit.h>
void main(void)
{
EmberEUI64 emLocalEUi64;
EmberStatus Status;
printf("\n\r RESET.....");
if(EmberInitialization())
{
EmberConfig();
EmberInitializeBinding();
ezspGetEUI64(&emLocalEUI64[0]);
EmberAddEndPoint();
EmberFormNetwork();
Status=ezspPermitJoining(0xFF);
while(TRUE)
{
EM260Tick();
sinkApplicationTick();
lcd_putd(unicast_data);
printf("\n\r DATA: %lu ",unicast_data);
}
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Jun 28, 2017 10:39 am |
|
|
You do realise that the message length has to increase. You now want to send two bytes of message data, where the code as standard sends one.... |
|
|
mvme5100
Joined: 10 Nov 2016 Posts: 6
|
|
Posted: Wed Jun 28, 2017 10:47 am |
|
|
Thanks, I did realize it earlier today. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19552
|
|
Posted: Wed Jun 28, 2017 11:16 am |
|
|
Good. |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|