source: rtos_arduino/trunk/arduino_lib/libraries/GSM/src/GSM3MobileMockupProvider.cpp@ 136

Last change on this file since 136 was 136, checked in by ertl-honda, 8 years ago

ライブラリとOS及びベーシックなサンプルの追加.

File size: 4.4 KB
Line 
1/*
2This file is part of the GSM3 communications library for Arduino
3-- Multi-transport communications platform
4-- Fully asynchronous
5-- Includes code for the Arduino-Telefonica GSM/GPRS Shield V1
6-- Voice calls
7-- SMS
8-- TCP/IP connections
9-- HTTP basic clients
10
11This library has been developed by Telefónica Digital - PDI -
12- Physical Internet Lab, as part as its collaboration with
13Arduino and the Open Hardware Community.
14
15September-December 2012
16
17This library is free software; you can redistribute it and/or
18modify it under the terms of the GNU Lesser General Public
19License as published by the Free Software Foundation; either
20version 2.1 of the License, or (at your option) any later version.
21
22This library is distributed in the hope that it will be useful,
23but WITHOUT ANY WARRANTY; without even the implied warranty of
24MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
25Lesser General Public License for more details.
26
27You should have received a copy of the GNU Lesser General Public
28License along with this library; if not, write to the Free Software
29Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30
31The latest version of this library can always be found at
32https://github.com/BlueVia/Official-Arduino
33*/
34#include <GSM3MobileNetworkProvider.h>
35#include <GSM3MobileMockupProvider.h>
36#include <inttypes.h>
37#include <HardwareSerial.h>
38#include <Arduino.h>
39
40
41GSM3MobileMockupProvider::GSM3MobileMockupProvider()
42{
43 lineStatus=IDLE;
44 msgExample="Hello#World";
45 msgIndex=0;
46};
47
48int GSM3MobileMockupProvider::begin(char* pin)
49{
50 Serial.println("GSM3MobileMockupProvider::begin()");
51 return 0;
52};
53
54int GSM3MobileMockupProvider::ready()
55{
56 Serial.println("GSM3MobileMockupProvider::ready()");
57 return 1;
58};
59
60int GSM3MobileMockupProvider::beginSMS(const char* number)
61{
62 Serial.println("SM3MobileMockupProvider::beginSMS()");
63 return 0;
64};
65
66void GSM3MobileMockupProvider::writeSMS(char c)
67{
68 Serial.print(c);
69};
70
71int GSM3MobileMockupProvider::endSMS()
72{
73 Serial.println("GSM3MobileMockupProvider::endSMS()");
74};
75
76int GSM3MobileMockupProvider::availableSMS()
77{
78 Serial.println("GSM3MobileMockupProvider::availableSMS()");
79 return 120;
80};
81
82int GSM3MobileMockupProvider::peek()
83{
84 return (int)'H';
85};
86
87int GSM3MobileMockupProvider::remoteSMSNumber(char* number, int nlength)
88{
89 if(nlength>=13)
90 strcpy(number, "+34630538546");
91 return 12;
92};
93
94
95void GSM3MobileMockupProvider::flushSMS()
96{
97 Serial.println("GSM3MobileMockupProvider::flushSMS()");
98};
99
100int GSM3MobileMockupProvider::readSMS()
101{
102 if(msgExample[msgIndex]==0)
103 {
104 msgIndex=0;
105 return 0;
106 }
107 else
108 {
109 msgIndex++;
110 return msgExample[msgIndex-1];
111 };
112};
113
114int GSM3MobileMockupProvider::connectTCPClient(const char* server, int port, int id_socket)
115{
116 Serial.println("GSM3MobileMockupProvider::connectTCPClient()");
117 Serial.print(server);Serial.print(":");Serial.print(port);Serial.print("-");Serial.println(id_socket);
118}
119
120void GSM3MobileMockupProvider::writeSocket(const uint8_t *buf, size_t size, int id_socket)
121{
122 int i;
123 for(i=0;i<size;i++)
124 Serial.print(buf[i]);
125}
126/* I'm taking this off. We'll reply from the NetworkProvider
127uint8_t GSM3MobileMockupProvider::getStatus(uint8_t socket)
128{
129 if((socket>=minSocket())&&(socket<=maxSocket()))
130 return 1;
131 else
132 return 0;
133};
134*/
135
136int GSM3MobileMockupProvider::readSocket(uint8_t *buf, size_t size, int idsocket)
137{
138 int i;
139 int l=strlen(msgExample);
140 for(i=0;(i<size)&&(i<l);i++)
141 buf[i]=msgExample[i];
142 buf[i]=0;
143 return i;
144}
145
146int GSM3MobileMockupProvider::availableSocket(int idsocket)
147{
148 return 1;
149};
150
151int GSM3MobileMockupProvider::readSocket(int idsocket, bool advance)
152{
153 char c;
154 if(msgExample[msgIndex]==0)
155 {
156 msgIndex=0;
157 return 0;
158 }
159 else
160 {
161 c=msgExample[msgIndex];
162 if(advance)
163 msgIndex++;
164 };
165 return c;
166};
167
168void GSM3MobileMockupProvider::flushSocket(int idsocket)
169{
170 while(readSocket(idsocket));
171};
172
173int GSM3MobileMockupProvider::disconnectTCP(int idsocket)
174{
175 Serial.println("GSM3MobileMockupProvider::disconnectTCP()");
176 return 1;
177};
178
179int GSM3MobileMockupProvider::connectTCPServer(int port, char* localIP, int* localIPlength)
180{
181 Serial.println("GSM3MobileMockupProvider::connectTCPServer()");
182 if((localIP!=0)&&(*localIPlength>12))
183 strcpy("192.168.1.1", localIP);
184 return 1;
185};
186
187bool GSM3MobileMockupProvider::getSocketModemStatus(uint8_t s)
188{
189 // Feeling lazy
190 return true;
191}
192
Note: See TracBrowser for help on using the repository browser.