This is Tiny protocol implementation for microcontrollers (Arduino, Stellaris).
Simple Tiny Protocol examples
Simple Tiny Protocol examples section is applicable only when working with Tiny simple API functions and Tiny advanced API functions. If you want to work with Tiny Half Duplex protocol, please refere to Half Duplex Tiny Protocol examples section.
Initialization
Sending/Receiving data over protocol
Variant 1
First variant: without using any helpers to work with data
uint8_t g_buffer[16];
void loop()
{
if (needToSend)
{
uint8_t buffer[16];
buffer[0] = 10;
buffer[1] = 20;
proto.
write( buffer, 2 );
}
int length;
if ( length > 0 )
{
}
}
Variant 2
Second variant: with using special helper to pack the data being sent
uint8_t g_buffer[16];
void loop()
{
if (needToSend)
{
uint8_t buffer[16];
packet.put( "message" );
}
int length;
if ( length > 0 )
{
char * str = packet.getString();
}
}
Stopping communication
void loop()
{
...
if ( needToStop )
{
}
}
Half Duplex Tiny Protocol examples
Half Duplex Tiny Protocol examples section is applicable when working with Tiny Half Duplex API functions, Tiny simple API functions and Tiny advanced API functions.
Initialization
uint8_t g_buffer[64];
void onReceiveData(uint8_t *buffer, int len)
{
}
void setup()
{
}
Sending/Receiving data over protocol
Variant 1
First variant: without using any helpers to work with data
uint8_t g_buffer[64];
void onReceiveData(uint8_t *buffer, int len)
{
}
void loop()
{
if (needToSend)
{
uint8_t buffer[16];
buffer[0] = 10;
buffer[1] = 20;
proto.
write( buffer, 2 );
}
proto.run();
...
}
Variant 2
Second variant: with using special helper to pack the data being sent
uint8_t g_buffer[64];
void onReceiveData(uint8_t *buffer, int len)
{
char * str = packet.getString();
}
void loop()
{
if (needToSend)
{
uint8_t buffer[16];
packet.put( "message" );
}
proto.run();
...
}
Stopping communication
void loop()
{
...
if ( needToStop )
{
}
}