■ Screenshot 7. A good programmer uses every trick
at his or her disposal. This capture shows how I
determined the Peripheral MAC address.
■ Screenshot 6. This is a familiar shot. Note the reduced
number of GPIO pins required to support the RN4020
click. These are the only pins that the click brings out to
its headers.
MLDP mode, which allows us to communicate with ASCII
characters. Let’s send a tilde character (~) once per second:
if(rxBuf[0] == ‘C’ && \
rxBuf[1] == ‘M’ && \
rxBuf[2] == ‘D’)
{
printf(“E,0,001EC01D7D9B\r\n”);
//connect to Peripheral
__delay_ms(100);
CMD_SetHigh(); //enter MLDP mode
}
do{
__delay_ms(1000);
printf(“~”);
}while(1);
We didn’t code the Peripheral to process the tilde. So,
we can go back to the peripheral project and add the code.
We can also use one of the Curiosity board’s LEDs to
indicate that the tilde character is getting processed. A quick
look at the Curiosity schematic (in the Curiosity User’s
Guide) tells us that we can access LED D7 via RC5 of the
PIC16F1619. I added the RC5 pin using the Code
■ Screenshot 8. I simply added the RC5 pin as OURLED
and regenerated the GPIO code. Macros for the new GPIO
pin were seamlessly added to the original code.
__delay_ms(500);
if(EUSART_DataReady)
{
do{
rxBuf[indx++] = EUSART_Read();
}while(EUSART_DataReady);
}
}
Once the Central comes up, it will need to connect to
our original peripheral. We’re going to cheat a little and
use an RN4020 PICtail to obtain the peripheral’s public
indx = 0;
do{
if(EUSART_DataReady)
{
do{
rxBuf[indx] = EUSART_Read();
if(rxBuf[indx] == ‘~’)
{
OURLED_Toggle();
//blink LED D7 on Curiosity Development Board
}
}while(EUSART_DataReady);
}
}while(1);
MAC address. The process is captured in Screenshot 7.
We could have written scan code to get this address,
but since we’re only concerned with a peer-to-peer
connection, I decided to go the cheap and easy way.
By the way, when the Peripheral establishes a
connection, LED D4 will illuminate on the Peripheral
Curiosity development board. The Master indicates a
connection by the CONN LED on the click module.
Here’s the Master connection code that was added to the
original peripheral code:
Still Curious?
You’ve got to try this on your own. I’ll supply the
project files we used via the article link. In the meantime,
you can now add Curiosity to your design cycle. NV
Curiosity Development Board
XC8 C Compiler
www.mikroe.com/click
RN4020 Bluetooth Smart Radio
Module
BLE Sniffer
RN4020 click Module
Once connected, we can exchange data using the
Microchip
www.microchip.com
Adafruit
www.adafruit.com
60 December 2015