Wiselib
wiselib.stable/external_interface/osa/osa_radio.h
Go to the documentation of this file.
00001 /***************************************************************************
00002  ** This file is part of the generic algorithm library Wiselib.           **
00003  ** Copyright (C) 2008,2009 by the Wisebed (www.wisebed.eu) project.      **
00004  **                                                                       **
00005  ** The Wiselib is free software: you can redistribute it and/or modify   **
00006  ** it under the terms of the GNU Lesser General Public License as        **
00007  ** published by the Free Software Foundation, either version 3 of the    **
00008  ** License, or (at your option) any later version.                       **
00009  **                                                                       **
00010  ** The Wiselib is distributed in the hope that it will be useful,        **
00011  ** but WITHOUT ANY WARRANTY; without even the implied warranty of        **
00012  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         **
00013  ** GNU Lesser General Public License for more details.                   **
00014  **                                                                       **
00015  ** You should have received a copy of the GNU Lesser General Public      **
00016  ** License along with the Wiselib.                                       **
00017  ** If not, see <http://www.gnu.org/licenses/>.                           **
00018  ***************************************************************************/
00019 #ifndef CONNECTOR_OSA_RADIOMODEL_H
00020 #define CONNECTOR_OSA_RADIOMODEL_H
00021 
00022 #include "external_interface/osa/osa_types.h"
00023 #include "util/delegates/delegate.hpp"
00024 #include <string.h>
00025 extern "C" {
00026 #include "opencom.h"
00027 #include "oc_bindinglistener.h"
00028 #include "interfaces/radio/iradio_int.h"
00029 #include "interfaces/hardware/ihardware_control.h"
00030 }
00031 
00032 namespace wiselib
00033 {
00034 
00035    typedef delegate3<void, TNodeID_Int, uint8_t, uint8_t*> osa_radio_delegate_t;
00036 
00045    template<typename OsModel_P>
00046    class OsaRadioModel
00047    {
00048    public:
00049       typedef OsModel_P OsModel;
00050 
00051       typedef OsaRadioModel<OsModel> self_type;
00052       typedef self_type* self_pointer_t;
00053 
00054       typedef TNodeID_Int node_id_t;
00055       typedef uint8_t     block_data_t;
00056       typedef uint8_t     size_t;
00057       typedef uint8_t     message_id_t;
00058 
00059       typedef osa_radio_delegate_t radio_delegate_t;
00060       // --------------------------------------------------------------------
00061       enum ErrorCodes
00062       {
00063          SUCCESS = OsModel::SUCCESS,
00064          ERR_UNSPEC = OsModel::ERR_UNSPEC,
00065          ERR_NOTIMPL = OsModel::ERR_NOTIMPL
00066       };
00067       // --------------------------------------------------------------------
00068       enum SpecialNodeIds {
00069          BROADCAST_ADDRESS = BROADCAST_INT, 
00070          NULL_NODE_ID      = -1             
00071       };
00072       // --------------------------------------------------------------------
00073       enum Restrictions {
00074          MAX_MESSAGE_LENGTH = 116           
00075       };
00076       // --------------------------------------------------------------------
00077       int send( node_id_t id, size_t len, block_data_t *data )
00078       {
00079          CALL(RECPS -> radio -> send, id, len, data);
00080          return SUCCESS;
00081       }
00082       // --------------------------------------------------------------------
00083       int enable_radio()
00084       {
00085          CALL( RECPS -> ihc -> enable );
00086          return SUCCESS;
00087       }
00088       // --------------------------------------------------------------------
00089       int disable_radio()
00090       {
00091          CALL( RECPS -> ihc -> disable );
00092          return SUCCESS;
00093       }
00094       // --------------------------------------------------------------------
00095       node_id_t id()
00096       {
00097          return CALL( RECPS -> radio -> get_id );
00098       }
00099       // --------------------------------------------------------------------
00100       template<class T, void (T::*TMethod)(node_id_t, size_t, block_data_t*)>
00101       int reg_recv_callback(T *obj_pnt )
00102       {
00103          return ERR_NOTIMPL;
00104       }
00105       // --------------------------------------------------------------------
00106       int unreg_recv_callback(int idx )
00107       {
00108          return ERR_NOTIMPL;
00109       }
00110    };
00111 }
00112 
00113 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines