A metronome using the FRDM K64F board

Committer:
ram54288
Date:
Sun May 14 18:40:18 2017 +0000
Revision:
0:a7a43371b306
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ram54288 0:a7a43371b306 1 #pragma once
ram54288 0:a7a43371b306 2
ram54288 0:a7a43371b306 3 #include "mbed-client/m2mdevice.h"
ram54288 0:a7a43371b306 4 #include "mbed-client/m2minterfacefactory.h"
ram54288 0:a7a43371b306 5 #include "mbed-client/m2minterface.h"
ram54288 0:a7a43371b306 6
ram54288 0:a7a43371b306 7 class frdm_client : public M2MInterfaceObserver
ram54288 0:a7a43371b306 8 {
ram54288 0:a7a43371b306 9 public:
ram54288 0:a7a43371b306 10 struct state
ram54288 0:a7a43371b306 11 {
ram54288 0:a7a43371b306 12 enum
ram54288 0:a7a43371b306 13 {
ram54288 0:a7a43371b306 14 initialized,
ram54288 0:a7a43371b306 15 boostrapped,
ram54288 0:a7a43371b306 16 registered,
ram54288 0:a7a43371b306 17 unregistered,
ram54288 0:a7a43371b306 18 error
ram54288 0:a7a43371b306 19 };
ram54288 0:a7a43371b306 20 };
ram54288 0:a7a43371b306 21
ram54288 0:a7a43371b306 22 public:
ram54288 0:a7a43371b306 23 static M2MDevice* make_device();
ram54288 0:a7a43371b306 24
ram54288 0:a7a43371b306 25 public:
ram54288 0:a7a43371b306 26 static const M2MInterface::NetworkStack stack_type = M2MInterface::LwIP_IPv4;
ram54288 0:a7a43371b306 27 static const M2MInterface::BindingMode socket_mode = M2MInterface::TCP;
ram54288 0:a7a43371b306 28
ram54288 0:a7a43371b306 29 public:
ram54288 0:a7a43371b306 30 frdm_client(const String& server_address, void* handler = NULL);
ram54288 0:a7a43371b306 31 ~frdm_client();
ram54288 0:a7a43371b306 32
ram54288 0:a7a43371b306 33 public:
ram54288 0:a7a43371b306 34 void connect(const M2MObjectList& objects);
ram54288 0:a7a43371b306 35 void disconnect();
ram54288 0:a7a43371b306 36
ram54288 0:a7a43371b306 37 virtual void bootstrap_done(M2MSecurity* security) { if (security) m_state = state::boostrapped; }
ram54288 0:a7a43371b306 38 virtual void object_registered(M2MSecurity*, const M2MServer&) { m_state = state::registered; }
ram54288 0:a7a43371b306 39 virtual void object_unregistered(M2MSecurity*) { m_state = state::unregistered; }
ram54288 0:a7a43371b306 40 virtual void registration_updated(M2MSecurity*, const M2MServer&) {}
ram54288 0:a7a43371b306 41 virtual void value_updated(M2MBase*, M2MBase::BaseType) {}
ram54288 0:a7a43371b306 42 virtual void error(M2MInterface::Error error) { m_state = state::error; }
ram54288 0:a7a43371b306 43
ram54288 0:a7a43371b306 44 int get_state() const { return m_state; }
ram54288 0:a7a43371b306 45 M2MSecurity* get_security() const { return m_security; }
ram54288 0:a7a43371b306 46
ram54288 0:a7a43371b306 47 private:
ram54288 0:a7a43371b306 48 String m_address;
ram54288 0:a7a43371b306 49 volatile int m_state;
ram54288 0:a7a43371b306 50
ram54288 0:a7a43371b306 51 M2MInterface* m_interface;
ram54288 0:a7a43371b306 52 M2MSecurity* m_security;
ram54288 0:a7a43371b306 53 };
ram54288 0:a7a43371b306 54