Other Parts Discussed in Thread: CC2650
Hi, I am developing an automated door lock with CC2650 launchpad in Code Composer Studio 6.
For that i started from the Simple_Observer.
The idea is to wait for the RSSI greater than (-40) and than check the pEvent->deviceInfo.pEvtData to see if it is the same as the one stored in my variable.
I will post the relevant code in context:
//Variable with the same data that i see in the TERMITE throw the UART
static uint8_t MsgData[512] = {0x02,0x01,0x1a,0x06,0x09,0x50,0x6f,0x72,0x74,0x61,0x04,0xff,0xf2,0xf1,0xb2,0x02,0x0a,0x01,0x04,0x16,0xf4,0xf9,0xb2};
case GAP_DEVICE_INFO_EVENT:
{
static char cmd[512],cmd2[512]; //Variable "cmd" receives the data from the advertiser, Variable "cmd2" receives the data from my internal variable that should be the same as "cmd".
static int ret; //This variable is for the (memcmp function)
//Just writing the RSSI level
UART_write(uart, "Level:", sizeof("Level:")-1);
sprintf(cmd, "%d\r\n", pEvent->deviceInfo.rssi);
UART_write(uart, cmd, strlen(cmd)-1);
//Converting the received advertisement data from uint8 to string in (sprintf function)
UART_write(uart, "Data:", sizeof("Data:")-1);
for (int j=0; j<pEvent->deviceInfo.dataLen;j++)
{
sprintf(cmd, "%02x ", pEvent->deviceInfo.pEvtData[j]);
UART_write(uart, cmd, 3);
}
UART_write(uart, "\r\n", sizeof("\r\n")-1);
UART_write(uart, "\r\n", sizeof("\r\n")-1);
//Checking the RSSI level, untill here its all good
if(pEvent->deviceInfo.rssi >= (-40))
{
flag = 1;
}
else if(pEvent->deviceInfo.rssi <(-40))
{
flag = 0;
}
//Here i convert from my variable MsgData that has the same uint8 vector as received throw the uart that is converted to the "cmd" variable
if(flag == 1)
{
for(int i=0; i<pEvent->deviceInfo.dataLen; i++)
{
sprintf(cmd2, "%02x ", MsgData[i]);
UART_write(uart, cmd2, 3);
}
//Here i compare both strings.
ret = memcmp(cmd,cmd2, pEvent->deviceInfo.dataLen);
if(ret == 0)
{
PIN_setOutputValue(pinHandle, IOID_6, 1);
PIN_setOutputValue(pinHandle, IOID_7, 1);
Clock_start(Clock_handle(&myClock));
}
else if(ret < 0)
{
UART_write(uart, "cmd2 > cmd \n\r", sizeof("Erro ret < 0 \n\r")-1);
}
else if(ret > 0)
{
//i get this responde from the memcmp
UART_write(uart, "cmd2 < cmd \n\r", sizeof("Erro ret < 0 \n\r")-1);
} //return;
So i dont know why, but it says that the cm2 is lesser than cmd, what makes me wonder, am i seeing all the data that i am receiving from the advertising packet?
Next its what i see in Termite:
discovering
Address:70925d364852Level:-28
Data:02 01 1a 06 09 50 6f 72 74 61 04 ff f2 f1 b2 02 0a 01 04 16 f4 f9 b2
02 01 1a 06 09 50 6f 72 74 61 04 ff f2 f1 b2 02 0a 01 04 16 f4 f9 b2 cmd2 < cmd
[00]À