Ejemplo n.º 1
0
      void
      onResourceInitialization(void)
      {
        // Process micro-modem addresses.
        std::vector<std::string> addrs = m_ctx.config.options(m_args.addr_section);
        for (unsigned i = 0; i < addrs.size(); ++i)
        {
          unsigned mid = 0;
          m_ctx.config.get(m_args.addr_section, addrs[i], "0", mid);
          m_smap[addrs[i]] = mid;
          m_amap[mid] = addrs[i];
        }

        // Get modem address.
        std::string agent = getSystemName();
        m_ctx.config.get(m_args.addr_section, agent, "1024", m_addr);
        if (m_addr == 1024)
          throw std::runtime_error(String::str(DTR("modem address for agent '%s' is invalid"), agent.c_str()));

        // Set modem address.
        {
          configureModem("CCCFG", "SRC", m_addr);

          if (!consumeResult(RS_SRC_ACKD))
          {
            setAndSendState(STA_ERR_SRC);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set NRV parameter.
        {
          configureModem("CCCFG", "NRV", 0);

          if (!consumeResult(RS_NRV_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set CTO parameter.
        {
          configureModem("CCCFG", "CTO", c_cto);

          if (!consumeResult(RS_CTO_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set TAT parameter.
        {
          configureModem("CCCFG", "TAT", m_args.turn_around_time);

          if (!consumeResult(RS_TAT_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set XST parameter.
        {
          configureModem("CCCFG", "XST", 0);

          if (!consumeResult(RS_XST_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        if (m_lbl.empty())
          setAndSendState(STA_NO_BEACONS);
        else
          setAndSendState(STA_IDLE);
      }
Ejemplo n.º 2
0
      void
      onResourceInitialization(void)
      {
        // Get modem address.
        std::string agent = getSystemName();
        m_ctx.config.get(m_args.addr_section, agent, "1024", m_addr);
        if (m_addr == 1024)
          throw std::runtime_error(String::str(DTR("modem address for agent '%s' is invalid"), agent.c_str()));

        // Set modem address.
        {
          configureModem("CCCFG", "SRC", m_addr);

          if (!consumeResult(RS_SRC_ACKD))
          {
            setAndSendState(STA_ERR_SRC);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set NRV parameter.
        {
          configureModem("CCCFG", "NRV", 0);

          if (!consumeResult(RS_NRV_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set CTO parameter.
        {
          configureModem("CCCFG", "CTO", c_cto);

          if (!consumeResult(RS_CTO_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set TAT parameter.
        {
          configureModem("CCCFG", "TAT", m_args.turn_around_time);

          if (!consumeResult(RS_TAT_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        // Set XST parameter.
        {
          configureModem("CCCFG", "XST", 0);

          if (!consumeResult(RS_XST_ACKD))
          {
            setAndSendState(STA_ERR_STP);
            throw std::runtime_error(m_states[m_state].description);
          }
        }

        if (m_beacons.empty())
          setAndSendState(STA_NO_BEACONS);
        else
          setAndSendState(STA_IDLE);
      }