?? wireless_mote_api.m
字號(hào):
function result = wireless_mote_api(device,command,argument1,argument2);
%Wirless Mote Application Program Interface.
% RESULT = WIRELESS_MOTE_API(DEVICE,COMMAND,ARGUMENT1,ARGUMENT2);
%
% Input Parameters:
% ================
%
% device ------------> Wireless mote device (string):
% 'CC2420DB': Chipcon CC2420DB wireless mote.
% command -----------> API function (string):
% 'open' - Open communications session.
% 'init' - Initialize wireless mote.
% 'recv' - Receive MAC packet.
% 'send' - Transmit MAC packet.
% 'close' - Close communications session.
% argument1 ---------> API function argument for
% 'open' - Communications port (string).
% 'init' - Device handle (positive integer).
% 'recv' - Device handle (positive integer).
% 'send' - Device handle (positive integer).
% 'close' - Device handle (positive integer).
% argument2 ---------> API function argument for
% 'open' - None.
% 'init' - PHY information (PhyInfo structure).
% 'recv' - None.
% 'send' - MAC transmit packet (TxMacPckt structure).
% 'close' - None.
%
% Output Parameters:
% =================
%
% result ------------> API function result for
% 'open' - Device handle (positive integer).
% 'init' - Success status (-1 = error, +1 = success).
% 'recv' - MAC receive packet (RxMacPckt structure),
% -1 if packet receive buffer empty.
% 'send' - Success status (-1 = error, +1 = success).
% 'close' - Success status (-1 = error, +1 = success).
%
% Data Structures:
% ===============
%
% PhyInfo -----------> PHY layer information containing entries
% Channel - Transceiver ISM channel (integer).
% Address - Mote's node address (integer).
% PanID - Personal Area Network (PAN) ID (integer).
% RxMacPckt ---------> MAC receive packet containing entries
% seqNumber - Sequence number (integer).
% scrAddr - Source address (integer).
% scrPanId - Source PAN ID (integer).
% length - Payload length in bytes (positive integer).
% pPayload - Payload (1xlength vector).
% ackRequest - Acknowledge request (0 = no, 1 = yes).
% rssi - Received signal strength indicator (integer).
% TxMacPckt ---------> MAC transmit packet containing entries
% destAddr - Destination address (integer).
% destPanId - Destination PAN ID (integer).
% length - Payload length in bytes (positive integer).
% pPayload - Payload (1xlength vector).
% ackRequest - Acknowledge request (0 = no, 1 = yes).
%
% See also N/A.
% Stephan Hengstler
% Stanford Wireless Sensor Networks Lab
% February 19, 2005
%
% Last modified: 02-21-2005
%********************** Wireless Mote Application Program Interface ***********************
% include device libraries in path
addpath cc2420db_library -end
%--- Section: Global Variables ------------------------------------------------------------
global handle; % device handle
global PORT; % communications port
global reg; % register structure
global PhyInfo; % PHY information structure
global RxMacPckt; % receive MAC packet structure
global TxMacPckt; % transmit MAC packet structure
%--- Command: Open Communications Session -------------------------------------------------
if (~isempty(strmatch('open',command,'exact')))
% parse argument(s)
PORT = argument1;
% call device library function
if (~isempty(strmatch('CC2420DB',device,'exact')))
status = cc2420db_library(command);
end
% return result(s)
result = handle;
%--- Command: Initialize Wireless Mote ----------------------------------------------------
elseif (~isempty(strmatch('init',command,'exact')))
% parse argument(s)
handle = argument1;
PhyInfo = argument2;
% call device library function
if (~isempty(strmatch('CC2420DB',device,'exact')))
status = cc2420db_library(command);
end
% return result(s)
result = status;
%--- Command: Receive MAC Packet ----------------------------------------------------------
elseif (~isempty(strmatch('recv',command,'exact')))
% parse argument(s)
handle = argument1;
% call device library function
if (~isempty(strmatch('CC2420DB',device,'exact')))
status = cc2420db_library(command);
end
% return result(s)
result = RxMacPckt;
%--- Command: Send MAC Packet -------------------------------------------------------------
elseif (~isempty(strmatch('send',command,'exact')))
% parse argument(s)
handle = argument1;
TxMacPckt = argument2;
% call device library function
if (~isempty(strmatch('CC2420DB',device,'exact')))
status = cc2420db_library(command);
end
% return result(s)
result = status;
%--- Command: Close Communications Session ------------------------------------------------
elseif (~isempty(strmatch('close',command,'exact')))
% parse argument(s)
handle = argument1;
% call device library function
if (~isempty(strmatch('CC2420DB',device,'exact')))
status = cc2420db_library(command);
end
% return result(s)
result = status;
%--- Command: Undefined -------------------------------------------------------------------
else
% return result(s)
result = -1;
end
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -