Go to the documentation of this file. 1 #ifndef __GREETHANDLER_H_
2 #define __GREETHANDLER_H_
6 #include <pheromones/HiveMindHostDeserializer.h>
7 #include <pheromones/HiveMindHostSerializer.h>
12 IHiveMindHostDeserializer& deserializer,
17 bool greet()
override;
25 #endif // __GREETHANDLER_H_
MessageDispatcherTask(const char *taskName, UBaseType_t priority, ICommInterface *stream, ICircularQueue< MessageDTO > &streamQueue)
Definition: Main.cpp:150
BittyBuzzStringResolver m_stringResolver
Definition: Main.cpp:67
Definition: IInterloc.h:10
BBVMRet
Definition: IBittyBuzzVm.h:10
void setStream(ICommInterface *stream)
Definition: Main.cpp:207
~GreetHandler() override=default
Definition: BittyBuzzContainer.h:14
bool deserializeAndDispatch() override
deserialize a message and dispatches it in the appropriate queue
Definition: MessageDispatcher.cpp:27
LogRet
The return value of the logger.
Definition: ILogger.h:23
BittyBuzzClosureRegister & getBBZClosureRegister()
return an instance of a bittybuzz function register
Definition: BittyBuzzContainer.cpp:16
constexpr uint16_t gc_taskHighPriority
Definition: Main.cpp:28
const char * getStateString(bbzvm_state state)
Definition: BittyBuzzSystem.cpp:143
virtual const PositionsTable & getPositionsTable() const =0
Returns the position table for all robots in the swarm.
Definition: InterlocContainer.h:9
std::optional< std::reference_wrapper< ICommInterface > >(*)() commInterfaceGetter
Definition: Main.cpp:31
~MessageDispatcherTask() override=default
~InterlocMessageHandlerTask() override=default
MessageSenderTask & m_senderTask
Definition: Main.cpp:257
ILogger & m_logger
Definition: Main.cpp:213
void task() override
Definition: Main.cpp:383
ICommInterface * m_stream
Definition: Main.cpp:164
IHiveMindHostDeserializer & m_deserializer
Definition: GreetHandler.h:21
virtual LogRet log(LogLevel level, const char *format,...)=0
Logs if the provided level is higher than the current log level (Thread-safe)
Definition: IInterlocMessageHandler.h:6
bool start() override
Starts the vm.
Definition: BittyBuzzVm.cpp:64
virtual int printLine(const char *format,...)=0
Provides an interface to print a line to the console or serial port. Flushes the input and adds a new...
ConnectionType
Definition: ICommInterface.h:6
static void resetVmButtonCallback(void *context)
Definition: Main.cpp:76
~InterlocDataHandlerTask() override=default
~HardwareInterlocTask() override=default
void task() override
Definition: Main.cpp:82
BittyBuzzStringResolver createBittyBuzzStringResolver(ILogger &logger)
Creates a BittyBuzzStringResolver with the main.bzz bytecode.
Definition: BittyBuzzFactory.cpp:16
IUserInterface & getUserInterface()
Returns an instance of the platform dependent UserInterface.
Definition: BSPContainer.cpp:19
void task() override
Definition: Main.cpp:168
BittyBuzzMessageHandler & getBBZMessageHandler()
return an instance of a bittybuzz message handler
Definition: BittyBuzzContainer.cpp:8
Definition: HiveMindHostApiRequestHandler.h:10
IHiveMindHostSerializer * m_serializer
Definition: Main.cpp:214
Definition: BittyBuzzFactory.h:12
void setHostConnectionState(ConnectionState state)
Definition: Main.cpp:419
GreetHandler(IHiveMindHostSerializer &serializer, IHiveMindHostDeserializer &deserializer, IBSP &bsp)
Definition: GreetHandler.cpp:3
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 24 > > createBittyBuzzMathLib()
Creates a the math table library for the bvm.
Definition: BittyBuzzFactory.cpp:46
virtual bool isConnected() const =0
Tells if interface is connected and functionning.
virtual void startInterloc()=0
Dummy function to demonstrate working DW1000s.
IButtonCallbackRegister & m_buttonCallbackRegister
Definition: Main.cpp:65
BittyBuzzNeighborsManager & getBBZNeighborsManager()
return an instance of a bittybuzz neighbors manager
Definition: BittyBuzzContainer.cpp:29
void terminate() override
Terminate the virtual machine and removes all messages that were supposed to be processed.
Definition: BittyBuzzVm.cpp:80
const char * getErrorString(bbzvm_error error)
Definition: BittyBuzzSystem.cpp:160
Definition: ApplicationInterfaceContainer.h:12
IUserInterface & m_ui
Definition: Logger.h:20
LogInterlocTask(const char *taskName, UBaseType_t priority)
Definition: Main.cpp:372
InterlocMessageHandlerTask(const char *taskName, UBaseType_t priority)
Definition: Main.cpp:331
IInterlocMessageHandler & getInterlocMessageHandler()
Definition: InterlocContainer.cpp:19
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 2 > > createBittyBuzzUILib()
Creates a the ui table library for the bvm.
Definition: BittyBuzzFactory.cpp:76
Definition: BittyBuzzVm.h:17
void delay()
wait for a certain delay Signature delay(arg1) Warning this function make the whole VM sleep which ca...
Definition: BittyBuzzUserFunctions.cpp:327
MessageDispatcherTask & m_dispatcherTask
Definition: Main.cpp:256
Manages the interface if a device was handshaked (greeted) with or not. Lights the appropriate LED to...
Definition: IHandshakeUI.h:6
void setStream(ICommInterface *stream)
Definition: Main.cpp:161
Definition: GreetHandler.h:9
~BittyBuzzTask() override=default
std::atomic_bool m_resetVm
Definition: Main.cpp:70
static char logLevelToString(LogLevel logLevel)
Definition: Logger.cpp:31
IHandshakeUI & m_handshakeUI
Definition: Main.cpp:258
LogLevel
The log level used for the logger.
Definition: ILogger.h:9
MessageSenderTask(const char *taskName, UBaseType_t priority, ICommInterface *stream, INotificationQueue< MessageDTO > &streamQueue, bool keepRunning=false)
Definition: Main.cpp:194
bool init(const std::reference_wrapper< IBittyBuzzLib > *bbzLibs, uint32_t bbzLibsLength) override
Init the virtual machine.
Definition: BittyBuzzVm.cpp:38
ButtonCallbackRegister & getButton1CallbackRegister()
get the button 1 callback register
Definition: ApplicationInterfaceContainer.cpp:17
LogRet log(LogLevel level, const char *format,...) override
Logs if the provided level is higher than the current log level (Thread-safe)
Definition: Logger.cpp:8
HostHandshakeUI & getHostHandshakeUI()
get the host handshake UI
Definition: ApplicationInterfaceContainer.cpp:33
void task() override
Definition: Main.cpp:363
void setRemoteConnectionState(ConnectionState state)
Definition: Main.cpp:424
BittyBuzzLib< std::array< BittyBuzzLibMemberRegister, 15 > > createBittyBuzzGlobalLib(int16_t vmStepDelay)
Creates an array of FunctionRegister associated with the code from main.bzz.
Definition: BittyBuzzFactory.cpp:21
connectionStateSetter m_connectionStateSetter
Definition: Main.cpp:260
ILogger & m_logger
Definition: Main.cpp:261
Definition: HiveConnectHiveMindApiMessageHandler.h:10
IInterloc & m_interloc
Definition: Main.cpp:361
void setSerializer(IHiveMindHostSerializer *serializer)
Definition: Main.cpp:208
BittyBuzzTask(const char *taskName, UBaseType_t priority, IDeviceStateUI &deviceStateUI, IButtonCallbackRegister &buttonCallbackRegister)
Definition: Main.cpp:38
NotificationQueue< MessageDTO > & getRemoteMsgQueue()
get the remote message queue
Definition: MessageHandlerContainer.cpp:57
ICircularQueue< MessageDTO > & m_streamQueue
Definition: Main.cpp:165
MessageDispatcher createMessageDispatcher(IHiveMindHostDeserializer &deserializer, IHiveMindHostApiRequestHandler &hivemindApiReqHandler, IHiveConnectHiveMindApiMessageHandler &hiveconnectApiMessageHandler, IGreetSender &greetSender)
create a message dispatcher
Definition: MessageHandlerContainer.cpp:24
IInterlocManager & getInterlocManager()
Returns an instance of the interloc manager.
Definition: BSPContainer.cpp:24
void task() override
Definition: Main.cpp:263
HiveMindHostApiRequestHandler createHiveMindHostApiRequestHandler()
create a request handler
Definition: MessageHandlerContainer.cpp:18
IInterloc & m_interloc
Definition: Main.cpp:380
BittyBuzzBytecode createBittyBuzzBytecode(ILogger &logger)
Creates a BittyBuzzBytecode with the main.bzz bytecode.
Definition: BittyBuzzFactory.cpp:12
ILogger & m_logger
Definition: Main.cpp:381
Definition: BSPContainer.h:12
virtual Mutex & getPrintMutex()=0
get the mutex for printing. Note that the mutex is not used in any functions, the user needs to lock ...
uint16_t m_positionsLength
Definition: IInterloc.h:12
Definition: MessageHandlerContainer.h:14
BittyBuzzBytecode m_bytecode
Definition: Main.cpp:66
IBSP & m_bsp
Definition: GreetHandler.h:22
uint16_t getBBZVMStepDelayMs()
Get the delay between each steps of the vm.
Definition: SettingsContainer.cpp:53
BittyBuzzMessageService & getBBZMessageService()
return an instance of a bittybuzz message service
Definition: BittyBuzzContainer.cpp:21
int main(int argc, char **argv)
Definition: Main.cpp:428
~LogInterlocTask() override=default
std::optional< std::reference_wrapper< ICommInterface > > getRemoteCommInterface()
Return an instance of the connected remote comm interface.
Definition: BSPContainer.cpp:65
constexpr uint16_t gc_taskNormalPriority
Definition: Main.cpp:27
Definition: BittyBuzzStringResolver.h:9
Logger & getLogger()
Return a reference to the global logger.
Definition: LoggerContainer.cpp:5
void task() override
Definition: Main.cpp:217
ConnectionStateUI & getConnectionStateUI()
get the connection state UI
Definition: ApplicationInterfaceContainer.cpp:23
HardwareInterlocTask(const char *taskName, UBaseType_t priority)
Definition: Main.cpp:320
bbzvm_state getState() const override
Get the state of the vm.
Definition: BittyBuzzVm.cpp:122
std::optional< std::reference_wrapper< ICommInterface > > hostInterfaceGetter()
Definition: Main.cpp:398
A logger class with basic logging capabilities.
Definition: ILogger.h:35
bool greet() override
wait for a greet and then send the greet response. Serializes directly to the stream and not the the ...
Definition: GreetHandler.cpp:8
std::optional< std::reference_wrapper< ICommInterface > > getHostCommInterface()
Return an instance of the connected host comm interface.
Definition: BSPContainer.cpp:30
void(*)(ConnectionState state) connectionStateSetter
Definition: Main.cpp:34
virtual bool processMessage()=0
Processes the next message in the queue.
virtual void process()=0
Spins the interloc task checking if any updates happened. Processing them and pushing update values t...
BBVMRet step() override
Does one execution step in the virtual machine. Thus execute the buzz code in the step function.
Definition: BittyBuzzVm.cpp:90
IBSP & getBSP()
Returns an instance of the platform dependent BSP.
Definition: BSPContainer.cpp:13
Definition: ICommInterface.h:8
IInterloc & getInterloc()
Definition: InterlocContainer.cpp:12
Definition: BittyBuzzBytecode.h:9
virtual void initChip(void *args)=0
Initialise the chip for usage. Needs to be called early in the program.
void stop() override
Stops the vm, can be called in another thread or in an interrupt.
Definition: BittyBuzzVm.cpp:73
Definition: GreetSender.h:9
bool processAndSerialize() override
process an item in the queue, serializes it and sends it to the deserializer
Definition: MessageSender.cpp:9
virtual void setDeviceState(DeviceState state)=0
Sets the state of the device.
A structure to wrap command line arguments used for certain BSPs.
Definition: IBSP.h:29
ConnectionState
Definition: SystemStates.h:4
static DeviceState vmErrorToDeviceState(bbzvm_error err)
Definition: Main.cpp:72
LogLevel getLogLevel()
Get the log level of the application.
Definition: SettingsContainer.cpp:33
ILogger & m_logger
Definition: Main.cpp:166
NotificationQueue< MessageDTO > & getInterlocMsgQueue()
get the interloc message queue
Definition: MessageHandlerContainer.cpp:70
void setConnectionState(ConnectionState state) override
Sets the state of the connection.
Definition: ConnectionStateUI.cpp:6
Definition: IInterloc.h:15
HiveConnectHiveMindApiMessageHandler createHiveConnectHiveMindApiMessageHandler()
create a message handler
Definition: MessageHandlerContainer.cpp:13
NotificationQueue< MessageDTO > & getHostMsgQueue()
get the host message queue
Definition: MessageHandlerContainer.cpp:44
std::array< RelativePosition, MAX_AGENTS_IN_SWARM > m_positions
Definition: IInterloc.h:11
LogLevel m_logLevel
Definition: Logger.h:21
Manages UI of the device state and informs the user via the board display.
Definition: IDeviceStateUI.h:7
virtual int print(const char *format,...)=0
Provides an interface to print to the console or serial port. The arguments and return values match t...
Definition: MessageDispatcher.h:14
NotificationQueue< MessageDTO > & m_interlocMessageQueue
Definition: Main.cpp:339
IHiveMindHostSerializer & m_serializer
Definition: GreetHandler.h:20
InterlocDataHandlerTask(const char *taskName, UBaseType_t priority)
Definition: Main.cpp:355
ILogger & m_logger
Definition: Main.cpp:63
void logDump(LogLevel logLevel) override
Logs the virtual machine state, stack, heap and table segments.
Definition: BittyBuzzVm.cpp:78
Manages the user interface The user interface can consist of buttons, LED, serial print ports,...
Definition: IUserInterface.h:36
commInterfaceGetter m_commInterfaceGetter
Definition: Main.cpp:259
Definition: IGreetHandler.h:4
virtual void handshake(bool handshaked)=0
Sets the handshake status of the device.
Definition: MessageSender.h:10
DeviceStateUI & getDeviceStateUI()
get the device state UI
Definition: ApplicationInterfaceContainer.cpp:28
BittyBuzzVm m_bittybuzzVm
Definition: Main.cpp:68
IDeviceStateUI & m_deviceStateUI
Definition: Main.cpp:64
Logger(LogLevel level, IUserInterface &ui)
Definition: Logger.cpp:6
INotificationQueue< MessageDTO > & m_streamQueue
Definition: Main.cpp:212
DeviceState
Definition: SystemStates.h:6
~MessageSenderTask() override=default
void task() override
Definition: Main.cpp:342
bool m_keepRunning
Definition: Main.cpp:215
UserUI & getUserUI()
get the UI available to the user
Definition: ApplicationInterfaceContainer.cpp:43
void task() override
Definition: Main.cpp:326
bbzvm_error getError() const override
Get the error state of the VM.
Definition: BittyBuzzVm.cpp:124
Definition: LoggerContainer.h:6
RemoteHandshakeUI & getRemoteHandshakeUI()
get the remote handshake UI
Definition: ApplicationInterfaceContainer.cpp:38
IInterlocMessageHandler & m_interlocMessageHandler
Definition: Main.cpp:340
ICommInterface * m_stream
Definition: Main.cpp:211