41 #define _CRT_SECURE_NO_DEPRECATE //do not use windows secure crt 49 #define __FILE_ID__ "cellular" 116 ,_linkQuality(LINKQUALITY_INVALID)
117 ,_cellOperator(CELLOPERATOR_INVALID)
118 ,_cellIdentifier(CELLIDENTIFIER_INVALID)
119 ,_cellType(CELLTYPE_INVALID)
121 ,_message(MESSAGE_INVALID)
123 ,_lockedOperator(LOCKEDOPERATOR_INVALID)
124 ,_airplaneMode(AIRPLANEMODE_INVALID)
125 ,_enableData(ENABLEDATA_INVALID)
127 ,_apnSecret(APNSECRET_INVALID)
128 ,_pingInterval(PINGINTERVAL_INVALID)
129 ,_dataSent(DATASENT_INVALID)
130 ,_dataReceived(DATARECEIVED_INVALID)
131 ,_command(COMMAND_INVALID)
132 ,_valueCallbackCellular(NULL)
157 if(json_val->
has(
"linkQuality")) {
160 if(json_val->
has(
"cellOperator")) {
163 if(json_val->
has(
"cellIdentifier")) {
166 if(json_val->
has(
"cellType")) {
169 if(json_val->
has(
"imsi")) {
172 if(json_val->
has(
"message")) {
175 if(json_val->
has(
"pin")) {
178 if(json_val->
has(
"lockedOperator")) {
181 if(json_val->
has(
"airplaneMode")) {
184 if(json_val->
has(
"enableData")) {
187 if(json_val->
has(
"apn")) {
190 if(json_val->
has(
"apnSecret")) {
193 if(json_val->
has(
"pingInterval")) {
196 if(json_val->
has(
"dataSent")) {
199 if(json_val->
has(
"dataReceived")) {
202 if(json_val->
has(
"command")) {
230 }
catch (std::exception) {
259 }
catch (std::exception) {
289 }
catch (std::exception) {
319 }
catch (std::exception) {
352 }
catch (std::exception) {
381 }
catch (std::exception) {
414 }
catch (std::exception) {
449 }
catch (std::exception) {
482 }
catch (std::exception) {
508 res =
_setAttr(
"lockedOperator", rest_val);
509 }
catch (std::exception) {
539 }
catch (std::exception) {
563 rest_val = (newval>0 ?
"1" :
"0");
564 res =
_setAttr(
"airplaneMode", rest_val);
565 }
catch (std::exception) {
596 }
catch (std::exception) {
625 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
626 res =
_setAttr(
"enableData", rest_val);
627 }
catch (std::exception) {
657 }
catch (std::exception) {
683 }
catch (std::exception) {
715 }
catch (std::exception) {
730 res =
_setAttr(
"apnSecret", rest_val);
731 }
catch (std::exception) {
760 }
catch (std::exception) {
783 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
784 res =
_setAttr(
"pingInterval", rest_val);
785 }
catch (std::exception) {
814 }
catch (std::exception) {
837 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
838 res =
_setAttr(
"dataSent", rest_val);
839 }
catch (std::exception) {
868 }
catch (std::exception) {
891 char buf[32]; sprintf(buf,
"%d", newval); rest_val = string(buf);
892 res =
_setAttr(
"dataReceived", rest_val);
893 }
catch (std::exception) {
915 }
catch (std::exception) {
930 res =
_setAttr(
"command", rest_val);
931 }
catch (std::exception) {
979 }
catch (std::exception) {
1001 if (callback != NULL) {
1008 if (callback != NULL && this->
isOnline()) {
1045 if (!((gsmMsg).substr(0, 13) ==
"Enter SIM PUK")) {
1114 cmdLen = (int)(cmd).length();
1116 while (chrPos >= 0) {
1117 cmd =
YapiWrapper::ysprintf(
"%s%c23%s", (cmd).substr( 0, chrPos).c_str(), 37,(cmd).substr( chrPos+1, cmdLen-chrPos-1).c_str());
1118 cmdLen = cmdLen + 2;
1122 while (chrPos >= 0) {
1123 cmd =
YapiWrapper::ysprintf(
"%s%c2B%s", (cmd).substr( 0, chrPos).c_str(), 37,(cmd).substr( chrPos+1, cmdLen-chrPos-1).c_str());
1124 cmdLen = cmdLen + 2;
1128 while (chrPos >= 0) {
1129 cmd =
YapiWrapper::ysprintf(
"%s%c3D%s", (cmd).substr( 0, chrPos).c_str(), 37,(cmd).substr( chrPos+1, cmdLen-chrPos-1).c_str());
1130 cmdLen = cmdLen + 2;
1137 while (waitMore > 0) {
1139 bufflen = (int)(buff).size();
1141 buffstrlen = (int)(buffstr).length();
1143 while ((idx > 0) && (((u8)buff[idx]) != 64) && (((u8)buff[idx]) != 10) && (((u8)buff[idx]) != 13)) {
1146 if (((u8)buff[idx]) == 64) {
1148 suffixlen = bufflen - idx;
1149 cmd =
YapiWrapper::ysprintf(
"at.txt?cmd=%s",(buffstr).substr( buffstrlen - suffixlen, suffixlen).c_str());
1150 buffstr = (buffstr).substr( 0, buffstrlen - suffixlen);
1151 waitMore = waitMore - 1;
1177 cops = this->
_AT(
"+COPS=?");
1178 slen = (int)(cops).length();
1182 slen = slen - (idx+1);
1183 cops = (cops).substr( idx+1, slen);
1186 slen = slen - (idx+1);
1187 cops = (cops).substr( idx+1, slen);
1190 res.push_back((cops).substr( 0, idx));
1209 vector<string> recs;
1222 vector<YCellRecord> res;
1224 moni = this->
_AT(
"+CCED=0;#MONI=7;#MONI");
1225 mccs = (moni).substr(7, 3);
1226 if ((mccs).substr(0, 1) ==
"0") {
1227 mccs = (mccs).substr(1, 2);
1229 if ((mccs).substr(0, 1) ==
"0") {
1230 mccs = (mccs).substr(1, 1);
1232 mcc = atoi((mccs).c_str());
1233 mncs = (moni).substr(11, 3);
1234 if ((mncs).substr(2, 1) ==
",") {
1235 mncs = (mncs).substr(0, 2);
1237 if ((mncs).substr(0, 1) ==
"0") {
1238 mncs = (mncs).substr(1, (
int)(mncs).length()-1);
1240 mnc = atoi((mncs).c_str());
1244 for (
unsigned ii = 0; ii < recs.size(); ii++) {
1245 llen = (int)(recs[ii]).length() - 2;
1247 if ((recs[ii]).substr(41, 3) ==
"dbm") {
1248 lac = (int)strtoul((recs[ii]).substr(16, 4).c_str(), NULL, 16);
1249 cellId = (int)strtoul((recs[ii]).substr(23, 4).c_str(), NULL, 16);
1250 dbms = (recs[ii]).substr(37, 4);
1251 if ((dbms).substr(0, 1) ==
" ") {
1252 dbms = (dbms).substr(1, 3);
1254 dbm = atoi((dbms).c_str());
1256 tads = (recs[ii]).substr(54, 2);
1257 if ((tads).substr(0, 1) ==
" ") {
1258 tads = (tads).substr(1, 3);
1260 tad = atoi((tads).c_str());
1261 oper = (recs[ii]).substr(66, llen-66);
1267 res.push_back(
YCellRecord(mcc,mnc,lac,cellId,dbm,tad,oper));
1287 vector<YFUN_DESCR> v_fundescr;
1289 string serial, funcId, funcName, funcVal, errmsg;
1292 v_fundescr.size() == 0 ||
int set_apn(const string &newval)
yCRITICAL_SECTION _this_cs
virtual int _invokeValueCallback(string value)
int set_apnSecret(const string &newval)
int set_dataReceived(int newval)
string get_apnSecret(void)
static YCellular * FirstCellular(void)
YRETCODE _load_unsafe(int msValidity)
static const Y_ENABLEDATA_enum ENABLEDATA_INVALID
YCellularValueCallback _valueCallbackCellular
static const string APNSECRET_INVALID
string get_cellOperator(void)
virtual int get_locationAreaCode(void)
virtual int get_cellId(void)
static int DefaultCacheValidity
string getString(const string &key)
string get_lockedOperator(void)
int set_pin(const string &newval)
int get_dataReceived(void)
int get_pingInterval(void)
int _ystrpos(const string &haystack, const string &needle)
void _throw(YRETCODE errType, string errMsg)
static const Y_CELLTYPE_enum CELLTYPE_INVALID
void yLeaveCriticalSection(yCRITICAL_SECTION *cs)
virtual int get_timingAdvance(void)
string _download(const string &url)
static YRETCODE getFunctionInfo(YFUN_DESCR fundesc, YDEV_DESCR &devdescr, string &serial, string &funcId, string &funcName, string &funcVal, string &errmsg)
int set_dataSent(int newval)
static YCellular * FindCellular(string func)
virtual string get_cellOperator(void)
#define YAPI_INVALID_STRING
int set_enableData(Y_ENABLEDATA_enum newval)
virtual int _parseAttr(YJSONObject *json_val)
virtual int get_mobileNetworkCode(void)
virtual int get_mobileCountryCode(void)
void(* YCellularValueCallback)(YCellular *func, const string &functionValue)
static const int DATARECEIVED_INVALID
int getInt(const string &key)
static const string LOCKEDOPERATOR_INVALID
static u64 GetTickCount(void)
static void _AddToCache(const string &classname, const string &func, YFunction *obj)
YCellular(const string &func)
virtual int clearDataCounters(void)
static const string MESSAGE_INVALID
string get_cellIdentifier(void)
vector< string > _strsplit(const string &str, char delimiter)
virtual int _parseAttr(YJSONObject *json_val)
static const string APN_INVALID
YCellular * nextCellular(void)
virtual string _AT(string cmd)
static YFunction * _FindFromCache(const string &classname, const string &func)
static const int LINKQUALITY_INVALID
int set_command(const string &newval)
static string ysprintf(const char *fmt,...)
int set_pingInterval(int newval)
int get_linkQuality(void)
static const string CELLIDENTIFIER_INVALID
void yEnterCriticalSection(yCRITICAL_SECTION *cs)
YCellRecord(int mcc, int mnc, int lac, int cellId, int dbm, int tad, const string &oper)
static yCRITICAL_SECTION _global_cs
static const string CELLOPERATOR_INVALID
Y_ENABLEDATA_enum get_enableData(void)
Y_ENABLEDATA_enum _enableData
static const string COMMAND_INVALID
static int getFunctionsByClass(const string &class_str, YFUN_DESCR prevfundesc, vector< YFUN_DESCR > &buffer, int maxsize, string &errmsg)
Y_CELLTYPE_enum _cellType
Y_AIRPLANEMODE_enum get_airplaneMode(void)
static const string IMSI_INVALID
static const Y_AIRPLANEMODE_enum AIRPLANEMODE_INVALID
virtual int sendPUK(string puk, string newPin)
int set_lockedOperator(const string &newval)
virtual int set_apnAuth(string username, string password)
int set_airplaneMode(Y_AIRPLANEMODE_enum newval)
Y_CELLTYPE_enum get_cellType(void)
virtual int registerValueCallback(YCellularValueCallback callback)
static bool _apiInitialized
Y_AIRPLANEMODE_enum _airplaneMode
YRETCODE _nextFunction(string &hwId)
virtual int get_signalStrength(void)
static const int DATASENT_INVALID
static void _UpdateValueCallbackList(YFunction *func, bool add)
static const int PINGINTERVAL_INVALID
bool has(const string &key)
YRETCODE _setAttr(string attrname, string newvalue)
static const string PIN_INVALID
virtual vector< string > get_availableOperators(void)
virtual int _invokeValueCallback(string value)
virtual vector< YCellRecord > quickCellSurvey(void)