Axeda Corp
/
AxedaGo-ubloxC027
Axeda demo software for u-blox C027 (GSM)
AMMP/axTransport.cpp@1:ff6d8adaf6b9, 2014-08-11 (annotated)
- Committer:
- AxedaCorp
- Date:
- Mon Aug 11 19:07:20 2014 +0000
- Revision:
- 1:ff6d8adaf6b9
- Parent:
- 0:a725e8eab383
Pointed to platform (prod)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AxedaCorp | 0:a725e8eab383 | 1 | |
AxedaCorp | 0:a725e8eab383 | 2 | #include "axTransport.h" |
AxedaCorp | 0:a725e8eab383 | 3 | #include <stdio.h> |
AxedaCorp | 0:a725e8eab383 | 4 | #include <stdlib.h> |
AxedaCorp | 0:a725e8eab383 | 5 | #include <string.h> |
AxedaCorp | 0:a725e8eab383 | 6 | #include "MDM.h" |
AxedaCorp | 0:a725e8eab383 | 7 | #include "axStatusCodes.h" |
AxedaCorp | 0:a725e8eab383 | 8 | #include "axConstants.h" |
AxedaCorp | 0:a725e8eab383 | 9 | #include <math.h> |
AxedaCorp | 0:a725e8eab383 | 10 | |
AxedaCorp | 0:a725e8eab383 | 11 | |
AxedaCorp | 0:a725e8eab383 | 12 | MDMSerial* mdm; |
AxedaCorp | 0:a725e8eab383 | 13 | int socket; |
AxedaCorp | 0:a725e8eab383 | 14 | char *temp_buff; |
AxedaCorp | 0:a725e8eab383 | 15 | int buff_size; |
AxedaCorp | 0:a725e8eab383 | 16 | |
AxedaCorp | 0:a725e8eab383 | 17 | |
AxedaCorp | 0:a725e8eab383 | 18 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 19 | /*getEpoch() */ |
AxedaCorp | 0:a725e8eab383 | 20 | /* */ |
AxedaCorp | 0:a725e8eab383 | 21 | /*This method should return the number of seconds since January 1st 1970. */ |
AxedaCorp | 0:a725e8eab383 | 22 | /* */ |
AxedaCorp | 0:a725e8eab383 | 23 | /*returns long value in seconds */ |
AxedaCorp | 0:a725e8eab383 | 24 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 25 | |
AxedaCorp | 0:a725e8eab383 | 26 | long getEpoch() |
AxedaCorp | 0:a725e8eab383 | 27 | { |
AxedaCorp | 0:a725e8eab383 | 28 | return (long)0; |
AxedaCorp | 0:a725e8eab383 | 29 | } |
AxedaCorp | 0:a725e8eab383 | 30 | |
AxedaCorp | 0:a725e8eab383 | 31 | |
AxedaCorp | 0:a725e8eab383 | 32 | /**************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 33 | /*ax_print() */ |
AxedaCorp | 0:a725e8eab383 | 34 | /* */ |
AxedaCorp | 0:a725e8eab383 | 35 | /*A wrapper method that will allow you to direct the output to a particular stream. Most of the */ |
AxedaCorp | 0:a725e8eab383 | 36 | /*time the output will just go to printf/std. out. This is called by the axAgent library to print*/ |
AxedaCorp | 0:a725e8eab383 | 37 | /*error and debug messages. It is reccomended to include processing for the integers AX_DEBUG_MSG*/ |
AxedaCorp | 0:a725e8eab383 | 38 | /*and AX_ERROR_MSG as the library will frequently use these options if configured. */ |
AxedaCorp | 0:a725e8eab383 | 39 | /* */ |
AxedaCorp | 0:a725e8eab383 | 40 | /* msgType: allows for an integer value to control how the data is displayed or written */ |
AxedaCorp | 0:a725e8eab383 | 41 | /* msg: a pointer to a string containing the data to be printed */ |
AxedaCorp | 0:a725e8eab383 | 42 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 43 | void ax_print(int msgType, char *msg) |
AxedaCorp | 0:a725e8eab383 | 44 | { |
AxedaCorp | 0:a725e8eab383 | 45 | switch(msgType) { |
AxedaCorp | 0:a725e8eab383 | 46 | case AX_DEBUG_MSG: |
AxedaCorp | 0:a725e8eab383 | 47 | printf("DEBUG: %s\r\n", msg); |
AxedaCorp | 0:a725e8eab383 | 48 | break; |
AxedaCorp | 0:a725e8eab383 | 49 | case AX_ERROR_MSG: |
AxedaCorp | 0:a725e8eab383 | 50 | printf("ERR: %s\r\n", msg); |
AxedaCorp | 0:a725e8eab383 | 51 | break; |
AxedaCorp | 0:a725e8eab383 | 52 | } |
AxedaCorp | 0:a725e8eab383 | 53 | |
AxedaCorp | 0:a725e8eab383 | 54 | } |
AxedaCorp | 0:a725e8eab383 | 55 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 56 | /*sys_delay() */ |
AxedaCorp | 0:a725e8eab383 | 57 | /* */ |
AxedaCorp | 0:a725e8eab383 | 58 | /*A wrapper method that is meant to induce a delay on the system that it running it. Used mostly*/ |
AxedaCorp | 0:a725e8eab383 | 59 | /*to implement timeouts. */ |
AxedaCorp | 0:a725e8eab383 | 60 | /* */ |
AxedaCorp | 0:a725e8eab383 | 61 | /* */ |
AxedaCorp | 0:a725e8eab383 | 62 | /* */ |
AxedaCorp | 0:a725e8eab383 | 63 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 64 | void sys_delay(int seconds) |
AxedaCorp | 0:a725e8eab383 | 65 | { |
AxedaCorp | 0:a725e8eab383 | 66 | wait_ms(seconds*1000); |
AxedaCorp | 0:a725e8eab383 | 67 | } |
AxedaCorp | 0:a725e8eab383 | 68 | |
AxedaCorp | 0:a725e8eab383 | 69 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 70 | /*randInt() */ |
AxedaCorp | 0:a725e8eab383 | 71 | /* */ |
AxedaCorp | 0:a725e8eab383 | 72 | /*This function is an abstraction function and should be populated with a call to the host's */ |
AxedaCorp | 0:a725e8eab383 | 73 | /*equivalent of the random function. */ |
AxedaCorp | 0:a725e8eab383 | 74 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 75 | int randInt() |
AxedaCorp | 0:a725e8eab383 | 76 | { |
AxedaCorp | 0:a725e8eab383 | 77 | //call to the local create random method. |
AxedaCorp | 0:a725e8eab383 | 78 | return rand(); |
AxedaCorp | 0:a725e8eab383 | 79 | } |
AxedaCorp | 0:a725e8eab383 | 80 | |
AxedaCorp | 0:a725e8eab383 | 81 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 82 | /*seedRand() */ |
AxedaCorp | 0:a725e8eab383 | 83 | /* */ |
AxedaCorp | 0:a725e8eab383 | 84 | /*This function is an abstraction function and should be populated with a call to the host's */ |
AxedaCorp | 0:a725e8eab383 | 85 | /*equivalent of the function that seeds the random number generator */ |
AxedaCorp | 0:a725e8eab383 | 86 | /************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 87 | |
AxedaCorp | 0:a725e8eab383 | 88 | int seedRand() |
AxedaCorp | 0:a725e8eab383 | 89 | { |
AxedaCorp | 0:a725e8eab383 | 90 | srand(12345); |
AxedaCorp | 0:a725e8eab383 | 91 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 92 | } |
AxedaCorp | 0:a725e8eab383 | 93 | |
AxedaCorp | 0:a725e8eab383 | 94 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 95 | /*net_socketInit() */ |
AxedaCorp | 0:a725e8eab383 | 96 | /* */ |
AxedaCorp | 0:a725e8eab383 | 97 | /*This method provides a convenient way to call code that initializes the socket before it is */ |
AxedaCorp | 0:a725e8eab383 | 98 | /*actually called to open. For example, it could initialize a holder object that you code or set */ |
AxedaCorp | 0:a725e8eab383 | 99 | /*options on the socket itself. The return will be a code that could be passed up through the */ |
AxedaCorp | 0:a725e8eab383 | 100 | /*HTTP library and to the error stream. */ |
AxedaCorp | 0:a725e8eab383 | 101 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 102 | int net_socketInit(ax_socket *sock) |
AxedaCorp | 0:a725e8eab383 | 103 | { |
AxedaCorp | 0:a725e8eab383 | 104 | int retVal=AX_UNKNOWN; |
AxedaCorp | 0:a725e8eab383 | 105 | buff_size=0; |
AxedaCorp | 0:a725e8eab383 | 106 | temp_buff=NULL; |
AxedaCorp | 0:a725e8eab383 | 107 | return retVal; |
AxedaCorp | 0:a725e8eab383 | 108 | } |
AxedaCorp | 0:a725e8eab383 | 109 | |
AxedaCorp | 0:a725e8eab383 | 110 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 111 | /*net_socketOpen() */ |
AxedaCorp | 0:a725e8eab383 | 112 | /* */ |
AxedaCorp | 0:a725e8eab383 | 113 | /*This function opens a network port and connects to it. The connection point is defined by server*/ |
AxedaCorp | 0:a725e8eab383 | 114 | /*and port in the arguments. A reference to the port should be stored in the sock structure. If */ |
AxedaCorp | 0:a725e8eab383 | 115 | /*the secure flag is set to AX_TRUE your code should enable TLS or SSL at this stage. */ |
AxedaCorp | 0:a725e8eab383 | 116 | /* */ |
AxedaCorp | 0:a725e8eab383 | 117 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 118 | int net_socketOpen(ax_socket *sock, char *server, int port, int secure) |
AxedaCorp | 0:a725e8eab383 | 119 | { |
AxedaCorp | 0:a725e8eab383 | 120 | int retVal=AX_UNKNOWN; |
AxedaCorp | 0:a725e8eab383 | 121 | const char* host = server; |
AxedaCorp | 0:a725e8eab383 | 122 | mdm = MDMSerial::getMDMInstance(); |
AxedaCorp | 0:a725e8eab383 | 123 | socket = mdm->socketSocket(MDMParser::IPPROTO_TCP); |
AxedaCorp | 0:a725e8eab383 | 124 | if (socket >= 0) { |
AxedaCorp | 0:a725e8eab383 | 125 | mdm->socketSetBlocking(socket, 5000); |
AxedaCorp | 0:a725e8eab383 | 126 | mdm->socketConnect(socket, host, port); |
AxedaCorp | 0:a725e8eab383 | 127 | retVal=AX_OK; |
AxedaCorp | 0:a725e8eab383 | 128 | } else { |
AxedaCorp | 0:a725e8eab383 | 129 | retVal=AX_NET_ERR_UNABLE_TO_CONNECT; |
AxedaCorp | 0:a725e8eab383 | 130 | } |
AxedaCorp | 0:a725e8eab383 | 131 | |
AxedaCorp | 0:a725e8eab383 | 132 | return retVal; |
AxedaCorp | 0:a725e8eab383 | 133 | } |
AxedaCorp | 0:a725e8eab383 | 134 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 135 | /*net_socketWrite() */ |
AxedaCorp | 0:a725e8eab383 | 136 | /* */ |
AxedaCorp | 0:a725e8eab383 | 137 | /*This function is used to write the data to a network port that has already been open and is */ |
AxedaCorp | 0:a725e8eab383 | 138 | /*connected. As usual the ax_socket struct should contain a reference to your port that you wish */ |
AxedaCorp | 0:a725e8eab383 | 139 | /*to write to. Data contains the data to be written and size describes how long the data is. */ |
AxedaCorp | 0:a725e8eab383 | 140 | /* */ |
AxedaCorp | 0:a725e8eab383 | 141 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 142 | int net_socketWrite(ax_socket *sock, char *data, int size) |
AxedaCorp | 0:a725e8eab383 | 143 | { |
AxedaCorp | 0:a725e8eab383 | 144 | int retVal=AX_OK; |
AxedaCorp | 0:a725e8eab383 | 145 | int fullsz=size+1; |
AxedaCorp | 0:a725e8eab383 | 146 | if(buff_size==0) { |
AxedaCorp | 0:a725e8eab383 | 147 | temp_buff=(char *)calloc(fullsz, sizeof(char)); |
AxedaCorp | 0:a725e8eab383 | 148 | int wrt=snprintf(temp_buff, fullsz, "%s", data); |
AxedaCorp | 0:a725e8eab383 | 149 | buff_size++; |
AxedaCorp | 0:a725e8eab383 | 150 | } else { |
AxedaCorp | 0:a725e8eab383 | 151 | int total=strlen(temp_buff)+fullsz; |
AxedaCorp | 0:a725e8eab383 | 152 | char *temp=(char *)calloc(total, sizeof(char)); |
AxedaCorp | 0:a725e8eab383 | 153 | snprintf(temp, total, "%s%s", temp_buff, data); |
AxedaCorp | 0:a725e8eab383 | 154 | free(temp_buff); |
AxedaCorp | 0:a725e8eab383 | 155 | temp_buff=temp; |
AxedaCorp | 0:a725e8eab383 | 156 | buff_size++; |
AxedaCorp | 0:a725e8eab383 | 157 | } |
AxedaCorp | 0:a725e8eab383 | 158 | return retVal; |
AxedaCorp | 0:a725e8eab383 | 159 | } |
AxedaCorp | 0:a725e8eab383 | 160 | |
AxedaCorp | 0:a725e8eab383 | 161 | |
AxedaCorp | 0:a725e8eab383 | 162 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 163 | /*net_socketFlush() */ |
AxedaCorp | 0:a725e8eab383 | 164 | /* */ |
AxedaCorp | 0:a725e8eab383 | 165 | /*This function will be called to handle writing all the data out to a network port. This function*/ |
AxedaCorp | 0:a725e8eab383 | 166 | /*may not be needed depending on your system. The single argument is a pointer to a struct that */ |
AxedaCorp | 0:a725e8eab383 | 167 | /*should contain the necessary references to the port on your local system. */ |
AxedaCorp | 0:a725e8eab383 | 168 | /* */ |
AxedaCorp | 0:a725e8eab383 | 169 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 170 | int net_socketFlush(ax_socket *sock) |
AxedaCorp | 0:a725e8eab383 | 171 | { |
AxedaCorp | 0:a725e8eab383 | 172 | int retVal=AX_UNKNOWN; |
AxedaCorp | 0:a725e8eab383 | 173 | int size=strlen(temp_buff); |
AxedaCorp | 0:a725e8eab383 | 174 | retVal = mdm->socketSend(socket, temp_buff, size); //Wr |
AxedaCorp | 0:a725e8eab383 | 175 | free(temp_buff); |
AxedaCorp | 0:a725e8eab383 | 176 | buff_size=0; |
AxedaCorp | 0:a725e8eab383 | 177 | return retVal; |
AxedaCorp | 0:a725e8eab383 | 178 | } |
AxedaCorp | 0:a725e8eab383 | 179 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 180 | /*net_socketClose() */ |
AxedaCorp | 0:a725e8eab383 | 181 | /* */ |
AxedaCorp | 0:a725e8eab383 | 182 | /*This function will be called to handle a socket close operation. It is used primarily by the */ |
AxedaCorp | 0:a725e8eab383 | 183 | /*axHTTP part of the library. The single argument is pointer to a structure that should contain */ |
AxedaCorp | 0:a725e8eab383 | 184 | /*the necessary references to the port on your local system. */ |
AxedaCorp | 0:a725e8eab383 | 185 | /*Override the source in this function to close a network port */ |
AxedaCorp | 0:a725e8eab383 | 186 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 187 | int net_socketClose(ax_socket *sock) |
AxedaCorp | 0:a725e8eab383 | 188 | { |
AxedaCorp | 0:a725e8eab383 | 189 | |
AxedaCorp | 0:a725e8eab383 | 190 | mdm->socketClose(socket); |
AxedaCorp | 0:a725e8eab383 | 191 | mdm->socketFree(socket); |
AxedaCorp | 0:a725e8eab383 | 192 | |
AxedaCorp | 0:a725e8eab383 | 193 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 194 | } |
AxedaCorp | 0:a725e8eab383 | 195 | |
AxedaCorp | 0:a725e8eab383 | 196 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 197 | /*net_socketRead() */ |
AxedaCorp | 0:a725e8eab383 | 198 | /* */ |
AxedaCorp | 0:a725e8eab383 | 199 | /*This function is a wrapper function that will read returned data from a previous web call. It */ |
AxedaCorp | 0:a725e8eab383 | 200 | /*is assumed that any connection related to ax_socket will have already been established. The */ |
AxedaCorp | 0:a725e8eab383 | 201 | /*function should read the data and store it into the *data pointer, then populate the number of */ |
AxedaCorp | 0:a725e8eab383 | 202 | /*bytes read in the size variable. The axHTTP library will handle parsing and making sense of the*/ |
AxedaCorp | 0:a725e8eab383 | 203 | /*data that it is provided. The timeout will be passed as a parameter but is not implemented by */ |
AxedaCorp | 0:a725e8eab383 | 204 | /*any of the calling libraries, implement it here or pass to another local function if available.*/ |
AxedaCorp | 0:a725e8eab383 | 205 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 206 | int net_socketRead(ax_socket *sock, int timeout, unsigned char *buffer, int bufferSz, int *readSz) |
AxedaCorp | 0:a725e8eab383 | 207 | { |
AxedaCorp | 0:a725e8eab383 | 208 | int retVal=AX_UNKNOWN; |
AxedaCorp | 0:a725e8eab383 | 209 | retVal = mdm->socketRecv(socket, (char*)buffer, bufferSz); |
AxedaCorp | 0:a725e8eab383 | 210 | readSz = &retVal; |
AxedaCorp | 0:a725e8eab383 | 211 | retVal=AX_OK; |
AxedaCorp | 0:a725e8eab383 | 212 | return retVal; |
AxedaCorp | 0:a725e8eab383 | 213 | } |
AxedaCorp | 0:a725e8eab383 | 214 | |
AxedaCorp | 0:a725e8eab383 | 215 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 216 | /*scm_download_req() */ |
AxedaCorp | 0:a725e8eab383 | 217 | /* */ |
AxedaCorp | 0:a725e8eab383 | 218 | /*This function will be called whenever an egress message is recieved with a file download command*/ |
AxedaCorp | 0:a725e8eab383 | 219 | /*You can write the code in the function to handle the file immediately OR store the structure for*/ |
AxedaCorp | 0:a725e8eab383 | 220 | /*later processing. The latter is preferable as this request may prevent the network port from */ |
AxedaCorp | 0:a725e8eab383 | 221 | /*being closed in a timely fashion. */ |
AxedaCorp | 0:a725e8eab383 | 222 | /* */ |
AxedaCorp | 0:a725e8eab383 | 223 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 224 | int scm_download_req(ax_package *request) |
AxedaCorp | 0:a725e8eab383 | 225 | { |
AxedaCorp | 0:a725e8eab383 | 226 | |
AxedaCorp | 0:a725e8eab383 | 227 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 228 | } |
AxedaCorp | 0:a725e8eab383 | 229 | |
AxedaCorp | 0:a725e8eab383 | 230 | |
AxedaCorp | 0:a725e8eab383 | 231 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 232 | /*scm_file_write() */ |
AxedaCorp | 0:a725e8eab383 | 233 | /* */ |
AxedaCorp | 0:a725e8eab383 | 234 | /*This function will be called whenever a file download is requested from the system. Override the*/ |
AxedaCorp | 0:a725e8eab383 | 235 | /*function to direct the output to serial or a file system or other storage device of your choice*/ |
AxedaCorp | 0:a725e8eab383 | 236 | /*The parameters to the function will be filled in when it's called by the toolkit */ |
AxedaCorp | 0:a725e8eab383 | 237 | /* */ |
AxedaCorp | 0:a725e8eab383 | 238 | /*char *filename: Just what it sounds like, the file name of the file */ |
AxedaCorp | 0:a725e8eab383 | 239 | /*char *data: The actual data of the file. */ |
AxedaCorp | 0:a725e8eab383 | 240 | /*int length: The number of bytes received */ |
AxedaCorp | 0:a725e8eab383 | 241 | /*ax_package_instruction *downloadInfo: a struct containing filename/path etc. */ |
AxedaCorp | 0:a725e8eab383 | 242 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 243 | int scm_file_write(char *filename, char *data, int length, ax_package_instruction *downloadInfo) |
AxedaCorp | 0:a725e8eab383 | 244 | { |
AxedaCorp | 0:a725e8eab383 | 245 | |
AxedaCorp | 0:a725e8eab383 | 246 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 247 | } |
AxedaCorp | 0:a725e8eab383 | 248 | |
AxedaCorp | 0:a725e8eab383 | 249 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 250 | /*data_item_write() */ |
AxedaCorp | 0:a725e8eab383 | 251 | /* */ |
AxedaCorp | 0:a725e8eab383 | 252 | /*If a set data item command is recieved from the platform server this function will be called to*/ |
AxedaCorp | 0:a725e8eab383 | 253 | /*handle it each time. The function is here to allow for external data to be modified as needed. */ |
AxedaCorp | 0:a725e8eab383 | 254 | /*It could toggle a pin and light up an led or set a global variable in another thread. */ |
AxedaCorp | 0:a725e8eab383 | 255 | /* */ |
AxedaCorp | 0:a725e8eab383 | 256 | /*char *name: The name of the data item on the platform */ |
AxedaCorp | 0:a725e8eab383 | 257 | /*int ax_type: {AX_STRING|AX_ANALoG|AX_DIGITAL} indicates whether the sValue or dValue parameter */ |
AxedaCorp | 0:a725e8eab383 | 258 | /* will have the intended data. */ |
AxedaCorp | 0:a725e8eab383 | 259 | /*char *sValue: if ax_type==AX_STRING then this will be a pointer to a valid cstring */ |
AxedaCorp | 0:a725e8eab383 | 260 | /*int dValue: if ax_type==AX_ANLOG|AX_DIGITAL this value will be populated. It should be not be */ |
AxedaCorp | 0:a725e8eab383 | 261 | /* checked if the type is AX_STRING */ |
AxedaCorp | 0:a725e8eab383 | 262 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 263 | int data_item_write(char *name, char *sValue, int dValue, int ax_type) |
AxedaCorp | 0:a725e8eab383 | 264 | { |
AxedaCorp | 0:a725e8eab383 | 265 | /* |
AxedaCorp | 0:a725e8eab383 | 266 | //these variables are declared in main.cpp |
AxedaCorp | 0:a725e8eab383 | 267 | extern int oil_level; |
AxedaCorp | 0:a725e8eab383 | 268 | extern int oil_level2; |
AxedaCorp | 0:a725e8eab383 | 269 | |
AxedaCorp | 0:a725e8eab383 | 270 | if (ax_type==AX_ANALOG) { |
AxedaCorp | 0:a725e8eab383 | 271 | if (strstr(name, "oil_level2")) |
AxedaCorp | 0:a725e8eab383 | 272 | printf("STATUS: Received data item from platform: OL1"); |
AxedaCorp | 0:a725e8eab383 | 273 | oil_level2=dValue; |
AxedaCorp | 0:a725e8eab383 | 274 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 275 | } else if (strstr(name, "oil_level")) { |
AxedaCorp | 0:a725e8eab383 | 276 | printf("STATUS: Received data item from platform: OL2"); |
AxedaCorp | 0:a725e8eab383 | 277 | oil_level=dValue; |
AxedaCorp | 0:a725e8eab383 | 278 | } |
AxedaCorp | 0:a725e8eab383 | 279 | */ |
AxedaCorp | 0:a725e8eab383 | 280 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 281 | } |
AxedaCorp | 0:a725e8eab383 | 282 | |
AxedaCorp | 0:a725e8eab383 | 283 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 284 | /*data_item_request() */ |
AxedaCorp | 0:a725e8eab383 | 285 | /* */ |
AxedaCorp | 0:a725e8eab383 | 286 | /*This function is called whenever the platform requests a data item's current value. Since this */ |
AxedaCorp | 0:a725e8eab383 | 287 | /*library is designed to run as it's own thread it does not maintain a list of data items and */ |
AxedaCorp | 0:a725e8eab383 | 288 | /*values. The implementation of this function should call an appropriate library or check an input*/ |
AxedaCorp | 0:a725e8eab383 | 289 | /*then create a dataItem set and send it immediately or on the next ping. */ |
AxedaCorp | 0:a725e8eab383 | 290 | /* */ |
AxedaCorp | 0:a725e8eab383 | 291 | /*char *name, the name of the data item being requested */ |
AxedaCorp | 0:a725e8eab383 | 292 | /* */ |
AxedaCorp | 0:a725e8eab383 | 293 | /*************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 294 | int data_item_request(char *name) |
AxedaCorp | 0:a725e8eab383 | 295 | { |
AxedaCorp | 0:a725e8eab383 | 296 | |
AxedaCorp | 0:a725e8eab383 | 297 | return AX_OK; |
AxedaCorp | 0:a725e8eab383 | 298 | } |
AxedaCorp | 0:a725e8eab383 | 299 | |
AxedaCorp | 0:a725e8eab383 | 300 | /***************************************************************************************************/ |
AxedaCorp | 0:a725e8eab383 | 301 | /***********************************************{Custom helper methods}****************************/ |