Home | History | Annotate | Download | only in nos
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 #ifndef NOS_NUGGET_CLIENT_INTERFACE_H
     18 #define NOS_NUGGET_CLIENT_INTERFACE_H
     19 
     20 #include <cstdint>
     21 #include <vector>
     22 
     23 namespace nos {
     24 
     25 /**
     26  * Interface for communication with a Nugget device.
     27  */
     28 class NuggetClientInterface {
     29 public:
     30     virtual ~NuggetClientInterface() = default;
     31 
     32     /**
     33      * Opens a connection to the default Nugget device.
     34      *
     35      * If this fails, isOpen() will return false.
     36      */
     37     virtual void Open() = 0;
     38 
     39     /**
     40      * Closes the connection to Nugget.
     41      */
     42     virtual void Close() = 0;
     43 
     44     /**
     45      * Checked whether a connection is open to Nugget.
     46      */
     47     virtual bool IsOpen() const = 0;
     48 
     49     /**
     50      * Call into and app running on Nugget.
     51      *
     52      * @param app_id   The ID of the app to call.
     53      * @param arg      Argument to pass to the app.
     54      * @param request  Data to send to the app.
     55      * @param response Buffer to receive data from the app.
     56      * @return         Status code from the app.
     57      */
     58     virtual uint32_t CallApp(uint32_t appId, uint16_t arg,
     59                              const std::vector<uint8_t>& request,
     60                              std::vector<uint8_t>* response) = 0;
     61 };
     62 
     63 } // namespace nos
     64 
     65 #endif // NOS_NUGGET_CLIENT_INTERFACE_H
     66