;; -*- scheme -*- ; not really, but tells emacs how to format this
;;
;; Copyright 2007 Free Software Foundation, Inc.
;; 
;; This file is part of GNU Radio
;; 
;; GNU Radio is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; 
;; GNU Radio is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.
;; 
;; You should have received a copy of the GNU General Public License along
;; with this program; if not, write to the Free Software Foundation, Inc.,
;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
;;

;; ----------------------------------------------------------------
;;              This is an mblock header file
;;
;; The format is very much a work-in-progress.
;; It'll be compiled to C++.
;; ----------------------------------------------------------------

;; In the outgoing messages described below, invocation-handle is an
;; identifier provided by the client to tag the method invocation.
;; The identifier will be returned with the response, to provide the
;; client with a mechanism to match asynchronous responses with the
;; commands that generate them.  The value of the invocation-handle is
;; opaque the the server, and is not required by the server to be
;; unique.
;;
;; In the incoming messages described below, invocation-handle is the
;; identifier provided by the client in the prompting invocation.  The
;; identifier is returned with the response, so that the client has a
;; mechanism to match asynchronous responses with the commands that
;; generated them.
;;
;; status is either #t, indicating success, or a symbol indicating an error.
;; All symbol's names shall begin with %error-


;; ----------------------------------------------------------------
;; gmac-tx
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class gmac-tx

  (:outgoing

    ;; Transmitting packets can carry an invocation handle so the application
    ;; can get TX results on specific packets, such as whether a packet tagged
    ;; as #1 was successfully transmitted or not.  This would allow the
    ;; application to implement something sliding window like.
    ;;
    ;; 'dst' is the destination MAC address (given a MAC addressing scheme)
    ;;
    ;; 'data' will be treated transparently and passed on as samples.
    ;;
    ;; 'properties' can be used in the future to set per-packet options such as
    ;;   carrier sense overriding functionality.
    (cmd-tx-pkt invocation-handle dst data properties)

   )

  (:incoming

    ;; The response will carry the same invocation-handle passed with cmd-tx-pkt
    (response-tx-pkt invocation-handle status)

   )
  )

;; ----------------------------------------------------------------
;; gmac-rx
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)

(define-protocol-class gmac-rx

  (:outgoing
    
    ;; There are currently no outgoing commands, I believe that the RX
    ;; should always be enabled, there is no point in having an enable/disable
    ;; that I can see.
   
   )

  (:incoming

    ;; Contains packets decoded by the MAC destined for this machine, sent by
    ;; the specified address.
    (response-rx-pkt invocation-handle src data)

   )
  )


;; ----------------------------------------------------------------
;; gmac-cs
;;
;; The protocol class is defined from the client's point-of-view.
;; (The client port is unconjugated, the server port is conjugated.)
;;
;; This defines a control/status interface to the MAC layer, for control over
;; functionality such as carrier sense and future functionality such as channel
;; hopping.


(define-protocol-class gmac-cs

  (:outgoing

    ;; Threshold represents the carrier sense threshold based on the digital
    ;; reading out of the DAC.  If the threshold is set to PMT_NIL then the
    ;; MAC will use averaging to determine an appropriate threshold.
    (cmd-carrier-sense-enable invocation-handle threshold deadline)
    (cmd-carrier-sense-threshold invocation-handle threshold)
    (cmd-carrier-sense-disable invocation-handle)

    ;; Setting the number of fast transmission retries on a failure before
    ;; reporting a loss back to the application.
    (cmd-set-tx-retries invocation-handle retries)

   )

  (:incoming

    (response-gmac-initialized invocation-handle status)

    (response-carrier-sense-enable invocation-handle status)
    (response-carrier-sense-threshold invocation-handle status)
    (response-carrier-sense-deadline invocation-handle status)
    (response-carrier-sense-disable invocation-handle status)

    (response-set-tx-retries invocation-handle status)

   )
  )