Ram Gandikota / Mbed OS ABCD
Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers frdm_client.hpp Source File

frdm_client.hpp

00001 #pragma once
00002 
00003 #include "mbed-client/m2mdevice.h"
00004 #include "mbed-client/m2minterfacefactory.h"
00005 #include "mbed-client/m2minterface.h"
00006 
00007 class frdm_client : public M2MInterfaceObserver
00008 {
00009 public:
00010     struct state
00011     {
00012         enum
00013         {
00014             initialized,
00015             boostrapped,
00016             registered,
00017             unregistered,
00018             error
00019         };
00020     };
00021 
00022 public:
00023     static M2MDevice* make_device();
00024 
00025 public:
00026     static const M2MInterface::NetworkStack stack_type = M2MInterface::LwIP_IPv4;
00027     static const M2MInterface::BindingMode socket_mode = M2MInterface::TCP;
00028 
00029 public:
00030     frdm_client(const String& server_address, void* handler = NULL);
00031     ~frdm_client();
00032 
00033 public:
00034     void connect(const M2MObjectList& objects);
00035     void disconnect();
00036 
00037     virtual void bootstrap_done(M2MSecurity* security) { if (security) m_state = state::boostrapped; }
00038     virtual void object_registered(M2MSecurity*, const M2MServer&) { m_state = state::registered; }
00039     virtual void object_unregistered(M2MSecurity*) { m_state = state::unregistered; }
00040     virtual void registration_updated(M2MSecurity*, const M2MServer&) {}
00041     virtual void value_updated(M2MBase*, M2MBase::BaseType) {}
00042     virtual void error(M2MInterface::Error error) { m_state = state::error; }
00043 
00044     int get_state() const { return m_state; }
00045     M2MSecurity* get_security() const { return m_security; }
00046 
00047 private:
00048     String m_address;
00049     volatile int m_state;
00050 
00051     M2MInterface* m_interface;
00052     M2MSecurity* m_security;
00053 };
00054