1 //******************************************************************
3 // Copyright 2015 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
24 * This API only works with:
30 #ifndef TELEGESISSOCKET_H_
31 #define TELEGESISSOCKET_H_
38 #include "plugininterface.h"
67 * Represents a single line within TWEntry struct.
76 * Represents a queue item. This is structure built after incoming data from the
77 * Telegesis adapter has put something in the buffer. A single TWEntry can contain 0+ TWLines.
79 typedef struct TWEntry
81 /** A pointer to the list of lines */
83 /** Number of lines in this entry. */
85 /** The type of entry. This maps with the leading tag of any given AT response/prompt. */
87 /** First two characters are an AT Error Code,
88 while third character is NULL terminator so it can be printed */
90 /** Any read, write, parsing, or system errors are captured in this generic resultCode. */
91 TWResultCode resultCode;
92 struct TWEntry * next; // Ignore; Used internally to manage the queue.
96 * Starts socket communication with the Telegesis Dongle at com location.
98 * @param plugin The plugin' scope which the socket ops will operate within.
100 * @param fileLoc The file descriptor location on the file system to start.
102 TWResultCode TWStartSock(PIPlugin * plugin, const char * fileLoc);
105 * Issues command to a specific Telegesis Dongle.
107 * @param plugin The plugin' scope which the command will be issued.
109 * @param command The command to be issued to the Telegesis Dongle.
111 TWResultCode TWIssueATCommand(PIPlugin * plugin, const char * command);
114 * Returns a response/prompt. If NULL, no response or prompts have been issued
115 * back by the Telegesis Dongle.
117 * @param plugin The plugin' scope which the socket is managed within.
119 * @param entry The line(s) which correspond to a single entry in the
120 * response/prompt queue. Returned by-reference.
122 * @param type The type of entry this queue item is. If not specified as TW_NONE,
123 * this API will block (for up to 5 Seconds) until an entry with the specified type
126 * @brief Its best to call this function in a loop. Break from loop when this
127 * function returns NULL. Otherwise, handle the data in TWEntry. Release
128 * memory allocated by this function by passing the entry into TWDeleteEntry.
130 TWResultCode TWDequeueEntry(PIPlugin * plugin, TWEntry ** entry, TWEntryType type);
133 * Helper function to deallocate memory of a TWEntry.
135 * Use this function when you are finished using the entry returned after
136 * calling TWDequeueLine. This will ensure your utilization of this API does
137 * not lead to memory leaks in your application.
139 * @param plugin The plugin' scope which the socket is managed within.
141 * @param entry The entry that was dequeued by calling TWDequeueLine.
143 TWResultCode TWDeleteEntry(PIPlugin * plugin, TWEntry * entry);
146 * Helper function to retrieve the current radio's EUI.
148 * @param plugin The plugin' scope which the socket is managed within.
150 * @param eui The local radio's EUI.
152 TWResultCode TWGetEUI(PIPlugin * plugin, char ** eui);
155 * Stops socket communication with the Telegesis Dongle within scope of plugin.
157 * @param plugin The plugin' scope the socket ops cease to operate within.
159 TWResultCode TWStopSock(PIPlugin * plugin);
163 #endif // __cplusplus
165 #endif /* TELEGESISSOCKET_H_ */