nrf_stream.hpp
Go to the documentation of this file.
1 /*
2  * SocialLedge.com - Copyright (C) 2013
3  *
4  * This file is part of free software framework for embedded processors.
5  * You can use it and/or distribute it as long as this copyright header
6  * remains unmodified. The code is free for personal use and requires
7  * permission to use in a commercial product.
8  *
9  * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
10  * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
12  * I SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
13  * CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
14  *
15  * You can reach the author of this software at :
16  * p r e e t . w i k i @ g m a i l . c o m
17  */
18 
24 #ifndef NRF_STREAM_HPP_
25 #define NRF_STREAM_HPP_
26 
27 #include <stdint.h>
28 #include "wireless.h"
29 #include "char_dev.hpp" // Base class
30 #include "singleton_template.hpp" // Singleton Template
31 
32 
33 
44 class NordicStream : public CharDev, public SingletonTemplate<NordicStream>
45 {
46  public:
52  inline void setDestAddr(uint8_t address) { mDestAddr = address; }
53  inline void setPktHops(uint8_t hops) { mHops = hops; }
54 
56  bool flush(void);
57 
59  bool getChar(char* pInputChar, unsigned int timeout=portMAX_DELAY);
60  bool putChar(char out, unsigned int timeout=portMAX_DELAY);
63  private:
64  typedef struct {
65  mesh_packet_t pkt;
66  uint8_t dataPtr;
67  } nrfPktBuffer_t;
68 
69  nrfPktBuffer_t mRxBuffer;
70  nrfPktBuffer_t mTxBuffer;
71  uint8_t mDestAddr;
72  uint8_t mHops;
73 
74  NordicStream();
76 };
77 
78 
79 
80 #endif /* NRF_STREAM_HPP_ */
#define portMAX_DELAY
Definition: portmacro.h:106
Definition: nrf_stream.hpp:44
Provides a &#39;char&#39; device base class functionality for stream oriented char devices.
bool putChar(char out, unsigned int timeout=portMAX_DELAY)
Definition: nrf_stream.cpp:63
Definition: char_dev.hpp:43
void setPktHops(uint8_t hops)
Definition: nrf_stream.hpp:53
bool getChar(char *pInputChar, unsigned int timeout=portMAX_DELAY)
Definition: nrf_stream.cpp:44
bool flush(void)
Flush all buffered data or send any pending data immediately.
Definition: nrf_stream.cpp:80
void setDestAddr(uint8_t address)
Definition: nrf_stream.hpp:52
Definition: singleton_template.hpp:55
This provides simplified way to send/receive data from Nordic wireless chip. ALL WIRELESS DATA should...