VitroIO SDK
Software development kit for Vitro Shard.
Loading...
Searching...
No Matches
node_controller.h
Go to the documentation of this file.
1#ifndef VITROIO_SDK_NODE_CONTROLLER_H
2#define VITROIO_SDK_NODE_CONTROLLER_H
3
4#include <mbed.h>
5#include <functional>
6
9#include <vitroio-sdk/types.h>
10
16
17namespace vitroio
18{
19
20namespace sdk
21{
22
34#define VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE 32
35
36class Canbus;
37
53class NodeController : private NonCopyable<NodeController>
54{
55public:
88 Canbus* canbus,
89 const FirmwareId& fwId,
90 const Version& fwVersion,
91 FlashSpace environmentFlashSpace,
92 FlashSpace regionAFlashSpace,
93 FlashSpace regionBFlashSpace,
94 EventQueue* targetQueue,
95 uint32_t eventQueueSize = VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE);
96
121 Canbus* canbus,
122 const FirmwareId& fwId,
123 const Version& fwVersion,
124 FlashSpace environmentFlashSpace,
125 FlashSpace regionAFlashSpace,
126 FlashSpace regionBFlashSpace,
127 osPriority priority = osPriorityNormal,
128 uint32_t eventQueueSize = VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE);
129
148 Canbus* canbus,
149 const FirmwareId& fwId,
150 const Version& fwVersion,
151 osPriority priority = osPriorityNormal,
152 uint32_t eventQueueSize = VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE);
153
180 Canbus* canbus,
181 const FirmwareId& fwId,
182 const Version& fwVersion,
183 EventQueue* targetQueue,
184 uint32_t eventQueueSize = VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE);
185
187
194 bool isValid();
195
204
212 int initCommunication(uint32_t sync_time, Transport_layer* layer);
213
223 uint32_t nodeId();
224
229 void setExternalFrameCallback(std::function<void(const CanbusFrame&)>);
230
231private:
232 bool valid_;
233
234 EventQueue evQueue_;
235 impl::ScopedPtr<Thread> evQueueThread_;
236
240 Canbus* canbus_;
241 FirmwareId fwId_;
242 Version fwVer_;
243 uint64_t id_;
244 uint32_t nodeId_;
245 FlashSpace regionAFlashSpace_;
246 FlashSpace regionBFlashSpace_;
247
248 Mutex mutex_;
249
250 //void (*externalFrameCallback)(const CanbusFrame&);
251 std::function<void(const CanbusFrame&)> externalFrameCallback;
252
253 void setNodeId(uint32_t id);
254
255 int onFrameReceivedCallbackHandle_;
256
257 void onFrameReceivedCallback(const CanbusFrame&);
258
259 void handleNodeIdResponseFrame(const CanbusFrame& frame);
260 void handleUpgradeFrame(const CanbusFrame& frame);
261 void handleProvisioningFrame(const CanbusFrame& frame);
262 void handleExternalFrame(const CanbusFrame& frame);
263
264 void onNewFirmwareAvailableCallback();
265
266 uint64_t getHardwareId();
267};
268
273} // namespace sdk
274
275} // namespace vitroio
276
277#endif // VITROIO_SDK_NODE_CONTROLLER_H
Class is a wrapper for mbed::CANMessage. It provides interface allowing creation of frames complied w...
Definition: canbus_frame.h:24
Class is a wrapper for mbed::CAN class and provides interface for CanbusFrame type.
Definition: canbus.h:50
Class is a main component of the node firmware.
Definition: node_controller.h:54
uint32_t nodeId()
Function allows to obtain node ID assigned by gateway during initialization of communication.
int initCommunication(uint32_t sync_time, Transport_layer *layer)
Function initializes communication with gateway. This method blocks until the communication is not in...
bool isValid()
Function allows to check whether the controller is in valid state.
NodeController(Canbus *canbus, const FirmwareId &fwId, const Version &fwVersion, osPriority priority=osPriorityNormal, uint32_t eventQueueSize=VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE)
Contructor initializes the controller and creates internal event loop using thread with priority prio...
NodeController(Canbus *canbus, const FirmwareId &fwId, const Version &fwVersion, FlashSpace environmentFlashSpace, FlashSpace regionAFlashSpace, FlashSpace regionBFlashSpace, osPriority priority=osPriorityNormal, uint32_t eventQueueSize=VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE)
Contructor initializes the controller and creates internal event loop using thread with priority prio...
NodeController(Canbus *canbus, const FirmwareId &fwId, const Version &fwVersion, FlashSpace environmentFlashSpace, FlashSpace regionAFlashSpace, FlashSpace regionBFlashSpace, EventQueue *targetQueue, uint32_t eventQueueSize=VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE)
Contructor initializes the controller and chains an internal event queue to the targetQueue.
void setExternalFrameCallback(std::function< void(const CanbusFrame &)>)
Function allows to attach a handler for frames with paramId matching VITROIO_PROTOCOL_EXTERNAL_FRAME.
NodeController(Canbus *canbus, const FirmwareId &fwId, const Version &fwVersion, EventQueue *targetQueue, uint32_t eventQueueSize=VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE)
Contructor initializes the controller and chains an internal event queue to the targetQueue.
int initCommunication(Transport_layer *layer)
Function initializes communication with gateway. This method blocks until the communication is not in...
Virtual class providing interface for communication interfaces.
Definition: transport_layer.h:29
Class is wrapper for FlashInterface. It allows to read/write environment variables stored in flash me...
Definition: environment_interface.h:33
Class is a wrapper for mbed::FlashIAP module.
Definition: flash_interface.h:26
Definition: scoped_ptr.h:17
Class is responsible for handling upgrade data.
Definition: upgrade_controller.h:39
#define VITROIO_NODE_CONTROLLER_DEFAULT_EVENT_QUEUE_SIZE
Defines default size of internal event queue for NodeController .
Definition: node_controller.h:34
The namespace contains all of components of vitro-shard-sdk and components based on the sdk....
Definition: can_layer.h:9
Definition: types.h:22
Structure representing space of flash memory.
Definition: types.h:79
Structure representing version in format major.minor.patch.
Definition: types.h:47
The file contains types used by vitro-shard-sdk.