Wiselib
wiselib.testing/external_interface/iphone/iPhoneRadioController.h
Go to the documentation of this file.
00001 //
00002 //  iPhoneRadioController.h
00003 //  Network
00004 //
00005 //  Created by Marcus on 21.12.10.
00006 //  Copyright 2010 __MyCompanyName__. All rights reserved.
00007 //
00008 
00009 #import <Foundation/Foundation.h>
00010 #include "util/delegates/delegate.hpp"
00011 
00012 #include "proto/Messages.pb.h"
00013 #include "proto/WSNAppMessages.pb.h"
00014 #include "util/wisebed_node_api/command_types.h"
00015 #include "util/iphone_node_api/iphone_link_message.h"
00016 
00017 #include "AsyncSocket/AsyncSocket.h"
00018 
00019 typedef uint16_t node_id_t;
00020 typedef uint8_t block_data_t;
00021 typedef uint8_t message_id_t;
00022 typedef __darwin_size_t size_t;
00023 
00024 typedef delegate3<void, node_id_t, size_t, block_data_t*> radio_delegate_t;
00025 
00026 using namespace de::uniluebeck::itm::tr::runtime::wsnapp;
00027 typedef de::uniluebeck::itm::gtr::messaging::Msg TestbedRuntimeMessage;
00028 typedef de::uniluebeck::itm::tr::runtime::wsnapp::Message Message;
00029 //typedef de::uniluebeck::itm::tr::runtime::wsnapp::Message_TextMessage TextMessage;
00030 //typedef de::uniluebeck::itm::tr::runtime::wsnapp::Message_BinaryMessage BinaryMessage;
00031    
00032 const std::string LISTENER_MESSAGE = "de.uniluebeck.itm.tr.runtime.wsnapp.WSNApp/LISTENER_MESSAGE";
00033 const std::string INVOCATION_REQUEST = "de.uniluebeck.itm.tr.runtime.wsnapp.WSNApp/OPERATION_INVOCATION_REQUEST";
00034 
00035 // Binary Message Type
00036 const int BIN_TYPE = 10;
00037 
00038 enum DECODER {
00039    SUCCESS = 0,
00040    ERROR_UNSPEC = -1,
00041    READ_HEADER = 100,
00042    READ_BODY = 101,
00043    HEADER_LENGTH = 4,
00044    TIME_OUT = 60,
00045    NO_TIME_OUT = -1
00046    
00047 };
00048 
00049 @interface iPhoneRadioController : NSObject<NSStreamDelegate> {
00050      
00051       AsyncSocket *asyncSocket_;      
00052       radio_delegate_t callback_;
00053       uint16_t radio_id_;
00054       
00055       NSString* url_;
00056       UInt16 port_;
00057 }
00058 
00059 - (int) enable;
00060 - (int) disable;
00061 - (int) sendTo: (node_id_t) dest_id withData: (block_data_t*) data withLenght: (size_t) len;
00062 - (void) registerReceiver: (radio_delegate_t) callback;
00063 - (void) fireDelegateWithData: (const uint8_t*)aBuffer lenght:(size_t)len from:(node_id_t)aFrom;
00064 - (node_id_t) getRadioId;
00065 - (void) setUrl:(NSString *)url andPort:(UInt16)port;
00066 
00067 @end
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines