C027_SupportTest_xively_locationで使用しているC027用ライブラリ

Fork of C027_Support by u-blox

下記のプログラムC027_SupportTest_xively_locationで使用しているC027用ライブラリです。

Import programC027_SupportTest_xively_location

インターフェース2014年10月号のu-blox C027で3G通信する記事で使用したプログラム。   CQ publishing Interface 2014.10 issue, C027 3G test program.

オリジナルのライブラリは下記を参照してください。

Import libraryC027_Support

support library for C027 helper functions for Buffer Pipes, Buffered Serial Port (rtos capable) and GPS parsing. It includes modem APIs for USSD, SMS and Sockets.

Committer:
mazgch
Date:
Fri May 09 17:49:32 2014 +0000
Revision:
49:8175b2b72d6b
Parent:
47:9a89e5195721
Child:
54:7ba8e4c218e2
remove debug

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mazgch 44:9d12223b78ff 1 #ifndef SOCKET_H_
mazgch 44:9d12223b78ff 2 #define SOCKET_H_
mazgch 44:9d12223b78ff 3
mazgch 44:9d12223b78ff 4 #include "MDM.h"
mazgch 44:9d12223b78ff 5
mazgch 44:9d12223b78ff 6 /** Socket file descriptor and select wrapper
mazgch 44:9d12223b78ff 7 */
mazgch 44:9d12223b78ff 8 class Socket {
mazgch 44:9d12223b78ff 9 public:
mazgch 44:9d12223b78ff 10 Socket() {
mazgch 44:9d12223b78ff 11 _socket = -1;
mazgch 47:9a89e5195721 12 _timeout = -1;
mazgch 44:9d12223b78ff 13 _mdm = MDMParser::getInstance();
mazgch 44:9d12223b78ff 14 if (_mdm == NULL) {
mazgch 44:9d12223b78ff 15 error("Socket constructor error: no modem instance available!\r\n");
mazgch 44:9d12223b78ff 16 }
mazgch 44:9d12223b78ff 17 }
mazgch 44:9d12223b78ff 18
mazgch 47:9a89e5195721 19 void set_blocking(bool blocking, unsigned int timeout=1) {
mazgch 47:9a89e5195721 20 _timeout = blocking ? (unsigned int) -1 /* blocking */ : timeout;
mazgch 47:9a89e5195721 21 if (_socket >= 0) {
mazgch 47:9a89e5195721 22 _mdm->socketSetBlocking(_socket, _timeout);
mazgch 47:9a89e5195721 23 }
mazgch 44:9d12223b78ff 24 }
mazgch 44:9d12223b78ff 25
mazgch 44:9d12223b78ff 26 int close() {
mazgch 44:9d12223b78ff 27 bool ret = false;
mazgch 44:9d12223b78ff 28 if (_socket >= 0)
mazgch 44:9d12223b78ff 29 {
mazgch 44:9d12223b78ff 30 ret = _mdm->socketClose(_socket);
mazgch 44:9d12223b78ff 31 _mdm->socketFree(_socket);
mazgch 44:9d12223b78ff 32 _socket = -1;
mazgch 44:9d12223b78ff 33 }
mazgch 44:9d12223b78ff 34 return ret ? 0 : -1;
mazgch 44:9d12223b78ff 35 }
mazgch 44:9d12223b78ff 36
mazgch 49:8175b2b72d6b 37 ~Socket() { close(); }
mazgch 44:9d12223b78ff 38
mazgch 44:9d12223b78ff 39 protected:
mazgch 44:9d12223b78ff 40 int _socket;
mazgch 47:9a89e5195721 41 int _timeout;
mazgch 44:9d12223b78ff 42 MDMParser* _mdm;
mazgch 44:9d12223b78ff 43 };
mazgch 44:9d12223b78ff 44
mazgch 44:9d12223b78ff 45
mazgch 44:9d12223b78ff 46 #endif /* SOCKET_H_ */