This document lists all available methods when importing the cp module for NCOS SDK applications.
add_advanced_apnalertclear_dns_cacheclear_logsclean_up_regcreate_userdecdeletedelete_advanced_apndelete_appdatadelete_userdecryptdisable_wan_devicedns_lookupdownload_packet_captureenable_wan_deviceensure_fresh_userensure_user_existsexecute_cliextract_cert_and_keyfactory_resetgetget_all_gpiosget_appdataget_apps_statusget_arp_tableget_asset_idget_available_gpiosget_available_interfacesget_bgp_statusget_certificate_by_nameget_certificate_by_uuidget_certificate_statusget_certificate_summaryget_certificatesget_client_usageget_comprehensive_statusget_descriptionget_dhcp_client_by_ipget_dhcp_client_by_macget_dhcp_clients_by_interfaceget_dhcp_clients_by_networkget_dhcp_interface_summaryget_dhcp_leasesget_dns_statusget_event_statusget_expiring_certificatesget_firewall_connectionsget_firewall_connections_by_ipget_firewall_connections_by_protocolget_firewall_hitcountersget_firewall_marksget_firewall_state_timeoutsget_firewall_statusget_flow_statisticsget_firmware_versionget_gpioget_gps_statusget_iot_statusget_ipv4_lan_clientsget_ipv4_wifi_clientsget_ipv4_wired_clientsget_lan_clientsget_lan_device_statsget_lan_devicesget_lan_networksget_lan_statisticsget_lan_statusget_loggerget_macget_ncm_account_nameget_ncm_api_keysget_ncm_group_nameget_ncm_router_idget_nameget_obd_statusget_openvpn_statusget_ospf_statusget_poe_statusget_power_usageget_product_typeget_qos_queue_by_nameget_qos_queuesget_qos_statusget_qos_traffic_statsget_raw_gpiosget_route_summaryget_router_modelget_routing_policiesget_routing_tableget_routing_table_by_nameget_sdwan_statusget_security_statusget_services_statusget_signal_strengthget_simsget_sensors_statusget_static_routesget_storage_statusget_system_statusget_temperatureget_usb_statusget_usersget_vpn_statusget_wan_connection_stateget_wan_devicesget_wan_devices_statusget_wan_device_profileget_wan_device_summaryget_wan_ethernet_infoget_wan_ip_addressget_wan_modem_diagnosticsget_wan_modem_statsget_wan_primary_deviceget_wan_profile_by_nameget_wan_profile_by_trigger_stringget_wan_profilesget_wan_statusget_wlan_channel_infoget_wlan_client_countget_wlan_client_count_by_bandget_wlan_clientsget_wlan_debugget_wlan_eventsget_wlan_radio_by_bandget_wlan_radio_statusget_wlan_region_configget_wlan_remote_statusget_wlan_stateget_wlan_statusget_wlan_tracelogmake_wan_device_highest_prioritymonitor_logmonitor_smsnetwork_connectivity_testpacket_captureping_hostpostpost_appdataputput_appdatareboot_deviceregisterremove_manual_apnreorder_wan_profilesreset_modemreset_wlanrestart_servicesend_smsset_asset_idset_descriptionset_log_levelset_manual_apnset_nameset_wan_device_bandwidthset_wan_device_default_connection_stateset_wan_device_priorityspeed_teststart_file_serverstart_packet_capturestart_streaming_capturestop_monitor_logstop_monitor_smsstop_packet_capturestop_pingstop_speed_testtraceroute_hostunregisteruptimewait_for_gps_fixwait_for_modem_connectionwait_for_ntpwait_for_uptimewait_for_wan_connection
get(base: str, query: str = '', tree: int = 0)→Optional[Dict[str, Any]]post(base: str, value: Any = '', query: str = '')→Optional[Dict[str, Any]]put(base: str, value: Any = '', query: str = '', tree: int = 0)→Optional[Dict[str, Any]]delete(base: str, query: str = '')→Optional[Dict[str, Any]]decrypt(base: str, query: str = '', tree: int = 0)→Optional[Dict[str, Any]]patch(value: List[Any])→Optional[Dict[str, Any]]
log(value: str = '')→Nonealert(value: str = '')→Optional[Dict[str, Any]]
register(action: str = 'set', path: str = '', callback: Callable = None, *args: Any)→Dict[str, Any]unregister(eid: int = 0)→Dict[str, Any]
get_uptime()→intget_mac(format_with_colons: bool = False)→Optional[str]get_serial_number()→Optional[str]get_product_type()→Optional[str]get_name()→Optional[str]get_firmware_version(include_build_info: bool = False)→strget_router_model()→Optional[str]
get_wan_status()→Dict[str, Any]get_wan_devices()→Dict[str, Any]get_wan_modem_diagnostics(device_id: str)→Dict[str, Any]get_wan_modem_stats(device_id: str)→Dict[str, Any]get_wan_ethernet_info(device_id: str)→Dict[str, Any]get_lan_status()→Dict[str, Any]get_lan_clients()→Dict[str, Any]get_lan_networks()→Dict[str, Any]get_lan_devices()→Dict[str, Any]get_lan_statistics()→Dict[str, Any]get_lan_device_stats(device_name: str)→Dict[str, Any]get_wlan_status()→Optional[Dict[str, Any]]get_wlan_clients()→List[Dict[str, Any]]get_wlan_radio_status()→List[Dict[str, Any]]get_wlan_radio_by_band(band: str = '2.4 GHz')→Optional[Dict[str, Any]]get_wlan_channel_info(band: Optional[str] = None, include_survey: bool = False)→Dict[str, Any]get_wlan_client_count()→intget_wlan_client_count_by_band()→Dict[str, int]get_wlan_events()→Dict[str, Any]get_wlan_region_config()→Dict[str, Any]get_wlan_remote_status()→Dict[str, Any]get_wlan_state()→strget_wlan_trace()→List[Dict[str, Any]]get_wlan_debug()→Dict[str, Any]
get_ipv4_wired_clients()→List[Dict[str, Any]]get_ipv4_wifi_clients()→List[Dict[str, Any]]get_ipv4_lan_clients()→Dict[str, List[Dict[str, Any]]]get_connected_wans(max_retries: int = 10)→List[str]get_sims(max_retries: int = 10)→List[str]
get_gps_status()→Dict[str, Any]get_lat_long(max_retries: int = 5, retry_delay: float = 0.1)→Tuple[Optional[float], Optional[float]]dec(deg: float, min: float = 0.0, sec: float = 0.0)→float
get_system_status()→Dict[str, Any]get_temperature(unit: str = 'fahrenheit')→Optional[float]get_power_usage(include_components: bool = True)→Optional[Dict[str, Any]]get_ncm_status(include_details: bool = False)→Optional[str]get_wan_devices_status()→Optional[Dict[str, Any]]get_signal_strength(uid: str, include_backlog: bool = False)→Optional[Dict[str, Any]]get_description()→Optional[Dict[str, Any]]get_asset_id()→Optional[Dict[str, Any]]set_description(description: str)→Optional[Dict[str, Any]]set_asset_id(asset_id: str)→Optional[Dict[str, Any]]set_name(name: str)→Optional[Dict[str, Any]]
get_appdata(name: str = '')→Optional[str]post_appdata(name: str = '', value: str = '')→Noneput_appdata(name: str = '', value: str = '')→Nonedelete_appdata(name: str = '')→None
get_ncm_api_keys()→Dict[str, Optional[str]]extract_cert_and_key(cert_name_or_uuid: str = '', return_filenames: bool = True, return_cert_content: bool = False, return_key_content: bool = False)→Union[Tuple[Optional[str], Optional[str]], Tuple[Optional[str], Optional[str], Optional[str], Optional[str]]]get_certificates()→List[Dict[str, Any]]get_certificate_by_name(cert_name: str)→Optional[Dict[str, Any]]get_certificate_by_uuid(cert_uuid: str)→Optional[Dict[str, Any]]get_expiring_certificates(days_threshold: int = 30)→List[Dict[str, Any]]get_certificate_summary()→Dict[str, Any]
wait_for_uptime(min_uptime_seconds: int = 60)→Nonewait_for_ntp(timeout: int = 300, check_interval: int = 1)→boolwait_for_wan_connection(timeout: int = 300)→boolwait_for_modem_connection(timeout: int = 300, check_interval: float = 1.0)→boolwait_for_gps_fix(timeout: int = 300, check_interval: float = 1.0)→bool
reboot_device(force: bool = False)→Nonefactory_reset()→bool
reset_modem(modem_id: Optional[str] = None, force: bool = False)→boolreset_wlan(force: bool = False)→bool
clear_logs()→boolrestart_service(service_name: str, force: bool = False)→boolset_log_level(level: str = 'info')→bool
get_openvpn_status()→Dict[str, Any]get_hotspot_status()→Optional[Dict[str, Any]]get_obd_status()→Dict[str, Any]get_qos_status()→Dict[str, Any]get_firewall_status()→Dict[str, Any]get_dns_status()→Dict[str, Any]get_dhcp_status()→Dict[str, Any]get_dhcp_leases()→Optional[List[Dict[str, Any]]]get_routing_table()→Optional[Dict[str, Any]]get_certificate_status()→Optional[Dict[str, Any]]get_storage_status(include_detailed: bool = False)→Optional[Dict[str, Any]]get_usb_status(include_all_ports: bool = False)→Optional[Dict[str, Any]]get_poe_status()→Optional[Dict[str, Any]]get_sensors_status()→Optional[Dict[str, Any]]get_services_status()→Optional[Dict[str, Any]]get_apps_status()→Optional[Dict[str, Any]]get_event_status()→Optional[Dict[str, Any]]get_flow_statistics()→Optional[Dict[str, Any]]get_client_usage()→Optional[Dict[str, Any]]get_vpn_status()→Optional[Dict[str, Any]]get_security_status()→Optional[Dict[str, Any]]get_iot_status()→Optional[Dict[str, Any]]get_sdwan_status()→Optional[Dict[str, Any]]get_comprehensive_status(include_detailed: bool = True, include_clients: bool = True)→Optional[Dict[str, Any]]
get_qos_queues()→List[Dict[str, Any]]get_qos_queue_by_name(queue_name: str = '')→Optional[Dict[str, Any]]get_qos_traffic_stats()→Dict[str, Any]
get_dhcp_clients_by_interface(interface_name: str = '')→List[Dict[str, Any]]get_dhcp_clients_by_network(network_name: str = '')→List[Dict[str, Any]]get_dhcp_client_by_mac(mac_address: str = '')→Optional[Dict[str, Any]]get_dhcp_client_by_ip(ip_address: str = '')→Optional[Dict[str, Any]]get_dhcp_interface_summary()→Dict[str, Any]
get_bgp_status()→Dict[str, Any]get_ospf_status()→Dict[str, Any]get_static_routes()→List[Dict[str, Any]]get_routing_policies()→List[Dict[str, Any]]get_routing_table_by_name(table_name: str)→List[Dict[str, Any]]get_arp_table()→strget_route_summary()→Dict[str, Any]
get_firewall_connections()→List[Dict[str, Any]]get_firewall_hitcounters()→List[Dict[str, Any]]get_firewall_marks()→Dict[str, Any]get_firewall_state_timeouts()→Dict[str, Any]get_firewall_connections_by_protocol(protocol: int = 6)→List[Dict[str, Any]]get_firewall_connections_by_ip(ip_address: str = '')→List[Dict[str, Any]]get_firewall_summary()→Dict[str, Any]
get_wan_profiles()→Dict[str, Any]get_wan_device_profile(device_id: str)→Optional[Dict[str, Any]]get_wan_profile_by_trigger_string(trigger_string: str)→Optional[Dict[str, Any]]get_wan_profile_by_name(profile_name: str)→Optional[Dict[str, Any]]get_wan_device_summary()→Dict[str, Any]get_wan_primary_device()→Optional[str]
set_wan_device_priority(device_id: str, new_priority: float)→boolmake_wan_device_highest_priority(device_id: str)→boolenable_wan_device(device_id: str)→booldisable_wan_device(device_id: str)→boolset_wan_device_default_connection_state(device_id: str, connection_state: str)→boolset_wan_device_bandwidth(device_id: str, ingress_kbps: int = None, egress_kbps: int = None)→boolreorder_wan_profiles(device_priorities: Dict[str, float])→bool
set_manual_apn(device_or_id: str, new_apn: str)→Optional[Dict[str, Any]]remove_manual_apn(device_or_id: str)→Optional[Dict[str, Any]]
add_advanced_apn(carrier: str, apn: str)→Optional[Dict[str, Any]]delete_advanced_apn(carrier_or_apn: str)→Optional[Dict[str, Any]]
ping_host(host: str, count: int = 4, timeout: float = 15.0, interval: float = 0.5, packet_size: int = 56, interface: str = None, bind_ip: bool = False)→Optional[Dict[str, Any]]traceroute_host(host: str, max_hops: int = 30, timeout: float = 5.0)→Optional[Dict[str, Any]]speed_test(host: str = "", interface: str = "", duration: int = 5, packet_size: int = 0, port: int = None, protocol: str = "tcp", direction: str = "both")→Optional[Dict[str, Any]]stop_speed_test()→Optional[Dict[str, Any]]network_connectivity_test(host: str = "8.8.8.8", port: int = 53, timeout: float = 5.0)→Optional[Dict[str, Any]]stop_ping()→Optional[Dict[str, Any]]
dns_lookup(hostname: str, record_type: str = "A")→Optional[Dict[str, Any]]clear_dns_cache()→Optional[Dict[str, Any]]
start_packet_capture(interface: str = "any", filter: str = "", count: int = 20, timeout: int = 600, wifichannel: str = "", wifichannelwidth: str = "", wifiextrachannel: str = "", url: str = "")→Optional[Dict[str, Any]]stop_packet_capture()→Optional[Dict[str, Any]]get_packet_capture_status()→Optional[Dict[str, Any]]download_packet_capture(filename: str, local_path: str = None, capture_params: dict = None)→Optional[Dict[str, Any]]start_streaming_capture(interface: str = "any", filter: str = "", wifichannel: str = "", wifichannelwidth: str = "", wifiextrachannel: str = "", url: str = "")→Optional[Dict[str, Any]]get_available_interfaces()→Optional[Dict[str, Any]]packet_capture(iface: str = None, filter: str = "", count: int = 10, timeout: int = 10, save_directory: str = "captures", capture_user: str = "SDKTCPDUMP")→Optional[Dict[str, Any]]
start_file_server(folder_path: str = "files", port: int = 8000, host: str = "0.0.0.0", title: str = "File Download")→Optional[Dict[str, Any]]
create_user(username: str, password: str, group: str = "admin")→Optional[Dict[str, Any]]get_users()→Optional[Dict[str, Any]]delete_user(username: str)→Optional[Dict[str, Any]]ensure_user_exists(username: str, password: str, group: str = "admin")→Optional[Dict[str, Any]]ensure_fresh_user(username: str, group: str = "admin")→Optional[Dict[str, Any]]
get_gpio(gpio_name: GPIOType, router_model: Optional[str] = None, return_path: bool = False)→Optional[Union[Any, str]]get_all_gpios(router_model: Optional[str] = None)→Dict[str, Any]get_available_gpios(router_model: Optional[str] = None)→List[str]get_raw_gpios()→Optional[Dict[str, Any]]
monitor_log(pattern: str = None, callback: callable = None, follow: bool = True, max_lines: int = 0, timeout: int = 0)→Optional[Dict[str, Any]]stop_monitor_log(monitor_result: Dict[str, Any])→Optional[Dict[str, Any]]monitor_sms(callback: callable, timeout: int = 0)→Optional[Dict[str, Any]]stop_monitor_sms(monitor_result: Dict[str, Any])→Optional[Dict[str, Any]]send_sms(phone_number: str = None, message: str = None, port: str = None)→Optional[str]execute_cli(commands: Union[str, List[str]], timeout: int = 10, soft_timeout: int = 5, clean: bool = True)→Optional[str]
get_ncm_router_id()→Optional[Dict[str, Any]]get_ncm_group_name()→Optional[Dict[str, Any]]get_ncm_account_name()→Optional[Dict[str, Any]]
get_logger()→Anyuptime()→float(monkey patched version)clean_up_reg(signal: Any, frame: Any)→None
import cp
# Get device information
device_name = cp.get_device_name()
uptime = cp.get_uptime()
# Get network status
wan_status = cp.get_wan_status()
lan_clients = cp.get_ipv4_lan_clients()
# Log information
cp.log(f"Device {device_name} has been up for {uptime} seconds")import cp
def config_change_callback(path, value, args):
cp.log(f"Configuration changed: {path} = {value}")
# Register for configuration changes
event_id = cp.register('put', '/config/system/logging/level', config_change_callback)import cp
# Get comprehensive status
status = cp.get_comprehensive_status()
# Wait for services to be ready
cp.wait_for_wan_connection()
cp.wait_for_gps_fix()import cp
# Get all WAN profiles
profiles = cp.get_wan_profiles()
# Set a device to highest priority
cp.make_wan_device_highest_priority("mdm-123456")
# Enable/disable devices
cp.enable_wan_device("ethernet-1")
cp.disable_wan_device("mdm-789012")
# Set connection state and bandwidth
cp.set_wan_device_default_connection_state("mdm-123456", "alwayson")
cp.set_wan_device_bandwidth("mdm-123456", ingress_kbps=5000, egress_kbps=1000)import cp
# Manual APN configuration using WAN rule ID
result = cp.set_manual_apn("00000006-a81d-3590-93ca-8b1fcfeb8e14", "custom.apn")
if result['success']:
print(f"Manual APN set successfully for rule {result['rule_id']}")
# Manual APN configuration using modem device name
result = cp.set_manual_apn("mdm-123456", "device.apn")
if result['success']:
print(f"Manual APN set for device {result['device_id']}")
# Remove manual APN
result = cp.remove_manual_apn("mdm-123456")
if result['success']:
print("Manual APN removed successfully")
# Advanced APN configuration
result = cp.add_advanced_apn("Verizon", "vzwinternet")
if result['success']:
print(f"Advanced APN added: {result['carrier']} -> {result['apn']}")
# Remove advanced APN by carrier
result = cp.delete_advanced_apn("Verizon")
if result['success']:
print(f"Removed {result['deleted_count']} advanced APN entries")
# Remove advanced APN by APN name
result = cp.delete_advanced_apn("vzwinternet")
if result['success']:
print(f"Removed {result['deleted_count']} advanced APN entries")import cp
# Ping a host
result = cp.ping_host("8.8.8.8", count=5)
if result:
print(f"Ping successful: {result['packet_loss']}% loss")
# Traceroute
result = cp.traceroute_host("google.com", max_hops=15)
if result:
print(f"Traceroute completed in {result['total_time']}ms")
# Speed test
result = cp.speed_test(host="speedtest.net", duration=10)
if result:
print(f"Download: {result['download_speed']} Mbps")
# DNS lookup
result = cp.dns_lookup("google.com", "A")
if result:
print(f"DNS resolution: {result['result']}")import cp
# Start packet capture
result = cp.start_packet_capture(interface="eth0", count=100, timeout=60)
if result['success']:
print(f"Capture started: {result['filename']}")
# Check capture status
status = cp.get_packet_capture_status()
print(f"Capture status: {status['status']}")
# Download captured file
result = cp.download_packet_capture("capture.pcap", "/local/path/")
if result['success']:
print("Capture file downloaded successfully")This comprehensive list shows that the cp module provides extensive functionality for interacting with NCOS routers, including:
- Status Monitoring: System, network, GPS, and device status information
- Network Operations: WAN/LAN management, routing, firewall, and QoS
- APN Management: Manual and advanced APN configuration for cellular modems
- Network Testing: Ping, traceroute, speed tests, and connectivity testing
- Packet Capture: Advanced packet capture and analysis capabilities
- System Control: Device management, user administration, and service control
- WAN Profile Management: Device prioritization, bandwidth control, and connection management
- Event Handling: Real-time configuration change monitoring
- GPIO Control: Hardware interface management
- File Operations: File server and data management capabilities
The module provides a complete SDK for developing applications that interact with NCOS routers, from simple status queries to complex network management operations.