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 light protocol 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
Tiny::Proto proto;
void loop()
{
if (needToSend)
{
proto.write( packet );
}
int length;
if ( length > 0 )
{
}
}
Stopping communication
Tiny::Proto proto;
void loop()
{
...
if ( needToStop )
{
proto.end();
}
}
Half Duplex Tiny Protocol examples
Half Duplex Tiny Protocol examples section is applicable when working with Tiny Half Duplex API functions, Tiny light protocol API functions.
Initialization
uint8_t g_buffer[64];
void onReceiveData(uint8_t *buffer, int len)
{
}
void setup()
{
proto.beginToSerial();
}
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)
{
}
void loop()
{
if (needToSend)
{
proto.write( packet );
}
proto.run();
...
}
Stopping communication
void loop()
{
...
if ( needToStop )
{
proto.end();
}
}